Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
refactor(core): populate shipping_cost in payment response (#6351)
Swangi Kumari368e6b531098
diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.jsonindex 1db9c98806..5546d90514 100644--- a/api-reference-v2/openapi_spec.json+++ b/api-reference-v2/openapi_spec.json@@ -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","example": 6540},+ "shipping_cost": {+ "type": "integer",+ "format": "int64",+ "description": "The shipping cost for the payment.",+ "example": 6540,+ "nullable": true+ },"amount_capturable": {"type": "integer","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","example": 6540},+ "shipping_cost": {+ "type": "integer",+ "format": "int64",+ "description": "The shipping cost for the payment.",+ "example": 6540,+ "nullable": true+ },"amount_capturable": {"type": "integer","format": "int64",diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.jsonindex 28f1ec4b70..a7a4b04b46 100644--- a/api-reference/openapi_spec.json+++ b/api-reference/openapi_spec.json@@ -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","example": 6540},+ "shipping_cost": {+ "type": "integer",+ "format": "int64",+ "description": "The shipping cost for the payment.",+ "example": 6540,+ "nullable": true+ },"amount_capturable": {"type": "integer","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","example": 6540},+ "shipping_cost": {+ "type": "integer",+ "format": "int64",+ "description": "The shipping cost for the payment.",+ "example": 6540,+ "nullable": true+ },"amount_capturable": {"type": "integer","format": "int64",diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 71f383f014..65d785b0ff 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -4093,6 +4093,10 @@ pub struct PaymentsResponse {#[schema(value_type = i64, example = 6540)]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#[schema(value_type = i64, minimum = 100, example = 6540)]pub amount_capturable: MinorUnit,diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex 0d9d684cae..03ae1c8800 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -1342,6 +1342,7 @@ wheremerchant_order_reference_id: payment_intent.merchant_order_reference_id,order_tax_amount,connector_mandate_id,+ shipping_cost: payment_intent.shipping_cost,};services::ApplicationResponse::JsonWithHeaders((payments_response, headers))@@ -1598,6 +1599,7 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Payfrm_metadata: None,order_tax_amount: None,connector_mandate_id:None,+ shipping_cost: None,}}}diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rsindex 435e39acae..2638792e10 100644--- a/crates/router/tests/payments.rs+++ b/crates/router/tests/payments.rs@@ -446,6 +446,7 @@ async fn payments_create_core() {merchant_order_reference_id: None,order_tax_amount: None,connector_mandate_id: None,+ shipping_cost: None,};let expected_response =services::ApplicationResponse::JsonWithHeaders((expected_response, vec![]));@@ -704,6 +705,7 @@ async fn payments_create_core_adyen_no_redirect() {merchant_order_reference_id: None,order_tax_amount: None,connector_mandate_id: None,+ shipping_cost: None,},vec![],));diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rsindex b6c22c469d..07764606d1 100644--- a/crates/router/tests/payments2.rs+++ b/crates/router/tests/payments2.rs@@ -207,6 +207,7 @@ async fn payments_create_core() {merchant_order_reference_id: None,order_tax_amount: None,connector_mandate_id: None,+ shipping_cost: None,};let expected_response =@@ -474,6 +475,7 @@ async fn payments_create_core_adyen_no_redirect() {merchant_order_reference_id: None,order_tax_amount: None,connector_mandate_id: None,+ shipping_cost: None,},vec![],));