feat(router): add api_models and openapi changes for refunds create api v2 (#6385)

This commit is contained in:
Sai Harsha Vardhan
2024-10-23 16:53:46 +05:30
committed by GitHub
parent 4ef48c39b3
commit 5a10e5867a
15 changed files with 469 additions and 38 deletions

View File

@ -123,6 +123,9 @@ Never share your secret api keys. Keep them guarded and secure.
//Routes for payments
routes::payments::payments_create_intent,
//Routes for refunds
routes::refunds::refunds_create,
),
components(schemas(
common_utils::types::MinorUnit,
@ -140,6 +143,8 @@ Never share your secret api keys. Keep them guarded and secure.
common_utils::payout_method_utils::PaypalAdditionalData,
common_utils::payout_method_utils::VenmoAdditionalData,
api_models::refunds::RefundRequest,
api_models::refunds::RefundsCreateRequest,
api_models::refunds::RefundErrorDetails,
api_models::refunds::RefundType,
api_models::refunds::RefundResponse,
api_models::refunds::RefundStatus,

View File

@ -44,6 +44,7 @@
operation_id = "Create a Refund",
security(("api_key" = []))
)]
#[cfg(feature = "v1")]
pub async fn refunds_create() {}
/// Refunds - Retrieve
@ -159,3 +160,55 @@ pub fn refunds_list_profile() {}
security(("api_key" = []))
)]
pub async fn refunds_filter_list() {}
/// Refunds - Create
///
/// Creates a refund against an already processed payment. In case of some processors, you can even opt to refund only a partial amount multiple times until the original charge amount has been refunded
#[utoipa::path(
post,
path = "/v2/refunds",
request_body(
content = RefundsCreateRequest,
examples(
(
"Create an instant refund to refund the whole amount" = (
value = json!({
"payment_id": "{{payment_id}}",
"merchant_reference_id": "ref_123",
"refund_type": "instant"
})
)
),
(
"Create an instant refund to refund partial amount" = (
value = json!({
"payment_id": "{{payment_id}}",
"merchant_reference_id": "ref_123",
"refund_type": "instant",
"amount": 654
})
)
),
(
"Create an instant refund with reason" = (
value = json!({
"payment_id": "{{payment_id}}",
"merchant_reference_id": "ref_123",
"refund_type": "instant",
"amount": 6540,
"reason": "Customer returned product"
})
)
),
)
),
responses(
(status = 200, description = "Refund created", body = RefundResponse),
(status = 400, description = "Missing Mandatory fields")
),
tag = "Refunds",
operation_id = "Create a Refund",
security(("api_key" = []))
)]
#[cfg(feature = "v2")]
pub async fn refunds_create() {}