Skip to content

Commit

Permalink
refactor(core): populate shipping_cost in payment response (#6351)
Browse files Browse the repository at this point in the history
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
  • Loading branch information
swangi-kumari and hyperswitch-bot[bot] authored Oct 18, 2024
1 parent 3cf6210 commit 368e6b5
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 0 deletions.
14 changes: 14 additions & 0 deletions api-reference-v2/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions api-reference/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/core/payments/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,7 @@ where
merchant_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))
Expand Down Expand Up @@ -1598,6 +1599,7 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Pay
frm_metadata: None,
order_tax_amount: None,
connector_mandate_id:None,
shipping_cost: None,
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/router/tests/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![]));
Expand Down Expand Up @@ -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![],
));
Expand Down
2 changes: 2 additions & 0 deletions crates/router/tests/payments2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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![],
));
Expand Down

0 comments on commit 368e6b5

Please sign in to comment.