refactor(core): populate shipping_cost in payment response (#6351)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Swangi Kumari
2024-10-18 18:49:04 +05:30
committed by GitHub
parent 3cf6210176
commit 368e6b5310
6 changed files with 38 additions and 0 deletions

View File

@ -14085,6 +14085,13 @@
"description": "The payment net amount. net_amount = amount + surcharge_details.surcharge_amount + surcharge_details.tax_amount + shipping_cost + order_tax_amount,\nIf no surcharge_details, shipping_cost, order_tax_amount, net_amount = amount", "description": "The payment net amount. net_amount = amount + surcharge_details.surcharge_amount + surcharge_details.tax_amount + shipping_cost + order_tax_amount,\nIf no surcharge_details, shipping_cost, order_tax_amount, net_amount = amount",
"example": 6540 "example": 6540
}, },
"shipping_cost": {
"type": "integer",
"format": "int64",
"description": "The shipping cost for the payment.",
"example": 6540,
"nullable": true
},
"amount_capturable": { "amount_capturable": {
"type": "integer", "type": "integer",
"format": "int64", "format": "int64",
@ -15224,6 +15231,13 @@
"description": "The payment net amount. net_amount = amount + surcharge_details.surcharge_amount + surcharge_details.tax_amount + shipping_cost + order_tax_amount,\nIf no surcharge_details, shipping_cost, order_tax_amount, net_amount = amount", "description": "The payment net amount. net_amount = amount + surcharge_details.surcharge_amount + surcharge_details.tax_amount + shipping_cost + order_tax_amount,\nIf no surcharge_details, shipping_cost, order_tax_amount, net_amount = amount",
"example": 6540 "example": 6540
}, },
"shipping_cost": {
"type": "integer",
"format": "int64",
"description": "The shipping cost for the payment.",
"example": 6540,
"nullable": true
},
"amount_capturable": { "amount_capturable": {
"type": "integer", "type": "integer",
"format": "int64", "format": "int64",

View File

@ -17347,6 +17347,13 @@
"description": "The payment net amount. net_amount = amount + surcharge_details.surcharge_amount + surcharge_details.tax_amount + shipping_cost + order_tax_amount,\nIf no surcharge_details, shipping_cost, order_tax_amount, net_amount = amount", "description": "The payment net amount. net_amount = amount + surcharge_details.surcharge_amount + surcharge_details.tax_amount + shipping_cost + order_tax_amount,\nIf no surcharge_details, shipping_cost, order_tax_amount, net_amount = amount",
"example": 6540 "example": 6540
}, },
"shipping_cost": {
"type": "integer",
"format": "int64",
"description": "The shipping cost for the payment.",
"example": 6540,
"nullable": true
},
"amount_capturable": { "amount_capturable": {
"type": "integer", "type": "integer",
"format": "int64", "format": "int64",
@ -18535,6 +18542,13 @@
"description": "The payment net amount. net_amount = amount + surcharge_details.surcharge_amount + surcharge_details.tax_amount + shipping_cost + order_tax_amount,\nIf no surcharge_details, shipping_cost, order_tax_amount, net_amount = amount", "description": "The payment net amount. net_amount = amount + surcharge_details.surcharge_amount + surcharge_details.tax_amount + shipping_cost + order_tax_amount,\nIf no surcharge_details, shipping_cost, order_tax_amount, net_amount = amount",
"example": 6540 "example": 6540
}, },
"shipping_cost": {
"type": "integer",
"format": "int64",
"description": "The shipping cost for the payment.",
"example": 6540,
"nullable": true
},
"amount_capturable": { "amount_capturable": {
"type": "integer", "type": "integer",
"format": "int64", "format": "int64",

View File

@ -4093,6 +4093,10 @@ pub struct PaymentsResponse {
#[schema(value_type = i64, example = 6540)] #[schema(value_type = i64, example = 6540)]
pub net_amount: MinorUnit, pub net_amount: MinorUnit,
/// The shipping cost for the payment.
#[schema(value_type = Option<i64>, example = 6540)]
pub shipping_cost: Option<MinorUnit>,
/// The maximum amount that could be captured from the payment /// The maximum amount that could be captured from the payment
#[schema(value_type = i64, minimum = 100, example = 6540)] #[schema(value_type = i64, minimum = 100, example = 6540)]
pub amount_capturable: MinorUnit, pub amount_capturable: MinorUnit,

View File

@ -1342,6 +1342,7 @@ where
merchant_order_reference_id: payment_intent.merchant_order_reference_id, merchant_order_reference_id: payment_intent.merchant_order_reference_id,
order_tax_amount, order_tax_amount,
connector_mandate_id, connector_mandate_id,
shipping_cost: payment_intent.shipping_cost,
}; };
services::ApplicationResponse::JsonWithHeaders((payments_response, headers)) services::ApplicationResponse::JsonWithHeaders((payments_response, headers))
@ -1598,6 +1599,7 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Pay
frm_metadata: None, frm_metadata: None,
order_tax_amount: None, order_tax_amount: None,
connector_mandate_id:None, connector_mandate_id:None,
shipping_cost: None,
} }
} }
} }

View File

@ -446,6 +446,7 @@ async fn payments_create_core() {
merchant_order_reference_id: None, merchant_order_reference_id: None,
order_tax_amount: None, order_tax_amount: None,
connector_mandate_id: None, connector_mandate_id: None,
shipping_cost: None,
}; };
let expected_response = let expected_response =
services::ApplicationResponse::JsonWithHeaders((expected_response, vec![])); services::ApplicationResponse::JsonWithHeaders((expected_response, vec![]));
@ -704,6 +705,7 @@ async fn payments_create_core_adyen_no_redirect() {
merchant_order_reference_id: None, merchant_order_reference_id: None,
order_tax_amount: None, order_tax_amount: None,
connector_mandate_id: None, connector_mandate_id: None,
shipping_cost: None,
}, },
vec![], vec![],
)); ));

View File

@ -207,6 +207,7 @@ async fn payments_create_core() {
merchant_order_reference_id: None, merchant_order_reference_id: None,
order_tax_amount: None, order_tax_amount: None,
connector_mandate_id: None, connector_mandate_id: None,
shipping_cost: None,
}; };
let expected_response = let expected_response =
@ -474,6 +475,7 @@ async fn payments_create_core_adyen_no_redirect() {
merchant_order_reference_id: None, merchant_order_reference_id: None,
order_tax_amount: None, order_tax_amount: None,
connector_mandate_id: None, connector_mandate_id: None,
shipping_cost: None,
}, },
vec![], vec![],
)); ));