diff --git a/crates/router/src/connector/cryptopay.rs b/crates/router/src/connector/cryptopay.rs index 2f9c996eff..7245694bd4 100644 --- a/crates/router/src/connector/cryptopay.rs +++ b/crates/router/src/connector/cryptopay.rs @@ -287,11 +287,14 @@ impl ConnectorIntegration - TryFrom> - for types::RouterData + TryFrom<( + types::ResponseRouterData, + diesel_models::enums::Currency, + )> for types::RouterData { type Error = error_stack::Report; fn try_from( - item: types::ResponseRouterData< - F, - CryptopayPaymentsResponse, - T, - types::PaymentsResponseData, - >, + (item, currency): ( + types::ResponseRouterData, + diesel_models::enums::Currency, + ), ) -> Result { let status = enums::AttemptStatus::from(item.response.data.status.clone()); let response = if is_payment_failure(status) { @@ -197,11 +199,28 @@ impl incremental_authorization_allowed: None, }) }; - Ok(Self { - status, - response, - ..item.data - }) + + match item.response.data.price_amount { + Some(price_amount) => { + let amount_captured = Some( + connector_utils::to_currency_lower_unit(price_amount, currency)? + .parse::() + .change_context(errors::ConnectorError::ParsingFailed)?, + ); + + Ok(Self { + status, + response, + amount_captured, + ..item.data + }) + } + None => Ok(Self { + status, + response, + ..item.data + }), + } } } diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 23b3f1f693..c8de432fc0 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -1220,6 +1220,7 @@ impl TryFrom> for types::PaymentsSyncData None => types::SyncRequestType::SinglePaymentSync, }, payment_method_type: payment_data.payment_attempt.payment_method_type, + currency: payment_data.currency, }) } } diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs index 6004131be4..951be887ed 100644 --- a/crates/router/src/types.rs +++ b/crates/router/src/types.rs @@ -565,6 +565,7 @@ pub struct PaymentsSyncData { pub sync_type: SyncRequestType, pub mandate_id: Option, pub payment_method_type: Option, + pub currency: storage_enums::Currency, } #[derive(Debug, Default, Clone)] diff --git a/crates/router/tests/connectors/bambora.rs b/crates/router/tests/connectors/bambora.rs index 46f61271ee..5cd82d097a 100644 --- a/crates/router/tests/connectors/bambora.rs +++ b/crates/router/tests/connectors/bambora.rs @@ -109,6 +109,7 @@ async fn should_sync_authorized_payment() { sync_type: types::SyncRequestType::SinglePaymentSync, connector_meta: None, payment_method_type: None, + currency: enums::Currency::USD, }), None, ) @@ -224,6 +225,7 @@ async fn should_sync_auto_captured_payment() { sync_type: types::SyncRequestType::SinglePaymentSync, connector_meta: None, payment_method_type: None, + currency: enums::Currency::USD, }), None, ) diff --git a/crates/router/tests/connectors/forte.rs b/crates/router/tests/connectors/forte.rs index c7934b3711..c58cab38a2 100644 --- a/crates/router/tests/connectors/forte.rs +++ b/crates/router/tests/connectors/forte.rs @@ -157,6 +157,7 @@ async fn should_sync_authorized_payment() { connector_meta: None, mandate_id: None, payment_method_type: None, + currency: enums::Currency::USD, }), get_default_payment_info(), ) diff --git a/crates/router/tests/connectors/nexinets.rs b/crates/router/tests/connectors/nexinets.rs index 7f42048c98..5948855ae8 100644 --- a/crates/router/tests/connectors/nexinets.rs +++ b/crates/router/tests/connectors/nexinets.rs @@ -125,6 +125,7 @@ async fn should_sync_authorized_payment() { connector_meta, mandate_id: None, payment_method_type: None, + currency: enums::Currency::EUR, }), None, ) diff --git a/crates/router/tests/connectors/paypal.rs b/crates/router/tests/connectors/paypal.rs index 14690ae2a7..bded135f45 100644 --- a/crates/router/tests/connectors/paypal.rs +++ b/crates/router/tests/connectors/paypal.rs @@ -142,6 +142,7 @@ async fn should_sync_authorized_payment() { sync_type: types::SyncRequestType::SinglePaymentSync, connector_meta, payment_method_type: None, + currency: enums::Currency::USD, }), get_default_payment_info(), ) @@ -339,6 +340,7 @@ async fn should_sync_auto_captured_payment() { sync_type: types::SyncRequestType::SinglePaymentSync, connector_meta, payment_method_type: None, + currency: enums::Currency::USD, }), get_default_payment_info(), ) diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rs index 47ec71cc94..6294108c82 100644 --- a/crates/router/tests/connectors/utils.rs +++ b/crates/router/tests/connectors/utils.rs @@ -997,6 +997,7 @@ impl Default for PaymentSyncType { sync_type: types::SyncRequestType::SinglePaymentSync, connector_meta: None, payment_method_type: None, + currency: enums::Currency::USD, }; Self(data) } diff --git a/crates/router/tests/connectors/zen.rs b/crates/router/tests/connectors/zen.rs index c9a7be2b0a..95017e7da0 100644 --- a/crates/router/tests/connectors/zen.rs +++ b/crates/router/tests/connectors/zen.rs @@ -104,6 +104,7 @@ async fn should_sync_authorized_payment() { connector_meta: None, mandate_id: None, payment_method_type: None, + currency: enums::Currency::USD, }), None, ) @@ -219,6 +220,7 @@ async fn should_sync_auto_captured_payment() { connector_meta: None, mandate_id: None, payment_method_type: None, + currency: enums::Currency::USD, }), None, )