diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index 41b2c0f80e44..b038b16b333e 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -15314,7 +15314,7 @@ "split_payments": { "allOf": [ { - "$ref": "#/components/schemas/SplitPaymentsResponse" + "$ref": "#/components/schemas/ConnectorChargeResponseData" } ], "nullable": true @@ -16214,7 +16214,7 @@ "split_payments": { "allOf": [ { - "$ref": "#/components/schemas/SplitPaymentsResponse" + "$ref": "#/components/schemas/ConnectorChargeResponseData" } ], "nullable": true @@ -20400,7 +20400,7 @@ ], "description": "Fee information for Split Payments to be charged on the payment being collected" }, - "SplitPaymentsResponse": { + "ConnectorChargeResponseData": { "oneOf": [ { "type": "object", @@ -20409,7 +20409,7 @@ ], "properties": { "stripe_split_payment": { - "$ref": "#/components/schemas/StripeSplitPaymentsResponse" + "$ref": "#/components/schemas/StripeChargeResponseData" } } } @@ -20533,7 +20533,7 @@ }, "additionalProperties": false }, - "StripeSplitPaymentsResponse": { + "StripeChargeResponseData": { "type": "object", "description": "Fee information to be charged on the payment being collected", "required": [ diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index c29c253b1fca..56a7a0bcd593 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -18807,7 +18807,7 @@ "split_payments": { "allOf": [ { - "$ref": "#/components/schemas/SplitPaymentsResponse" + "$ref": "#/components/schemas/ConnectorChargeResponseData" } ], "nullable": true @@ -20050,7 +20050,7 @@ "split_payments": { "allOf": [ { - "$ref": "#/components/schemas/SplitPaymentsResponse" + "$ref": "#/components/schemas/ConnectorChargeResponseData" } ], "nullable": true @@ -24946,7 +24946,7 @@ ], "description": "Fee information for Split Payments to be charged on the payment being collected" }, - "SplitPaymentsResponse": { + "ConnectorChargeResponseData": { "oneOf": [ { "type": "object", @@ -24955,7 +24955,7 @@ ], "properties": { "stripe_split_payment": { - "$ref": "#/components/schemas/StripeSplitPaymentsResponse" + "$ref": "#/components/schemas/StripeChargeResponseData" } } } @@ -25079,7 +25079,7 @@ }, "additionalProperties": false }, - "StripeSplitPaymentsResponse": { + "StripeChargeResponseData": { "type": "object", "description": "Fee information to be charged on the payment being collected", "required": [ diff --git a/connector-template/transformers.rs b/connector-template/transformers.rs index b508596cbc08..73e167d89fd6 100644 --- a/connector-template/transformers.rs +++ b/connector-template/transformers.rs @@ -138,7 +138,7 @@ impl TryFrom, /// Fee information to be charged on the payment being collected - pub split_payments: Option, + pub split_payments: Option, /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. FRM Metadata is useful for storing additional, structured information on an object related to FRM. #[schema(value_type = Option, example = r#"{ "fulfillment_method" : "deliver", "coverage_request" : "fraud" }"#)] @@ -4991,31 +4991,6 @@ pub struct PaymentStartRedirectionParams { pub profile_id: id_type::ProfileId, } -/// Fee information to be charged on the payment being collected -#[derive(Setter, Clone, Debug, PartialEq, serde::Serialize, ToSchema)] -pub struct StripeSplitPaymentsResponse { - /// Identifier for charge created for the payment - pub charge_id: Option, - - /// Type of charge (connector specific) - #[schema(value_type = PaymentChargeType, example = "direct")] - pub charge_type: api_enums::PaymentChargeType, - - /// Platform fees collected on the payment - #[schema(value_type = i64, example = 6540)] - pub application_fees: MinorUnit, - - /// Identifier for the reseller's account where the funds were transferred - pub transfer_account_id: String, -} - -#[derive(Clone, Debug, PartialEq, serde::Serialize, ToSchema)] -#[serde(rename_all = "snake_case")] -pub enum SplitPaymentsResponse { - /// StripeSplitPaymentsResponse - StripeSplitPayment(StripeSplitPaymentsResponse), -} - /// Details of external authentication #[derive(Setter, Clone, Default, Debug, PartialEq, serde::Serialize, ToSchema)] pub struct ExternalAuthenticationDetailsResponse { diff --git a/crates/common_enums/Cargo.toml b/crates/common_enums/Cargo.toml index 92fc2f02066b..f8f25593c8bd 100644 --- a/crates/common_enums/Cargo.toml +++ b/crates/common_enums/Cargo.toml @@ -13,7 +13,7 @@ openapi = [] payouts = [] [dependencies] -diesel = { version = "2.2.3", features = ["postgres"] } +diesel = { version = "2.2.3", features = ["postgres", "128-column-tables"]} serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.115" strum = { version = "0.26", features = ["derive"] } diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 562b4fdf2692..3a4da2ffd8c7 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -3650,3 +3650,41 @@ pub enum FeatureStatus { NotSupported, Supported, } + +#[derive( + Clone, + Debug, + Eq, + PartialEq, + serde::Deserialize, + serde::Serialize, + strum::Display, + strum::EnumString, + ToSchema, +)] +#[strum(serialize_all = "PascalCase")] +#[serde(rename_all = "PascalCase")] +pub enum AdyenSplitType { + /// Books split amount to the specified account. + BalanceAccount, + /// The aggregated amount of the interchange and scheme fees. + AcquiringFees, + /// The aggregated amount of all transaction fees. + PaymentFee, + /// The aggregated amount of Adyen's commission and markup fees. + AdyenFees, + /// The transaction fees due to Adyen under blended rates. + AdyenCommission, + /// The transaction fees due to Adyen under Interchange ++ pricing. + AdyenMarkup, + /// The fees paid to the issuer for each payment made with the card network. + Interchange, + /// The fees paid to the card scheme for using their network. + SchemeFee, + /// Your platform's commission on the payment (specified in amount), booked to your liable balance account. + Commission, + /// Allows you and your users to top up balance accounts using direct debit, card payments, or other payment methods. + TopUp, + /// The value-added tax charged on the payment, booked to your platforms liable balance account. + Vat, +} diff --git a/crates/common_types/src/domain.rs b/crates/common_types/src/domain.rs new file mode 100644 index 000000000000..875fc6cb4e24 --- /dev/null +++ b/crates/common_types/src/domain.rs @@ -0,0 +1,43 @@ +//! Common types + +use common_enums::enums; +use common_utils::{impl_to_sql_from_sql_json, types::MinorUnit}; +use diesel::{sql_types::Jsonb, AsExpression, FromSqlRow}; +use serde::{Deserialize, Serialize}; +use utoipa::ToSchema; + +#[derive( + Serialize, Deserialize, Debug, Clone, PartialEq, Eq, FromSqlRow, AsExpression, ToSchema, +)] +#[diesel(sql_type = Jsonb)] +#[serde(deny_unknown_fields)] +/// Fee information for Split Payments to be charged on the payment being collected for Adyen +pub struct AdyenSplitData { + /// The store identifier + pub store: Option, + /// Data for the split items + pub split_items: Vec, +} +impl_to_sql_from_sql_json!(AdyenSplitData); + +#[derive( + Serialize, Deserialize, Debug, Clone, PartialEq, Eq, FromSqlRow, AsExpression, ToSchema, +)] +#[diesel(sql_type = Jsonb)] +#[serde(deny_unknown_fields)] +/// Data for the split items +pub struct AdyenSplitItem { + /// The amount of the split item + #[schema(value_type = i64, example = 6540)] + pub amount: Option, + /// Defines type of split item + #[schema(value_type = AdyenSplitType, example = "BalanceAccount")] + pub split_type: enums::AdyenSplitType, + /// The unique identifier of the account to which the split amount is allocated. + pub account: Option, + /// Unique Identifier for the split item + pub reference: Option, + /// Description for the part of the payment that will be allocated to the specified account. + pub description: Option, +} +impl_to_sql_from_sql_json!(AdyenSplitItem); diff --git a/crates/common_types/src/lib.rs b/crates/common_types/src/lib.rs index b0b258ecb6d8..6139ddff16ae 100644 --- a/crates/common_types/src/lib.rs +++ b/crates/common_types/src/lib.rs @@ -2,6 +2,7 @@ #![warn(missing_docs, missing_debug_implementations)] +pub mod domain; pub mod payment_methods; pub mod payments; pub mod refunds; diff --git a/crates/common_types/src/payments.rs b/crates/common_types/src/payments.rs index 080756056288..8222c7796e4d 100644 --- a/crates/common_types/src/payments.rs +++ b/crates/common_types/src/payments.rs @@ -8,6 +8,8 @@ use diesel::{sql_types::Jsonb, AsExpression, FromSqlRow}; use serde::{Deserialize, Serialize}; use utoipa::ToSchema; +use crate::domain as domain_types; + #[derive( Serialize, Deserialize, Debug, Clone, PartialEq, Eq, FromSqlRow, AsExpression, ToSchema, )] @@ -18,6 +20,8 @@ use utoipa::ToSchema; pub enum SplitPaymentsRequest { /// StripeSplitPayment StripeSplitPayment(StripeSplitPaymentRequest), + /// AdyenSplitPayment + AdyenSplitPayment(domain_types::AdyenSplitData), } impl_to_sql_from_sql_json!(SplitPaymentsRequest); @@ -65,3 +69,41 @@ impl AuthenticationConnectorAccountMap { .cloned() } } + +/// Fee information to be charged on the payment being collected via Stripe +#[derive( + Serialize, Deserialize, Debug, Clone, PartialEq, Eq, FromSqlRow, AsExpression, ToSchema, +)] +#[diesel(sql_type = Jsonb)] +#[serde(deny_unknown_fields)] +pub struct StripeChargeResponseData { + /// Identifier for charge created for the payment + pub charge_id: Option, + + /// Type of charge (connector specific) + #[schema(value_type = PaymentChargeType, example = "direct")] + pub charge_type: enums::PaymentChargeType, + + /// Platform fees collected on the payment + #[schema(value_type = i64, example = 6540)] + pub application_fees: MinorUnit, + + /// Identifier for the reseller's account where the funds were transferred + pub transfer_account_id: String, +} +impl_to_sql_from_sql_json!(StripeChargeResponseData); + +/// Charge Information +#[derive( + Serialize, Deserialize, Debug, Clone, PartialEq, Eq, FromSqlRow, AsExpression, ToSchema, +)] +#[diesel(sql_type = Jsonb)] +#[serde(deny_unknown_fields)] +pub enum ConnectorChargeResponseData { + /// StripeChargeResponseData + StripeSplitPayment(StripeChargeResponseData), + /// AdyenChargeResponseData + AdyenSplitPayment(domain_types::AdyenSplitData), +} + +impl_to_sql_from_sql_json!(ConnectorChargeResponseData); diff --git a/crates/common_types/src/refunds.rs b/crates/common_types/src/refunds.rs index e4b7c5a336fa..14223d32a47b 100644 --- a/crates/common_types/src/refunds.rs +++ b/crates/common_types/src/refunds.rs @@ -5,6 +5,8 @@ use diesel::{sql_types::Jsonb, AsExpression, FromSqlRow}; use serde::{Deserialize, Serialize}; use utoipa::ToSchema; +use crate::domain as domain_types; + #[derive( Serialize, Deserialize, Debug, Clone, PartialEq, Eq, FromSqlRow, AsExpression, ToSchema, )] @@ -15,6 +17,8 @@ use utoipa::ToSchema; pub enum SplitRefund { /// StripeSplitRefundRequest StripeSplitRefund(StripeSplitRefundRequest), + /// AdyenSplitRefundRequest + AdyenSplitRefund(domain_types::AdyenSplitData), } impl_to_sql_from_sql_json!(SplitRefund); diff --git a/crates/diesel_models/Cargo.toml b/crates/diesel_models/Cargo.toml index 5da67eb30759..4f02cc4aea87 100644 --- a/crates/diesel_models/Cargo.toml +++ b/crates/diesel_models/Cargo.toml @@ -17,7 +17,7 @@ payment_methods_v2 = [] [dependencies] async-bb8-diesel = { git = "https://github.com/jarnura/async-bb8-diesel", rev = "53b4ab901aab7635c8215fd1c2d542c8db443094" } -diesel = { version = "2.2.3", features = ["postgres", "serde_json", "time", "64-column-tables"] } +diesel = { version = "2.2.3", features = ["postgres", "serde_json", "time", "128-column-tables"] } error-stack = "0.4.1" rustc-hash = "1.1.0" serde = { version = "1.0.197", features = ["derive"] } diff --git a/crates/diesel_models/src/payment_attempt.rs b/crates/diesel_models/src/payment_attempt.rs index a450a30fa760..c7464f554896 100644 --- a/crates/diesel_models/src/payment_attempt.rs +++ b/crates/diesel_models/src/payment_attempt.rs @@ -94,6 +94,7 @@ pub struct PaymentAttempt { pub shipping_cost: Option, pub order_tax_amount: Option, pub connector_mandate_detail: Option, + pub charges: Option, } #[cfg(feature = "v1")] @@ -172,6 +173,7 @@ pub struct PaymentAttempt { pub order_tax_amount: Option, pub connector_transaction_data: Option, pub connector_mandate_detail: Option, + pub charges: Option, } #[cfg(feature = "v1")] @@ -471,6 +473,7 @@ pub enum PaymentAttemptUpdate { payment_method_data: Option, charge_id: Option, connector_mandate_detail: Option, + charges: Option, }, UnresolvedResponseUpdate { status: storage_enums::AttemptStatus, @@ -848,6 +851,7 @@ pub struct PaymentAttemptUpdateInternal { pub order_tax_amount: Option, pub connector_transaction_data: Option, pub connector_mandate_detail: Option, + pub charges: Option, } #[cfg(feature = "v1")] @@ -1031,6 +1035,7 @@ impl PaymentAttemptUpdate { order_tax_amount, connector_transaction_data, connector_mandate_detail, + charges, } = PaymentAttemptUpdateInternal::from(self).populate_derived_fields(&source); PaymentAttempt { amount: amount.unwrap_or(source.amount), @@ -1089,6 +1094,7 @@ impl PaymentAttemptUpdate { connector_transaction_data: connector_transaction_data .or(source.connector_transaction_data), connector_mandate_detail: connector_mandate_detail.or(source.connector_mandate_detail), + charges: charges.or(source.charges), ..source } } @@ -2141,6 +2147,7 @@ impl From for PaymentAttemptUpdateInternal { order_tax_amount: None, connector_transaction_data: None, connector_mandate_detail: None, + charges: None, }, PaymentAttemptUpdate::AuthenticationTypeUpdate { authentication_type, @@ -2197,6 +2204,7 @@ impl From for PaymentAttemptUpdateInternal { order_tax_amount: None, connector_transaction_data: None, connector_mandate_detail: None, + charges: None, }, PaymentAttemptUpdate::ConfirmUpdate { amount, @@ -2284,6 +2292,7 @@ impl From for PaymentAttemptUpdateInternal { order_tax_amount, connector_transaction_data: None, connector_mandate_detail, + charges: None, }, PaymentAttemptUpdate::VoidUpdate { status, @@ -2341,6 +2350,7 @@ impl From for PaymentAttemptUpdateInternal { order_tax_amount: None, connector_transaction_data: None, connector_mandate_detail: None, + charges: None, }, PaymentAttemptUpdate::RejectUpdate { status, @@ -2399,6 +2409,7 @@ impl From for PaymentAttemptUpdateInternal { order_tax_amount: None, connector_transaction_data: None, connector_mandate_detail: None, + charges: None, }, PaymentAttemptUpdate::BlocklistUpdate { status, @@ -2457,6 +2468,7 @@ impl From for PaymentAttemptUpdateInternal { order_tax_amount: None, connector_transaction_data: None, connector_mandate_detail: None, + charges: None, }, PaymentAttemptUpdate::ConnectorMandateDetailUpdate { connector_mandate_detail, @@ -2513,6 +2525,7 @@ impl From for PaymentAttemptUpdateInternal { order_tax_amount: None, connector_transaction_data: None, connector_mandate_detail, + charges: None, }, PaymentAttemptUpdate::PaymentMethodDetailsUpdate { payment_method_id, @@ -2569,6 +2582,7 @@ impl From for PaymentAttemptUpdateInternal { order_tax_amount: None, connector_transaction_data: None, connector_mandate_detail: None, + charges: None, }, PaymentAttemptUpdate::ResponseUpdate { status, @@ -2592,6 +2606,7 @@ impl From for PaymentAttemptUpdateInternal { payment_method_data, charge_id, connector_mandate_detail, + charges, } => { let (connector_transaction_id, connector_transaction_data) = connector_transaction_id @@ -2650,6 +2665,7 @@ impl From for PaymentAttemptUpdateInternal { shipping_cost: None, order_tax_amount: None, connector_mandate_detail, + charges, } } PaymentAttemptUpdate::ErrorUpdate { @@ -2723,6 +2739,7 @@ impl From for PaymentAttemptUpdateInternal { shipping_cost: None, order_tax_amount: None, connector_mandate_detail: None, + charges: None, } } PaymentAttemptUpdate::StatusUpdate { status, updated_by } => Self { @@ -2777,6 +2794,7 @@ impl From for PaymentAttemptUpdateInternal { order_tax_amount: None, connector_transaction_data: None, connector_mandate_detail: None, + charges: None, }, PaymentAttemptUpdate::UpdateTrackers { payment_token, @@ -2839,6 +2857,7 @@ impl From for PaymentAttemptUpdateInternal { order_tax_amount: None, connector_transaction_data: None, connector_mandate_detail: None, + charges: None, }, PaymentAttemptUpdate::UnresolvedResponseUpdate { status, @@ -2908,6 +2927,7 @@ impl From for PaymentAttemptUpdateInternal { shipping_cost: None, order_tax_amount: None, connector_mandate_detail: None, + charges: None, } } PaymentAttemptUpdate::PreprocessingUpdate { @@ -2976,6 +2996,7 @@ impl From for PaymentAttemptUpdateInternal { shipping_cost: None, order_tax_amount: None, connector_mandate_detail: None, + charges: None, } } PaymentAttemptUpdate::CaptureUpdate { @@ -3034,6 +3055,7 @@ impl From for PaymentAttemptUpdateInternal { order_tax_amount: None, connector_transaction_data: None, connector_mandate_detail: None, + charges: None, }, PaymentAttemptUpdate::AmountToCaptureUpdate { status, @@ -3091,6 +3113,7 @@ impl From for PaymentAttemptUpdateInternal { order_tax_amount: None, connector_transaction_data: None, connector_mandate_detail: None, + charges: None, }, PaymentAttemptUpdate::ConnectorResponse { authentication_data, @@ -3157,6 +3180,7 @@ impl From for PaymentAttemptUpdateInternal { shipping_cost: None, order_tax_amount: None, connector_mandate_detail: None, + charges: None, } } PaymentAttemptUpdate::IncrementalAuthorizationAmountUpdate { @@ -3214,6 +3238,7 @@ impl From for PaymentAttemptUpdateInternal { order_tax_amount: None, connector_transaction_data: None, connector_mandate_detail: None, + charges: None, }, PaymentAttemptUpdate::AuthenticationUpdate { status, @@ -3273,6 +3298,7 @@ impl From for PaymentAttemptUpdateInternal { order_tax_amount: None, connector_transaction_data: None, connector_mandate_detail: None, + charges: None, }, PaymentAttemptUpdate::ManualUpdate { status, @@ -3341,6 +3367,7 @@ impl From for PaymentAttemptUpdateInternal { shipping_cost: None, order_tax_amount: None, connector_mandate_detail: None, + charges: None, } } PaymentAttemptUpdate::PostSessionTokensUpdate { @@ -3398,6 +3425,7 @@ impl From for PaymentAttemptUpdateInternal { order_tax_amount: None, connector_transaction_data: None, connector_mandate_detail: None, + charges: None, }, } } diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs index dfe3d5acc239..a2988d55ef9a 100644 --- a/crates/diesel_models/src/schema.rs +++ b/crates/diesel_models/src/schema.rs @@ -905,6 +905,7 @@ diesel::table! { #[max_length = 512] connector_transaction_data -> Nullable, connector_mandate_detail -> Nullable, + charges -> Nullable, } } diff --git a/crates/hyperswitch_connectors/src/connectors/airwallex/transformers.rs b/crates/hyperswitch_connectors/src/connectors/airwallex/transformers.rs index 45a7b577a86b..25c1953fd4ce 100644 --- a/crates/hyperswitch_connectors/src/connectors/airwallex/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/airwallex/transformers.rs @@ -664,7 +664,7 @@ impl TryFrom TryFrom TryFrom TryFrom network_txn_id: None, connector_response_reference_id: Some(item.response.order_number.to_string()), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -593,7 +593,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.order_number.to_string()), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -628,7 +628,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.order_number.to_string()), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -663,7 +663,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.order_number.to_string()), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) diff --git a/crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers.rs b/crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers.rs index f4399d105c5d..5996ba05834e 100644 --- a/crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers.rs @@ -313,7 +313,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(connector_transaction_id), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -485,7 +485,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -631,7 +631,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(connector_transaction_id), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -910,7 +910,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(connector_transaction_id), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) diff --git a/crates/hyperswitch_connectors/src/connectors/billwerk/transformers.rs b/crates/hyperswitch_connectors/src/connectors/billwerk/transformers.rs index 05b9abae0515..9fe00bac046c 100644 --- a/crates/hyperswitch_connectors/src/connectors/billwerk/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/billwerk/transformers.rs @@ -291,7 +291,7 @@ impl TryFrom TryFrom TryFrom, } @@ -291,7 +291,7 @@ pub struct ChargeResponseData { #[serde(rename_all = "kebab-case")] pub struct SingleChargeResponseData { charge_status: String, - charge_id: String, + charges: String, } impl TryFrom> @@ -316,7 +316,7 @@ impl TryFrom> network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -344,7 +344,7 @@ fn get_authorize_response( }), }?; - Ok((status, response.charge_id, redirection_data)) + Ok((status, response.charges, redirection_data)) } fn get_psync_response( @@ -352,7 +352,7 @@ fn get_psync_response( ) -> Result<(enums::AttemptStatus, String, Option), errors::ConnectorError> { let status = get_response_status(response.charges.charge.charge_status); - Ok((status, response.charges.charge.charge_id, None)) + Ok((status, response.charges.charge.charges, None)) } // REFUND : @@ -363,7 +363,7 @@ pub struct BokuRefundRequest { merchant_id: Secret, merchant_request_id: String, merchant_refund_id: Secret, - charge_id: String, + charges: String, reason_code: String, } @@ -389,7 +389,7 @@ impl TryFrom<&BokuRouterData<&RefundsRouterData>> for BokuRefundRequest { merchant_id: auth_type.merchant_id, merchant_refund_id: Secret::new(item.router_data.request.refund_id.to_string()), merchant_request_id: Uuid::new_v4().to_string(), - charge_id: item + charges: item .router_data .request .connector_transaction_id @@ -404,7 +404,7 @@ impl TryFrom<&BokuRouterData<&RefundsRouterData>> for BokuRefundRequest { #[derive(Debug, Clone, Deserialize, Serialize)] #[serde(rename = "refund-charge-response")] pub struct RefundResponse { - charge_id: String, + charges: String, refund_status: String, } @@ -423,7 +423,7 @@ impl TryFrom> for RefundsRout ) -> Result { Ok(Self { response: Ok(RefundsResponseData { - connector_refund_id: item.response.charge_id, + connector_refund_id: item.response.charges, refund_status: get_refund_status(item.response.refund_status), }), ..item.data diff --git a/crates/hyperswitch_connectors/src/connectors/cashtocode/transformers.rs b/crates/hyperswitch_connectors/src/connectors/cashtocode/transformers.rs index 7a70d97a102c..c139bc1524db 100644 --- a/crates/hyperswitch_connectors/src/connectors/cashtocode/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/cashtocode/transformers.rs @@ -274,7 +274,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ) } @@ -307,7 +307,7 @@ impl TryFrom TryFrom .custom_id .or(Some(item.response.data.id)), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) }; match amount_captured_in_minor_units { diff --git a/crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs b/crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs index 2ec76cb2937e..d999619d8c32 100644 --- a/crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs @@ -289,7 +289,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) } }; @@ -407,7 +407,7 @@ impl TryFrom> network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs index 8133be2fa794..571944fd8520 100644 --- a/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs @@ -594,7 +594,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }), @@ -645,7 +645,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -895,7 +895,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -984,7 +984,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) diff --git a/crates/hyperswitch_connectors/src/connectors/digitalvirgo/transformers.rs b/crates/hyperswitch_connectors/src/connectors/digitalvirgo/transformers.rs index a9408e4e1c52..f67271136f12 100644 --- a/crates/hyperswitch_connectors/src/connectors/digitalvirgo/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/digitalvirgo/transformers.rs @@ -167,7 +167,7 @@ impl TryFrom TryFrom TryFrom TryFrom TryFrom TryFrom network_txn_id: None, connector_response_reference_id: Some(response.ssl_txn_id.clone()), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) } } @@ -391,7 +391,7 @@ impl TryFrom> for PaymentsSyn network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -450,7 +450,7 @@ impl TryFrom> network_txn_id: None, connector_response_reference_id: Some(response.ssl_txn_id.clone()), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) } } diff --git a/crates/hyperswitch_connectors/src/connectors/fiserv/transformers.rs b/crates/hyperswitch_connectors/src/connectors/fiserv/transformers.rs index f4084525410e..d6e2cd54db7f 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiserv/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiserv/transformers.rs @@ -385,7 +385,7 @@ impl TryFrom TryFrom TryFrom network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }), @@ -846,7 +846,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -902,7 +902,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) }; Ok(Self { @@ -948,7 +948,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) }; Self { @@ -967,7 +967,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }); Self { response, @@ -1244,7 +1244,7 @@ impl TryFrom> for PaymentsSy .map(|id| id.clone().expose()), connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }; Ok(Self { status, @@ -1306,7 +1306,7 @@ impl TryFrom> for PaymentsSy network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }; Ok(Self { status, @@ -1477,7 +1477,7 @@ impl TryFrom> network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }; Ok(Self { status, @@ -1590,7 +1590,7 @@ impl TryFrom> network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }; Ok(Self { status, diff --git a/crates/hyperswitch_connectors/src/connectors/forte/transformers.rs b/crates/hyperswitch_connectors/src/connectors/forte/transformers.rs index 2583f47058bf..31265162ca09 100644 --- a/crates/hyperswitch_connectors/src/connectors/forte/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/forte/transformers.rs @@ -308,7 +308,7 @@ impl TryFrom TryFrom> network_txn_id: None, connector_response_reference_id: Some(item.response.transaction_id.to_string()), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), amount_captured: None, ..item.data @@ -488,7 +488,7 @@ impl TryFrom TryFrom TryFrom redirection_data: Box::new(None), mandate_reference: Box::new(mandate_reference), network_txn_id: None, - charge_id: None, + charges: None, }), status: enums::AttemptStatus::Charged, ..item.data @@ -685,7 +685,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -716,7 +716,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) diff --git a/crates/hyperswitch_connectors/src/connectors/helcim/transformers.rs b/crates/hyperswitch_connectors/src/connectors/helcim/transformers.rs index 4a8ddf68df9a..0a5453a49d04 100644 --- a/crates/hyperswitch_connectors/src/connectors/helcim/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/helcim/transformers.rs @@ -387,7 +387,7 @@ impl network_txn_id: None, connector_response_reference_id: item.response.invoice_number.clone(), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), status: enums::AttemptStatus::from(item.response), ..item.data @@ -438,7 +438,7 @@ impl network_txn_id: None, connector_response_reference_id: item.response.invoice_number.clone(), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), status: enums::AttemptStatus::from(item.response), ..item.data @@ -487,7 +487,7 @@ impl network_txn_id: None, connector_response_reference_id: item.response.invoice_number.clone(), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), status: enums::AttemptStatus::from(item.response), ..item.data @@ -567,7 +567,7 @@ impl network_txn_id: None, connector_response_reference_id: item.response.invoice_number.clone(), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), status: enums::AttemptStatus::from(item.response), ..item.data @@ -624,7 +624,7 @@ impl network_txn_id: None, connector_response_reference_id: item.response.invoice_number.clone(), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), status: enums::AttemptStatus::from(item.response), ..item.data diff --git a/crates/hyperswitch_connectors/src/connectors/inespay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/inespay/transformers.rs index 296d76546c84..8940e2363630 100644 --- a/crates/hyperswitch_connectors/src/connectors/inespay/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/inespay/transformers.rs @@ -135,7 +135,7 @@ impl TryFrom TryFrom TryFrom network_txn_id: None, connector_response_reference_id: Some(item.response.transaction_id.clone()), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -711,7 +711,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.transaction_id.clone()), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) diff --git a/crates/hyperswitch_connectors/src/connectors/mollie/transformers.rs b/crates/hyperswitch_connectors/src/connectors/mollie/transformers.rs index 5a641327c96e..a82f91b18f4d 100644 --- a/crates/hyperswitch_connectors/src/connectors/mollie/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/mollie/transformers.rs @@ -513,7 +513,7 @@ impl TryFrom TryFrom TryFrom TryFrom network_txn_id: None, connector_response_reference_id: Some(item.response.operation.order_id), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -829,7 +829,7 @@ impl response_body.operation.order_id.clone(), ), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -848,7 +848,7 @@ impl mandate_response.operation.order_id.clone(), ), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }), @@ -971,7 +971,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.operation.order_id), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -1143,7 +1143,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.order_id.clone()), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -1201,7 +1201,7 @@ impl item.data.request.connector_transaction_id.clone(), ), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -1264,7 +1264,7 @@ impl item.data.request.connector_transaction_id.clone(), ), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) diff --git a/crates/hyperswitch_connectors/src/connectors/nomupay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/nomupay/transformers.rs index bea8b607daea..93b38001576a 100644 --- a/crates/hyperswitch_connectors/src/connectors/nomupay/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/nomupay/transformers.rs @@ -135,7 +135,7 @@ impl TryFrom TryFrom network_txn_id: None, connector_response_reference_id: transaction_id.clone(), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -1157,7 +1157,7 @@ impl network_txn_id: None, connector_response_reference_id: transaction_id.clone(), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -1326,7 +1326,7 @@ impl network_txn_id: None, connector_response_reference_id: transaction_id.clone(), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) diff --git a/crates/hyperswitch_connectors/src/connectors/paybox/transformers.rs b/crates/hyperswitch_connectors/src/connectors/paybox/transformers.rs index effe6df28db2..2515f5e8109e 100644 --- a/crates/hyperswitch_connectors/src/connectors/paybox/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/paybox/transformers.rs @@ -699,7 +699,7 @@ impl TryFrom TryFrom TryFrom TryFrom network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }), diff --git a/crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs b/crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs index 49188803c4f6..8437b660a83c 100644 --- a/crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs @@ -447,7 +447,7 @@ impl TryFrom TryFrom TryFrom TryFrom TryFrom TryFrom TryFrom network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -411,7 +411,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -459,7 +459,7 @@ impl TryFrom TryFrom TryFrom TryFrom TryFrom TryFrom> network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -806,7 +806,7 @@ impl TryFrom TryFrom TryFrom<&Shift4RouterData<&RefundsRouterData>> for Shift4RefundReques type Error = Error; fn try_from(item: &Shift4RouterData<&RefundsRouterData>) -> Result { Ok(Self { - charge_id: item.router_data.request.connector_transaction_id.clone(), + charges: item.router_data.request.connector_transaction_id.clone(), amount: item.amount.to_owned(), }) } diff --git a/crates/hyperswitch_connectors/src/connectors/square/transformers.rs b/crates/hyperswitch_connectors/src/connectors/square/transformers.rs index 5abc93b3f882..af91cefa37b8 100644 --- a/crates/hyperswitch_connectors/src/connectors/square/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/square/transformers.rs @@ -394,7 +394,7 @@ impl TryFrom TryFrom TryFrom PaymentsResponseDa network_txn_id: None, connector_response_reference_id: Some(connector_response.transaction_id), incremental_authorization_allowed: None, - charge_id: None, + charges: None, } } @@ -275,7 +275,7 @@ fn get_payments_sync_response( .clone(), ), incremental_authorization_allowed: None, - charge_id: None, + charges: None, } } diff --git a/crates/hyperswitch_connectors/src/connectors/volt/transformers.rs b/crates/hyperswitch_connectors/src/connectors/volt/transformers.rs index a0d349eaa984..868161952762 100644 --- a/crates/hyperswitch_connectors/src/connectors/volt/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/volt/transformers.rs @@ -289,7 +289,7 @@ impl TryFrom TryFrom TryFrom TryFrom> network_txn_id: None, connector_response_reference_id: Some(item.response.id), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -634,7 +634,7 @@ impl TryFrom for Wo network_txn_id: None, connector_response_reference_id: optional_correlation_id, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..data.clone() }) @@ -531,7 +531,7 @@ impl ConnectorIntegration for Wor network_txn_id: None, connector_response_reference_id: optional_correlation_id, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..data.clone() }) @@ -632,7 +632,7 @@ impl ConnectorIntegration fo network_txn_id: None, connector_response_reference_id: optional_correlation_id, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..data.clone() }) diff --git a/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs index cd028e81ef1b..dc6af4ce4395 100644 --- a/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs @@ -763,7 +763,7 @@ impl network_txn_id: network_txn_id.map(|id| id.expose()), connector_response_reference_id: optional_correlation_id.clone(), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), (Some(reason), _) => Err(ErrorResponse { code: worldpay_status.to_string(), diff --git a/crates/hyperswitch_connectors/src/connectors/zen/transformers.rs b/crates/hyperswitch_connectors/src/connectors/zen/transformers.rs index cc6795f157a6..d44636d36378 100644 --- a/crates/hyperswitch_connectors/src/connectors/zen/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/zen/transformers.rs @@ -950,7 +950,7 @@ fn get_zen_response( network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }; Ok((status, error, payment_response_data)) } @@ -994,7 +994,7 @@ impl TryFrom TryFrom TryFrom, + pub charges: Option, } #[cfg(feature = "v1")] @@ -950,6 +951,7 @@ pub enum PaymentAttemptUpdate { payment_method_data: Option, charge_id: Option, connector_mandate_detail: Option, + charges: Option, }, UnresolvedResponseUpdate { status: storage_enums::AttemptStatus, @@ -1220,6 +1222,7 @@ impl PaymentAttemptUpdate { payment_method_data, charge_id, connector_mandate_detail, + charges, } => DieselPaymentAttemptUpdate::ResponseUpdate { status, connector, @@ -1242,6 +1245,7 @@ impl PaymentAttemptUpdate { payment_method_data, charge_id, connector_mandate_detail, + charges, }, Self::UnresolvedResponseUpdate { status, @@ -1551,6 +1555,7 @@ impl behaviour::Conversion for PaymentAttempt { order_tax_amount: self.net_amount.get_order_tax_amount(), shipping_cost: self.net_amount.get_shipping_cost(), connector_mandate_detail: self.connector_mandate_detail, + charges: self.charges, }) } @@ -1632,6 +1637,7 @@ impl behaviour::Conversion for PaymentAttempt { profile_id: storage_model.profile_id, organization_id: storage_model.organization_id, connector_mandate_detail: storage_model.connector_mandate_detail, + charges: storage_model.charges, }) } .await diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs index 2f8594662eb6..a5cf62977bdb 100644 --- a/crates/hyperswitch_domain_models/src/router_request_types.rs +++ b/crates/hyperswitch_domain_models/src/router_request_types.rs @@ -645,6 +645,7 @@ pub struct RefundIntegrityObject { #[derive(Debug, serde::Deserialize, Clone)] pub enum SplitRefundsRequest { StripeSplitRefund(StripeSplitRefund), + AdyenSplitRefund(common_types::domain::AdyenSplitData), } #[derive(Debug, serde::Deserialize, Clone)] diff --git a/crates/hyperswitch_domain_models/src/router_response_types.rs b/crates/hyperswitch_domain_models/src/router_response_types.rs index 613797e2988c..e378e01c9487 100644 --- a/crates/hyperswitch_domain_models/src/router_response_types.rs +++ b/crates/hyperswitch_domain_models/src/router_response_types.rs @@ -2,7 +2,7 @@ pub mod disputes; pub mod fraud_check; use std::collections::HashMap; -use common_utils::{request::Method, types as common_types, types::MinorUnit}; +use common_utils::{request::Method, types::MinorUnit}; pub use disputes::{AcceptDisputeResponse, DefendDisputeResponse, SubmitEvidenceResponse}; use crate::{ @@ -26,7 +26,7 @@ pub enum PaymentsResponseData { network_txn_id: Option, connector_response_reference_id: Option, incremental_authorization_allowed: Option, - charge_id: Option, + charges: Option, }, MultipleCaptureResponse { // pending_capture_id_list: Vec, @@ -163,7 +163,7 @@ impl PaymentsResponseData { network_txn_id: auth_network_txn_id, connector_response_reference_id: auth_connector_response_reference_id, incremental_authorization_allowed: auth_incremental_auth_allowed, - charge_id: auth_charge_id, + charges: auth_charges, }, Self::TransactionResponse { resource_id: capture_resource_id, @@ -173,7 +173,7 @@ impl PaymentsResponseData { network_txn_id: capture_network_txn_id, connector_response_reference_id: capture_connector_response_reference_id, incremental_authorization_allowed: capture_incremental_auth_allowed, - charge_id: capture_charge_id, + charges: capture_charges, }, ) => Ok(Self::TransactionResponse { resource_id: capture_resource_id.clone(), @@ -198,7 +198,7 @@ impl PaymentsResponseData { .or(auth_connector_response_reference_id.clone()), incremental_authorization_allowed: (*capture_incremental_auth_allowed) .or(*auth_incremental_auth_allowed), - charge_id: capture_charge_id.clone().or(auth_charge_id.clone()), + charges: auth_charges.clone().or(capture_charges.clone()), }), _ => Err(ApiErrorResponse::NotSupported { message: "Invalid Flow ".to_owned(), @@ -484,7 +484,7 @@ pub struct MandateRevokeResponseData { #[derive(Debug, Clone)] pub enum AuthenticationResponseData { PreAuthVersionCallResponse { - maximum_supported_3ds_version: common_types::SemanticVersion, + maximum_supported_3ds_version: common_utils::types::SemanticVersion, }, PreAuthThreeDsMethodCallResponse { threeds_server_transaction_id: String, diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs index 32c2402e1081..bcff0131a4ab 100644 --- a/crates/openapi/src/openapi.rs +++ b/crates/openapi/src/openapi.rs @@ -216,11 +216,14 @@ Never share your secret api keys. Keep them guarded and secure. common_utils::payout_method_utils::VenmoAdditionalData, common_types::payments::SplitPaymentsRequest, common_types::payments::StripeSplitPaymentRequest, + common_types::payments::AdyenSplitData, + common_types::payments::AdyenSplitItem, common_utils::types::ChargeRefunds, common_types::refunds::SplitRefund, common_types::refunds::StripeSplitRefundRequest, - api_models::payments::SplitPaymentsResponse, - api_models::payments::StripeSplitPaymentsResponse, + api_models::payments::ConnectorChargeResponseData, + api_models::payments::StripeChargeResponseData, + api_models::payments::AdyenChargeResponseData, api_models::refunds::RefundRequest, api_models::refunds::RefundType, api_models::refunds::RefundResponse, diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs index 5b4c89c3f4a6..578afaec4428 100644 --- a/crates/openapi/src/openapi_v2.rs +++ b/crates/openapi/src/openapi_v2.rs @@ -158,12 +158,15 @@ Never share your secret api keys. Keep them guarded and secure. common_utils::payout_method_utils::VenmoAdditionalData, common_types::payments::SplitPaymentsRequest, common_types::payments::StripeSplitPaymentRequest, + common_types::payments::AdyenSplitData, + common_types::payments::AdyenSplitItem, common_types::refunds::StripeSplitRefundRequest, common_utils::types::ChargeRefunds, common_types::payment_methods::PaymentMethodsEnabled, common_types::refunds::SplitRefund, - api_models::payments::SplitPaymentsResponse, - api_models::payments::StripeSplitPaymentsResponse, + api_models::payments::ConnectorChargeResponseData, + api_models::payments::StripeChargeResponseData, + api_models::payments::AdyenChargeResponseData, api_models::refunds::RefundRequest, api_models::refunds::RefundsCreateRequest, api_models::refunds::RefundErrorDetails, diff --git a/crates/router/src/connector/aci/transformers.rs b/crates/router/src/connector/aci/transformers.rs index 3e25799c02e6..0641fc2895cc 100644 --- a/crates/router/src/connector/aci/transformers.rs +++ b/crates/router/src/connector/aci/transformers.rs @@ -771,7 +771,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.id), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs index 394652c33e11..99b278fa85a5 100644 --- a/crates/router/src/connector/adyen/transformers.rs +++ b/crates/router/src/connector/adyen/transformers.rs @@ -171,6 +171,19 @@ pub struct AdyenPaymentRequest<'a> { channel: Option, metadata: Option, merchant_order_reference: Option, + splits: Option>, + store: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +struct AdyenSplitData { + amount: Option, + #[serde(rename = "type")] + split_type: common_enums::AdyenSplitType, + account: Option, + reference: Option, + description: Option, } #[serde_with::skip_serializing_none] @@ -365,6 +378,8 @@ pub struct Response { refusal_reason: Option, refusal_reason_code: Option, additional_data: Option, + splits: Option>, + store: Option, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -411,6 +426,8 @@ pub struct RedirectionResponse { refusal_reason_code: Option, psp_reference: Option, merchant_reference: Option, + store: Option, + splits: Option>, } #[derive(Debug, Clone, Deserialize, Serialize)] @@ -422,6 +439,8 @@ pub struct PresentToShopperResponse { refusal_reason: Option, refusal_reason_code: Option, merchant_reference: Option, + store: Option, + splits: Option>, } #[derive(Debug, Clone, Deserialize, Serialize)] @@ -434,6 +453,8 @@ pub struct QrCodeResponseResponse { additional_data: Option, psp_reference: Option, merchant_reference: Option, + store: Option, + splits: Option>, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -1240,13 +1261,15 @@ pub struct DokuBankData { } // Refunds Request and Response #[serde_with::skip_serializing_none] -#[derive(Default, Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct AdyenRefundRequest { merchant_account: Secret, amount: Amount, merchant_refund_reason: Option, reference: String, + splits: Option>, + store: Option, } #[derive(Default, Debug, Clone, Serialize, Deserialize)] @@ -2754,6 +2777,14 @@ impl } } // }?; + + let (store, splits) = match item.router_data.request.split_payments.as_ref() { + Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment( + adyen_split_payment, + )) => get_adyen_split_request(&adyen_split_payment, item.router_data.request.currency), + _ => (None, None), + }; + Ok(AdyenPaymentRequest { amount, merchant_account: auth_type.merchant_account, @@ -2781,6 +2812,8 @@ impl shopper_ip: item.router_data.request.get_ip_address_as_optional(), metadata: item.router_data.request.metadata.clone().map(Into::into), merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(), + store, + splits, }) } } @@ -2817,6 +2850,12 @@ impl let payment_method = AdyenPaymentMethod::try_from((card_data, card_holder_name))?; let shopper_email = item.router_data.get_optional_billing_email(); let shopper_name = get_shopper_name(item.router_data.get_optional_billing()); + let (store, splits) = match item.router_data.request.split_payments.as_ref() { + Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment( + adyen_split_payment, + )) => get_adyen_split_request(&adyen_split_payment, item.router_data.request.currency), + _ => (None, None), + }; Ok(AdyenPaymentRequest { amount, @@ -2845,6 +2884,8 @@ impl shopper_ip: item.router_data.request.get_ip_address_as_optional(), metadata: item.router_data.request.metadata.clone().map(Into::into), merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(), + store, + splits, }) } } @@ -2874,6 +2915,12 @@ impl let return_url = item.router_data.request.get_router_return_url()?; let payment_method = AdyenPaymentMethod::try_from((bank_debit_data, item.router_data))?; let country_code = get_country_code(item.router_data.get_optional_billing()); + let (store, splits) = match item.router_data.request.split_payments.as_ref() { + Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment( + adyen_split_payment, + )) => get_adyen_split_request(&adyen_split_payment, item.router_data.request.currency), + _ => (None, None), + }; let request = AdyenPaymentRequest { amount, merchant_account: auth_type.merchant_account, @@ -2901,6 +2948,8 @@ impl shopper_ip: item.router_data.request.get_ip_address_as_optional(), metadata: item.router_data.request.metadata.clone().map(Into::into), merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(), + store, + splits, }; Ok(request) } @@ -2933,6 +2982,12 @@ impl let billing_address = get_address_info(item.router_data.get_optional_billing()).and_then(Result::ok); let shopper_name = get_shopper_name(item.router_data.get_optional_billing()); + let (store, splits) = match item.router_data.request.split_payments.as_ref() { + Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment( + adyen_split_payment, + )) => get_adyen_split_request(&adyen_split_payment, item.router_data.request.currency), + _ => (None, None), + }; let request = AdyenPaymentRequest { amount, @@ -2961,6 +3016,8 @@ impl shopper_ip: item.router_data.request.get_ip_address_as_optional(), metadata: item.router_data.request.metadata.clone().map(Into::into), merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(), + store, + splits, }; Ok(request) } @@ -2986,6 +3043,12 @@ impl let shopper_interaction = AdyenShopperInteraction::from(item.router_data); let payment_method = AdyenPaymentMethod::try_from((bank_transfer_data, item.router_data))?; let return_url = item.router_data.request.get_router_return_url()?; + let (store, splits) = match item.router_data.request.split_payments.as_ref() { + Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment( + adyen_split_payment, + )) => get_adyen_split_request(&adyen_split_payment, item.router_data.request.currency), + _ => (None, None), + }; let request = AdyenPaymentRequest { amount, merchant_account: auth_type.merchant_account, @@ -3013,6 +3076,8 @@ impl shopper_ip: item.router_data.request.get_ip_address_as_optional(), metadata: item.router_data.request.metadata.clone().map(Into::into), merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(), + store, + splits, }; Ok(request) } @@ -3038,6 +3103,13 @@ impl let shopper_interaction = AdyenShopperInteraction::from(item.router_data); let return_url = item.router_data.request.get_router_return_url()?; let payment_method = AdyenPaymentMethod::try_from(gift_card_data)?; + let (store, splits) = match item.router_data.request.split_payments.as_ref() { + Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment( + adyen_split_payment, + )) => get_adyen_split_request(&adyen_split_payment, item.router_data.request.currency), + _ => (None, None), + }; + let request = AdyenPaymentRequest { amount, merchant_account: auth_type.merchant_account, @@ -3065,6 +3137,8 @@ impl shopper_ip: item.router_data.request.get_ip_address_as_optional(), metadata: item.router_data.request.metadata.clone().map(Into::into), merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(), + store, + splits, }; Ok(request) } @@ -3101,6 +3175,12 @@ impl let line_items = Some(get_line_items(item)); let billing_address = get_address_info(item.router_data.get_optional_billing()).and_then(Result::ok); + let (store, splits) = match item.router_data.request.split_payments.as_ref() { + Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment( + adyen_split_payment, + )) => get_adyen_split_request(&adyen_split_payment, item.router_data.request.currency), + _ => (None, None), + }; Ok(AdyenPaymentRequest { amount, @@ -3129,6 +3209,8 @@ impl shopper_ip: item.router_data.request.get_ip_address_as_optional(), metadata: item.router_data.request.metadata.clone().map(Into::into), merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(), + store, + splits, }) } } @@ -3219,6 +3301,12 @@ impl } else { None }; + let (store, splits) = match item.router_data.request.split_payments.as_ref() { + Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment( + adyen_split_payment, + )) => get_adyen_split_request(&adyen_split_payment, item.router_data.request.currency), + _ => (None, None), + }; Ok(AdyenPaymentRequest { amount, merchant_account: auth_type.merchant_account, @@ -3246,6 +3334,8 @@ impl shopper_ip: item.router_data.request.get_ip_address_as_optional(), metadata: item.router_data.request.metadata.clone().map(Into::into), merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(), + store, + splits, }) } } @@ -3295,6 +3385,13 @@ impl &billing_address, &delivery_address, ))?; + let (store, splits) = match item.router_data.request.split_payments.as_ref() { + Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment( + adyen_split_payment, + )) => get_adyen_split_request(&adyen_split_payment, item.router_data.request.currency), + _ => (None, None), + }; + Ok(AdyenPaymentRequest { amount, merchant_account: auth_type.merchant_account, @@ -3322,6 +3419,8 @@ impl shopper_ip: item.router_data.request.get_ip_address_as_optional(), metadata: item.router_data.request.metadata.clone().map(Into::into), merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(), + store, + splits, }) } } @@ -3355,6 +3454,13 @@ impl })? .number .to_owned(); + let (store, splits) = match item.router_data.request.split_payments.as_ref() { + Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment( + adyen_split_payment, + )) => get_adyen_split_request(&adyen_split_payment, item.router_data.request.currency), + _ => (None, None), + }; + Ok(AdyenPaymentRequest { amount, merchant_account: auth_type.merchant_account, @@ -3382,6 +3488,8 @@ impl shopper_ip: item.router_data.request.get_ip_address_as_optional(), metadata: item.router_data.request.metadata.clone().map(Into::into), merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(), + store, + splits, }) } } @@ -3397,6 +3505,27 @@ impl TryFrom<&types::PaymentsCancelRouterData> for AdyenCancelRequest { } } +fn get_adyen_split_request( + split_request: &common_types::domain::AdyenSplitData, + currency: common_enums::enums::Currency, +) -> (Option, Option>) { + let splits = split_request + .split_items + .iter() + .map(|split_item| { + let amount = split_item.amount.map(|value| Amount { currency, value }); + AdyenSplitData { + amount, + reference: split_item.reference.clone(), + split_type: split_item.split_type.clone(), + account: split_item.account.clone(), + description: split_item.description.clone(), + } + }) + .collect(); + (split_request.store.clone(), Some(splits)) +} + impl TryFrom> for types::PaymentsCancelRouterData { @@ -3416,7 +3545,7 @@ impl TryFrom> network_txn_id: None, connector_response_reference_id: Some(item.response.reference), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -3451,7 +3580,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), payment_method_balance: Some(types::PaymentMethodBalance { currency: item.response.balance.currency, @@ -3513,6 +3642,11 @@ pub fn get_adyen_response( .map(|network_tx_id| network_tx_id.expose()) }); + let charges = match &response.splits { + Some(split_items) => Some(construct_charge_response(response.store, split_items)), + None => None, + }; + let payments_response_data = types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(response.psp_reference), redirection_data: Box::new(None), @@ -3521,7 +3655,7 @@ pub fn get_adyen_response( network_txn_id, connector_response_reference_id: Some(response.merchant_reference), incremental_authorization_allowed: None, - charge_id: None, + charges, }; Ok((status, error, payments_response_data)) } @@ -3588,7 +3722,7 @@ pub fn get_webhook_response( network_txn_id: None, connector_response_reference_id: Some(response.merchant_reference_id), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }; Ok((status, error, payments_response_data)) } @@ -3650,6 +3784,11 @@ pub fn get_redirection_response( let connector_metadata = get_wait_screen_metadata(&response)?; + let charges = match &response.splits { + Some(split_items) => Some(construct_charge_response(response.store, split_items)), + None => None, + }; + let payments_response_data = types::PaymentsResponseData::TransactionResponse { resource_id: match response.psp_reference.as_ref() { Some(psp) => types::ResponseId::ConnectorTransactionId(psp.to_string()), @@ -3664,7 +3803,7 @@ pub fn get_redirection_response( .clone() .or(response.psp_reference), incremental_authorization_allowed: None, - charge_id: None, + charges, }; Ok((status, error, payments_response_data)) } @@ -3709,6 +3848,14 @@ pub fn get_present_to_shopper_response( None }; + let charges = match &response.splits { + Some(split_items) => Some(construct_charge_response( + response.store.clone(), + split_items, + )), + None => None, + }; + let connector_metadata = get_present_to_shopper_metadata(&response)?; // We don't get connector transaction id for redirections in Adyen. let payments_response_data = types::PaymentsResponseData::TransactionResponse { @@ -3725,7 +3872,7 @@ pub fn get_present_to_shopper_response( .clone() .or(response.psp_reference), incremental_authorization_allowed: None, - charge_id: None, + charges, }; Ok((status, error, payments_response_data)) } @@ -3770,6 +3917,14 @@ pub fn get_qr_code_response( None }; + let charges = match &response.splits { + Some(split_items) => Some(construct_charge_response( + response.store.clone(), + split_items, + )), + None => None, + }; + let connector_metadata = get_qr_metadata(&response)?; let payments_response_data = types::PaymentsResponseData::TransactionResponse { resource_id: match response.psp_reference.as_ref() { @@ -3785,7 +3940,7 @@ pub fn get_qr_code_response( .clone() .or(response.psp_reference), incremental_authorization_allowed: None, - charge_id: None, + charges, }; Ok((status, error, payments_response_data)) } @@ -3828,7 +3983,7 @@ pub fn get_redirection_error_response( .clone() .or(response.psp_reference), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }; Ok((status, error, payments_response_data)) @@ -4168,6 +4323,8 @@ pub struct AdyenCaptureResponse { status: String, amount: Amount, merchant_reference: Option, + store: Option, + splits: Option>, } impl TryFrom> @@ -4182,6 +4339,11 @@ impl TryFrom> } else { item.response.payment_psp_reference }; + let charges = match &item.response.splits { + Some(split_items) => Some(construct_charge_response(item.response.store, split_items)), + None => None, + }; + Ok(Self { // From the docs, the only value returned is "received", outcome of refund is available // through refund notification webhook @@ -4195,7 +4357,7 @@ impl TryFrom> network_txn_id: None, connector_response_reference_id: Some(item.response.reference), incremental_authorization_allowed: None, - charge_id: None, + charges, }), amount_captured: Some(0), ..item.data @@ -4203,6 +4365,32 @@ impl TryFrom> } } +fn construct_charge_response( + store: Option, + split_item: &Vec, +) -> common_types::payments::ConnectorChargeResponseData { + let splits: Vec = split_item + .iter() + .map(|split_item| common_types::domain::AdyenSplitItem { + amount: split_item + .amount + .as_ref() + .map(|amount| amount.value.clone()), + reference: split_item.reference.clone(), + split_type: split_item.split_type.clone(), + account: split_item.account.clone(), + description: split_item.description.clone(), + }) + .collect(); + + common_types::payments::ConnectorChargeResponseData::AdyenSplitPayment( + common_types::domain::AdyenSplitData { + store, + split_items: splits, + }, + ) +} + /* // This is a repeated code block from Stripe inegration. Can we avoid the repetition in every integration #[derive(Debug, Serialize, Deserialize)] @@ -4241,6 +4429,16 @@ impl TryFrom<&AdyenRouterData<&types::RefundsRouterData>> for AdyenRefundR type Error = Error; fn try_from(item: &AdyenRouterData<&types::RefundsRouterData>) -> Result { let auth_type = AdyenAuthType::try_from(&item.router_data.connector_auth_type)?; + let (store, splits) = match item + .router_data + .request + .split_refunds + .as_ref() + { + Some(hyperswitch_domain_models::router_request_types::SplitRefundsRequest::AdyenSplitRefund(adyen_split_data)) => get_adyen_split_request(&adyen_split_data, item.router_data.request.currency), + _ => (None, None), + }; + Ok(Self { merchant_account: auth_type.merchant_account, amount: Amount { @@ -4249,6 +4447,8 @@ impl TryFrom<&AdyenRouterData<&types::RefundsRouterData>> for AdyenRefundR }, merchant_refund_reason: item.router_data.request.reason.clone(), reference: item.router_data.request.refund_id.clone(), + store, + splits, }) } } @@ -5458,6 +5658,12 @@ impl .unwrap_or_default(), eci: Some("02".to_string()), }; + let (store, splits) = match item.router_data.request.split_payments.as_ref() { + Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment( + adyen_split_payment, + )) => get_adyen_split_request(&adyen_split_payment, item.router_data.request.currency), + _ => (None, None), + }; Ok(AdyenPaymentRequest { amount, @@ -5486,6 +5692,8 @@ impl metadata: item.router_data.request.metadata.clone().map(Into::into), merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(), mpi_data: Some(mpi_data), + store, + splits, }) } } diff --git a/crates/router/src/connector/authorizedotnet/transformers.rs b/crates/router/src/connector/authorizedotnet/transformers.rs index d2b212e3ea0e..3d952e9ef16a 100644 --- a/crates/router/src/connector/authorizedotnet/transformers.rs +++ b/crates/router/src/connector/authorizedotnet/transformers.rs @@ -407,7 +407,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }), @@ -1144,7 +1144,7 @@ impl transaction_response.transaction_id.clone(), ), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), }, ..item.data @@ -1217,7 +1217,7 @@ impl transaction_response.transaction_id.clone(), ), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), }, ..item.data @@ -1542,7 +1542,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(transaction.transaction_id.clone()), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), status: payment_status, ..item.data diff --git a/crates/router/src/connector/bankofamerica/transformers.rs b/crates/router/src/connector/bankofamerica/transformers.rs index 48363481ad85..e83f863e37db 100644 --- a/crates/router/src/connector/bankofamerica/transformers.rs +++ b/crates/router/src/connector/bankofamerica/transformers.rs @@ -426,7 +426,7 @@ impl .unwrap_or(info_response.id), ), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), }, connector_response, @@ -1529,7 +1529,7 @@ fn get_payment_response( .unwrap_or(info_response.id.clone()), ), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) } } @@ -1842,7 +1842,7 @@ impl .map(|cref| cref.code) .unwrap_or(Some(item.response.id)), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), connector_response, ..item.data @@ -1861,7 +1861,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.id), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }), diff --git a/crates/router/src/connector/braintree/transformers.rs b/crates/router/src/connector/braintree/transformers.rs index 00624ce0f9b1..44fb39feb5a2 100644 --- a/crates/router/src/connector/braintree/transformers.rs +++ b/crates/router/src/connector/braintree/transformers.rs @@ -450,7 +450,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) }; Ok(Self { @@ -473,7 +473,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }), @@ -626,7 +626,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) }; Ok(Self { @@ -649,7 +649,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }), @@ -709,7 +709,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) }; Ok(Self { @@ -774,7 +774,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) }; Ok(Self { @@ -1282,7 +1282,7 @@ impl TryFrom> network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) }; Ok(Self { @@ -1392,7 +1392,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) }; Ok(Self { @@ -1497,7 +1497,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) }; Ok(Self { diff --git a/crates/router/src/connector/checkout/transformers.rs b/crates/router/src/connector/checkout/transformers.rs index cd758fffb690..da6897b9adf4 100644 --- a/crates/router/src/connector/checkout/transformers.rs +++ b/crates/router/src/connector/checkout/transformers.rs @@ -700,7 +700,7 @@ impl TryFrom> item.response.reference.unwrap_or(item.response.id), ), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }; Ok(Self { status, @@ -753,7 +753,7 @@ impl TryFrom> item.response.reference.unwrap_or(item.response.id), ), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }; Ok(Self { status, @@ -829,7 +829,7 @@ impl TryFrom> network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), status: response.into(), ..item.data @@ -930,7 +930,7 @@ impl TryFrom> network_txn_id: None, connector_response_reference_id: item.response.reference, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), status, amount_captured, diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rs index 2aa24e5ffdf4..c21cf1307d52 100644 --- a/crates/router/src/connector/cybersource/transformers.rs +++ b/crates/router/src/connector/cybersource/transformers.rs @@ -2567,7 +2567,7 @@ fn get_payment_response( .unwrap_or(info_response.id.clone()), ), incremental_authorization_allowed, - charge_id: None, + charges: None, }) } } @@ -2664,7 +2664,7 @@ impl .unwrap_or(info_response.id.clone()), ), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }), @@ -3072,7 +3072,7 @@ impl network_txn_id: None, connector_response_reference_id, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -3329,7 +3329,7 @@ impl incremental_authorization_allowed: Some( mandate_status == enums::AttemptStatus::Authorized, ), - charge_id: None, + charges: None, }), }, connector_response, @@ -3458,7 +3458,7 @@ impl .map(|cref| cref.code) .unwrap_or(Some(item.response.id)), incremental_authorization_allowed, - charge_id: None, + charges: None, }), ..item.data }) @@ -3476,7 +3476,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.id), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }), diff --git a/crates/router/src/connector/dummyconnector/transformers.rs b/crates/router/src/connector/dummyconnector/transformers.rs index 79caa3d0a767..9d745ca19786 100644 --- a/crates/router/src/connector/dummyconnector/transformers.rs +++ b/crates/router/src/connector/dummyconnector/transformers.rs @@ -259,7 +259,7 @@ impl TryFrom types::PaymentsResponseData::TransactionResponse { @@ -398,7 +398,7 @@ fn get_iatpay_response( network_txn_id: None, connector_response_reference_id: connector_response_reference_id.clone(), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }, }; diff --git a/crates/router/src/connector/itaubank/transformers.rs b/crates/router/src/connector/itaubank/transformers.rs index 127f8526afe4..9d38044f0fe9 100644 --- a/crates/router/src/connector/itaubank/transformers.rs +++ b/crates/router/src/connector/itaubank/transformers.rs @@ -287,7 +287,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.txid), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -375,7 +375,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.txid), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) diff --git a/crates/router/src/connector/klarna/transformers.rs b/crates/router/src/connector/klarna/transformers.rs index 3cefa4ec6c9b..28c135fda8f7 100644 --- a/crates/router/src/connector/klarna/transformers.rs +++ b/crates/router/src/connector/klarna/transformers.rs @@ -389,7 +389,7 @@ impl TryFrom> network_txn_id: None, connector_response_reference_id: Some(response.order_id.clone()), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), status: enums::AttemptStatus::foreign_from(( response.fraud_status.clone(), @@ -412,7 +412,7 @@ impl TryFrom> network_txn_id: None, connector_response_reference_id: Some(response.order_id.clone()), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), status: enums::AttemptStatus::foreign_from(( response.status.clone(), @@ -575,7 +575,7 @@ impl .klarna_reference .or(Some(response.order_id.clone())), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }), @@ -594,7 +594,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(response.order_id.clone()), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }), @@ -672,7 +672,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), status, ..item.data diff --git a/crates/router/src/connector/mifinity/transformers.rs b/crates/router/src/connector/mifinity/transformers.rs index 1e2c420c767b..e07354d18713 100644 --- a/crates/router/src/connector/mifinity/transformers.rs +++ b/crates/router/src/connector/mifinity/transformers.rs @@ -268,7 +268,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(trace_id), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -283,7 +283,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }), @@ -352,7 +352,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -367,7 +367,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }), @@ -383,7 +383,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }), diff --git a/crates/router/src/connector/nmi/transformers.rs b/crates/router/src/connector/nmi/transformers.rs index 4c33f0200172..87e067cbbf67 100644 --- a/crates/router/src/connector/nmi/transformers.rs +++ b/crates/router/src/connector/nmi/transformers.rs @@ -212,7 +212,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.transactionid), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), enums::AttemptStatus::AuthenticationPending, ), @@ -366,7 +366,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.orderid), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), if let Some(diesel_models::enums::CaptureMethod::Automatic) = item.data.request.capture_method @@ -750,7 +750,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.orderid), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), enums::AttemptStatus::CaptureInitiated, ), @@ -845,7 +845,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.orderid), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), enums::AttemptStatus::Charged, ), @@ -902,7 +902,7 @@ impl TryFrom> network_txn_id: None, connector_response_reference_id: Some(item.response.orderid), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), if let Some(diesel_models::enums::CaptureMethod::Automatic) = item.data.request.capture_method @@ -953,7 +953,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.orderid), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), enums::AttemptStatus::VoidInitiated, ), @@ -1004,7 +1004,7 @@ impl TryFrom network_txn_id: None, connector_response_reference_id, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) } }, diff --git a/crates/router/src/connector/nuvei/transformers.rs b/crates/router/src/connector/nuvei/transformers.rs index c98a06477787..ea3d0d87a944 100644 --- a/crates/router/src/connector/nuvei/transformers.rs +++ b/crates/router/src/connector/nuvei/transformers.rs @@ -1627,7 +1627,7 @@ where network_txn_id: None, connector_response_reference_id: response.order_id, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) }, ..item.data diff --git a/crates/router/src/connector/opayo/transformers.rs b/crates/router/src/connector/opayo/transformers.rs index f55aa4325b06..992acfb5ef08 100644 --- a/crates/router/src/connector/opayo/transformers.rs +++ b/crates/router/src/connector/opayo/transformers.rs @@ -151,7 +151,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.transaction_id), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) diff --git a/crates/router/src/connector/opennode/transformers.rs b/crates/router/src/connector/opennode/transformers.rs index 44315ac42fa8..067237bc3e28 100644 --- a/crates/router/src/connector/opennode/transformers.rs +++ b/crates/router/src/connector/opennode/transformers.rs @@ -144,7 +144,7 @@ impl network_txn_id: None, connector_response_reference_id: item.response.data.order_id, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) } else { Ok(types::PaymentsResponseData::TransactionUnresolvedResponse { diff --git a/crates/router/src/connector/payme/transformers.rs b/crates/router/src/connector/payme/transformers.rs index cd8ba814eb7e..2f5f3e438918 100644 --- a/crates/router/src/connector/payme/transformers.rs +++ b/crates/router/src/connector/payme/transformers.rs @@ -259,7 +259,7 @@ impl TryFrom<&PaymePaySaleResponse> for types::PaymentsResponseData { network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) } } @@ -326,7 +326,7 @@ impl From<&SaleQuery> for types::PaymentsResponseData { network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, } } } @@ -546,7 +546,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }), @@ -1124,7 +1124,7 @@ impl TryFrom> network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) }; Ok(Self { diff --git a/crates/router/src/connector/paypal.rs b/crates/router/src/connector/paypal.rs index fb635708c23e..c7aef2ddb231 100644 --- a/crates/router/src/connector/paypal.rs +++ b/crates/router/src/connector/paypal.rs @@ -1227,7 +1227,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..data.clone() }) @@ -1278,7 +1278,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..data.clone() }) diff --git a/crates/router/src/connector/paypal/transformers.rs b/crates/router/src/connector/paypal/transformers.rs index 8f739792a0c2..0b4d865720ad 100644 --- a/crates/router/src/connector/paypal/transformers.rs +++ b/crates/router/src/connector/paypal/transformers.rs @@ -622,7 +622,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(info_response.id.clone()), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -1858,7 +1858,7 @@ impl .clone() .or(Some(item.response.id)), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -1983,7 +1983,7 @@ impl purchase_units.map_or(item.response.id, |item| item.invoice_id.clone()), ), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -2038,7 +2038,7 @@ impl purchase_units.map_or(item.response.id, |item| item.invoice_id.clone()), ), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -2091,7 +2091,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -2129,7 +2129,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -2182,7 +2182,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -2251,7 +2251,7 @@ impl .clone() .or(Some(item.response.supplementary_data.related_ids.order_id)), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) @@ -2592,7 +2592,7 @@ impl TryFrom> .invoice_id .or(Some(item.response.id)), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), amount_captured: Some(amount_captured), ..item.data @@ -2644,7 +2644,7 @@ impl .invoice_id .or(Some(item.response.id)), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) diff --git a/crates/router/src/connector/plaid/transformers.rs b/crates/router/src/connector/plaid/transformers.rs index 29d4db1297f8..4e4fb1863ee7 100644 --- a/crates/router/src/connector/plaid/transformers.rs +++ b/crates/router/src/connector/plaid/transformers.rs @@ -314,7 +314,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.payment_id), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) }, ..item.data @@ -400,7 +400,7 @@ impl TryFrom { - transformers::transform_headers_for_connect_platform( - stripe_split_payment.charge_type.clone(), - stripe_split_payment.transfer_account_id.clone(), - &mut header, - ); - } - } + if let Some(common_types::payments::SplitPaymentsRequest::StripeSplitPayment( + stripe_split_payment, + )) = &req.request.split_payments + { + transformers::transform_headers_for_connect_platform( + stripe_split_payment.charge_type.clone(), + stripe_split_payment.transfer_account_id.clone(), + &mut header, + ); } Ok(header) } @@ -943,26 +940,21 @@ impl let mut api_key = self.get_auth_header(&req.connector_auth_type)?; header.append(&mut api_key); - if let Some(split_payments) = &req.request.split_payments { - match split_payments { - common_types::payments::SplitPaymentsRequest::StripeSplitPayment( - stripe_split_payment, - ) => { - if stripe_split_payment.charge_type - == api::enums::PaymentChargeType::Stripe( - api::enums::StripeChargeType::Direct, - ) - { - let mut customer_account_header = vec![( - headers::STRIPE_COMPATIBLE_CONNECT_ACCOUNT.to_string(), - stripe_split_payment - .transfer_account_id - .clone() - .into_masked(), - )]; - header.append(&mut customer_account_header); - } - } + if let Some(common_types::payments::SplitPaymentsRequest::StripeSplitPayment( + stripe_split_payment, + )) = &req.request.split_payments + { + if stripe_split_payment.charge_type + == api::enums::PaymentChargeType::Stripe(api::enums::StripeChargeType::Direct) + { + let mut customer_account_header = vec![( + headers::STRIPE_COMPATIBLE_CONNECT_ACCOUNT.to_string(), + stripe_split_payment + .transfer_account_id + .clone() + .into_masked(), + )]; + header.append(&mut customer_account_header); } } Ok(header) @@ -1484,22 +1476,20 @@ impl services::ConnectorIntegration { - match &stripe_split_refund.charge_type { - api::enums::PaymentChargeType::Stripe(stripe_charge) => { - if stripe_charge == &api::enums::StripeChargeType::Direct { - let mut customer_account_header = vec![( - headers::STRIPE_COMPATIBLE_CONNECT_ACCOUNT.to_string(), - stripe_split_refund - .transfer_account_id - .clone() - .into_masked(), - )]; - header.append(&mut customer_account_header); - } - } + if let Some(SplitRefundsRequest::StripeSplitRefund(ref stripe_split_refund)) = + req.request.split_refunds.as_ref() + { + match &stripe_split_refund.charge_type { + api::enums::PaymentChargeType::Stripe(stripe_charge) => { + if stripe_charge == &api::enums::StripeChargeType::Direct { + let mut customer_account_header = vec![( + headers::STRIPE_COMPATIBLE_CONNECT_ACCOUNT.to_string(), + stripe_split_refund + .transfer_account_id + .clone() + .into_masked(), + )]; + header.append(&mut customer_account_header); } } } @@ -1530,15 +1520,15 @@ impl services::ConnectorIntegration RequestContent::FormUrlEncoded(Box::new(stripe::RefundRequest::try_from(( - req, - refund_amount, - ))?)), - Some(split_refunds) => match split_refunds { - SplitRefundsRequest::StripeSplitRefund(_) => RequestContent::FormUrlEncoded( - Box::new(stripe::ChargeRefundRequest::try_from(req)?), - ), - }, + Some(SplitRefundsRequest::AdyenSplitRefund(_)) | None => { + RequestContent::FormUrlEncoded(Box::new(stripe::RefundRequest::try_from(( + req, + refund_amount, + ))?)) + } + Some(SplitRefundsRequest::StripeSplitRefund(_)) => RequestContent::FormUrlEncoded( + Box::new(stripe::ChargeRefundRequest::try_from(req)?), + ), }; Ok(request_body) } @@ -1653,16 +1643,14 @@ impl services::ConnectorIntegration { - transformers::transform_headers_for_connect_platform( - stripe_refund.charge_type.clone(), - stripe_refund.transfer_account_id.clone(), - &mut header, - ); - } - } + if let Some(SplitRefundsRequest::StripeSplitRefund(ref stripe_refund)) = + req.request.split_refunds.as_ref() + { + transformers::transform_headers_for_connect_platform( + stripe_refund.charge_type.clone(), + stripe_refund.transfer_account_id.clone(), + &mut header, + ); } Ok(header) } diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index 48736c00e7d8..c0c3225d52f3 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -1953,7 +1953,9 @@ impl TryFrom<(&types::PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntent }; (charges, None) } - None => (None, item.connector_customer.to_owned().map(Secret::new)), + Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment(_)) | None => { + (None, item.connector_customer.to_owned().map(Secret::new)) + } }; Ok(Self { @@ -2451,6 +2453,8 @@ fn extract_payment_method_connector_response_from_latest_attempt( impl TryFrom> for types::RouterData +where + T: connector_util::SplitPaymentData, { type Error = error_stack::Report; fn try_from( @@ -2504,14 +2508,16 @@ impl item.response.id.clone(), )) } else { - let charge_id = item + let charges = item .response .latest_charge .as_ref() .map(|charge| match charge { - StripeChargeEnum::ChargeId(charge_id) => charge_id.clone(), + StripeChargeEnum::ChargeId(charges) => charges.clone(), StripeChargeEnum::ChargeObject(charge) => charge.id.clone(), - }); + }) + .and_then(|charge_id| construct_charge_response(charge_id, &item.data.request)); + Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()), redirection_data: Box::new(redirection_data), @@ -2520,7 +2526,7 @@ impl network_txn_id, connector_response_reference_id: Some(item.response.id), incremental_authorization_allowed: None, - charge_id, + charges, }) }; @@ -2609,6 +2615,8 @@ pub fn get_connector_metadata( impl TryFrom> for types::RouterData +where + T: connector_util::SplitPaymentData, { type Error = error_stack::Report; fn try_from( @@ -2712,14 +2720,16 @@ impl }), _ => None, }; - let charge_id = item + let charges = item .response .latest_charge .as_ref() .map(|charge| match charge { - StripeChargeEnum::ChargeId(charge_id) => charge_id.clone(), + StripeChargeEnum::ChargeId(charges) => charges.clone(), StripeChargeEnum::ChargeObject(charge) => charge.id.clone(), - }); + }) + .and_then(|charge_id| construct_charge_response(charge_id, &item.data.request)); + Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId(item.response.id.clone()), redirection_data: Box::new(redirection_data), @@ -2728,7 +2738,7 @@ impl network_txn_id: network_transaction_id, connector_response_reference_id: Some(item.response.id.clone()), incremental_authorization_allowed: None, - charge_id, + charges, }) }; @@ -2808,7 +2818,7 @@ impl network_txn_id: network_transaction_id, connector_response_reference_id: Some(item.response.id), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }) }; @@ -3059,6 +3069,11 @@ impl TryFrom<&types::RefundsRouterData> for ChargeRefundRequest { }, }) } + types::SplitRefundsRequest::AdyenSplitRefund(_) => { + Err(errors::ConnectorError::MissingRequiredField { + field_name: "stripe_split_refund", + })? + } }, } } @@ -3519,7 +3534,7 @@ impl TryFrom( + charge_id: String, + request: &T, +) -> Option +where + T: connector_util::SplitPaymentData, +{ + let charge_request = request.get_split_payment_data(); + if let Some(common_types::payments::SplitPaymentsRequest::StripeSplitPayment( + stripe_split_payment, + )) = charge_request + { + let stripe_charge_response = common_types::payments::StripeChargeResponseData { + charge_id: Some(charge_id), + charge_type: stripe_split_payment.charge_type, + application_fees: stripe_split_payment.application_fees, + transfer_account_id: stripe_split_payment.transfer_account_id, + }; + Some( + common_types::payments::ConnectorChargeResponseData::StripeSplitPayment( + stripe_charge_response, + ), + ) + } else { + None + } +} diff --git a/crates/router/src/connector/trustpay/transformers.rs b/crates/router/src/connector/trustpay/transformers.rs index 83587609b3ff..ba3dc193ade6 100644 --- a/crates/router/src/connector/trustpay/transformers.rs +++ b/crates/router/src/connector/trustpay/transformers.rs @@ -737,7 +737,7 @@ fn handle_cards_response( network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }; Ok((status, error, payment_response_data)) } @@ -767,7 +767,7 @@ fn handle_bank_redirects_response( network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }; Ok((status, error, payment_response_data)) } @@ -801,7 +801,7 @@ fn handle_bank_redirects_error_response( network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }; Ok((status, error, payment_response_data)) } @@ -862,7 +862,7 @@ fn handle_bank_redirects_sync_response( network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }; Ok((status, error, payment_response_data)) } @@ -910,7 +910,7 @@ pub fn handle_webhook_response( network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }; Ok((status, error, payment_response_data)) } diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs index cbf1867b08ba..a75b5ee854b2 100644 --- a/crates/router/src/connector/utils.rs +++ b/crates/router/src/connector/utils.rs @@ -753,6 +753,40 @@ impl PaymentsCaptureRequestData for types::PaymentsCaptureData { } } +pub trait SplitPaymentData { + fn get_split_payment_data(&self) -> Option; +} + +impl SplitPaymentData for types::PaymentsCaptureData { + fn get_split_payment_data(&self) -> Option { + None + } +} + +impl SplitPaymentData for types::PaymentsAuthorizeData { + fn get_split_payment_data(&self) -> Option { + self.split_payments.clone() + } +} + +impl SplitPaymentData for types::PaymentsSyncData { + fn get_split_payment_data(&self) -> Option { + self.split_payments.clone() + } +} + +impl SplitPaymentData for PaymentsCancelData { + fn get_split_payment_data(&self) -> Option { + None + } +} + +impl SplitPaymentData for types::SetupMandateRequestData { + fn get_split_payment_data(&self) -> Option { + None + } +} + pub trait RevokeMandateRequestData { fn get_connector_mandate_id(&self) -> Result; } diff --git a/crates/router/src/connector/wellsfargo/transformers.rs b/crates/router/src/connector/wellsfargo/transformers.rs index 0500b098bb18..8ed32f90363d 100644 --- a/crates/router/src/connector/wellsfargo/transformers.rs +++ b/crates/router/src/connector/wellsfargo/transformers.rs @@ -1809,7 +1809,7 @@ fn get_payment_response( .unwrap_or(info_response.id.clone()), ), incremental_authorization_allowed, - charge_id: None, + charges: None, }) } } @@ -2027,7 +2027,7 @@ impl incremental_authorization_allowed: Some( mandate_status == enums::AttemptStatus::Authorized, ), - charge_id: None, + charges: None, }), }, connector_response, @@ -2156,7 +2156,7 @@ impl .map(|cref| cref.code) .unwrap_or(Some(item.response.id)), incremental_authorization_allowed, - charge_id: None, + charges: None, }), ..item.data }) @@ -2174,7 +2174,7 @@ impl network_txn_id: None, connector_response_reference_id: Some(item.response.id), incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }), diff --git a/crates/router/src/connector/wellsfargopayout/transformers.rs b/crates/router/src/connector/wellsfargopayout/transformers.rs index 135cb5f53cbf..3a194550dfd9 100644 --- a/crates/router/src/connector/wellsfargopayout/transformers.rs +++ b/crates/router/src/connector/wellsfargopayout/transformers.rs @@ -140,7 +140,7 @@ impl network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }), ..item.data }) diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index 1b31fdf46c07..1346e9d96370 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -6245,15 +6245,14 @@ pub async fn validate_merchant_connector_ids_in_connector_mandate_details( Ok(()) } -pub fn validate_platform_fees_for_marketplace( +pub fn validate_platform_request_for_marketplace( amount: api::Amount, split_payments: Option, ) -> Result<(), errors::ApiErrorResponse> { - if let Some(common_types::payments::SplitPaymentsRequest::StripeSplitPayment( - stripe_split_payment, - )) = split_payments - { - match amount { + match split_payments { + Some(common_types::payments::SplitPaymentsRequest::StripeSplitPayment( + stripe_split_payment, + )) => match amount { api::Amount::Zero => { if stripe_split_payment.application_fees.get_amount_as_i64() != 0 { return Err(errors::ApiErrorResponse::InvalidDataValue { @@ -6268,7 +6267,96 @@ pub fn validate_platform_fees_for_marketplace( }); } } + }, + Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment( + adyen_split_payment, + )) => { + let total_split_amount: i64 = adyen_split_payment + .split_items + .iter() + .map(|split_item| { + split_item + .amount + .unwrap_or(MinorUnit::new(0)) + .get_amount_as_i64() + }) + .sum(); + + match amount { + api::Amount::Zero => { + if total_split_amount != 0 { + return Err(errors::ApiErrorResponse::InvalidDataValue { + field_name: "Sum of split amounts should be equal to the total amount", + }); + } + } + api::Amount::Value(amount) => { + let i64_amount: i64 = amount.into(); + if !adyen_split_payment.split_items.is_empty() + && i64_amount != total_split_amount + { + return Err(errors::ApiErrorResponse::PreconditionFailed { + message: "Sum of split amounts should be equal to the total amount" + .to_string(), + }); + } + } + }; + adyen_split_payment + .split_items + .iter() + .try_for_each(|split_item| { + match split_item.split_type { + common_enums::AdyenSplitType::BalanceAccount => { + if split_item.account.is_none() { + return Err(errors::ApiErrorResponse::MissingRequiredField { + field_name: + "split_payments.adyen_split_payment.split_items.account", + }); + } + if split_item.reference.is_none() { + return Err(errors::ApiErrorResponse::MissingRequiredField { + field_name: + "split_payments.adyen_split_payment.split_items.reference", + }); + } + } + common_enums::AdyenSplitType::Commission + | enums::AdyenSplitType::Vat + | enums::AdyenSplitType::TopUp => { + if split_item.amount.is_none() { + return Err(errors::ApiErrorResponse::MissingRequiredField { + field_name: + "split_payments.adyen_split_payment.split_items.amount", + }); + } + if let enums::AdyenSplitType::TopUp = split_item.split_type { + if split_item.account.is_none() { + return Err(errors::ApiErrorResponse::MissingRequiredField { + field_name: + "split_payments.adyen_split_payment.split_items.account", + }); + } + if adyen_split_payment.store.is_some() { + return Err(errors::ApiErrorResponse::PreconditionFailed { + message: "Topup split payment is not available via Adyen Platform" + .to_string(), + }); + } + } + } + enums::AdyenSplitType::AcquiringFees + | enums::AdyenSplitType::PaymentFee + | enums::AdyenSplitType::AdyenFees + | enums::AdyenSplitType::AdyenCommission + | enums::AdyenSplitType::AdyenMarkup + | enums::AdyenSplitType::Interchange + | enums::AdyenSplitType::SchemeFee => {} + }; + Ok(()) + })?; } + None => (), } Ok(()) } diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs index ed7b84e8329b..50fb92bc5864 100644 --- a/crates/router/src/core/payments/operations/payment_create.rs +++ b/crates/router/src/core/payments/operations/payment_create.rs @@ -1029,7 +1029,7 @@ impl ValidateRequest( connector_metadata, connector_response_reference_id, incremental_authorization_allowed, - charge_id, + charges, .. } => { payment_data @@ -1731,11 +1731,12 @@ async fn payment_response_update_tracker( authentication_data, encoded_data, payment_method_data: additional_payment_method_data, - charge_id, + charge_id: None, //depreciated connector_mandate_detail: payment_data .payment_attempt .connector_mandate_detail .clone(), + charges, }), ), }; diff --git a/crates/router/src/core/payments/retry.rs b/crates/router/src/core/payments/retry.rs index 7ae536a1f193..f50f0fe3a9d5 100644 --- a/crates/router/src/core/payments/retry.rs +++ b/crates/router/src/core/payments/retry.rs @@ -420,7 +420,7 @@ where resource_id, connector_metadata, redirection_data, - charge_id, + charges, .. }) => { let encoded_data = payment_data.get_payment_attempt().encoded_data.clone(); @@ -465,8 +465,9 @@ where unified_code: None, unified_message: None, payment_method_data: additional_payment_method_data, - charge_id, + charge_id: None, connector_mandate_detail: None, + charges, }; #[cfg(feature = "v1")] diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 80c10a294ecf..9d96f0b9c6ab 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -890,7 +890,7 @@ where network_txn_id: None, connector_response_reference_id: None, incremental_authorization_allowed: None, - charge_id: None, + charges: None, }); let additional_data = PaymentAdditionalData { @@ -2103,24 +2103,6 @@ where ) }); - let split_payments_response = match payment_intent.split_payments { - None => None, - Some(split_payments) => match split_payments { - common_types::payments::SplitPaymentsRequest::StripeSplitPayment( - stripe_split_payment, - ) => Some( - api_models::payments::SplitPaymentsResponse::StripeSplitPayment( - api_models::payments::StripeSplitPaymentsResponse { - charge_id: payment_attempt.charge_id.clone(), - charge_type: stripe_split_payment.charge_type, - application_fees: stripe_split_payment.application_fees, - transfer_account_id: stripe_split_payment.transfer_account_id, - }, - ), - ), - }, - }; - let mandate_data = payment_data.get_setup_mandate().map(|d| api::MandateData { customer_acceptance: d .customer_acceptance @@ -2299,7 +2281,7 @@ where .get_payment_method_info() .map(|info| info.status), updated: Some(payment_intent.modified_at), - split_payments: split_payments_response, + split_payments: payment_attempt.charges, frm_metadata: payment_intent.frm_metadata, merchant_order_reference_id: payment_intent.merchant_order_reference_id, order_tax_amount, diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rs index 1e788b6acee4..1c2e0f1e4baa 100644 --- a/crates/router/src/core/refunds.rs +++ b/crates/router/src/core/refunds.rs @@ -13,8 +13,7 @@ use common_utils::{ use diesel_models::process_tracker::business_status; use error_stack::{report, ResultExt}; use hyperswitch_domain_models::{ - router_data::ErrorResponse, - router_request_types::{SplitRefundsRequest, StripeSplitRefund}, + router_data::ErrorResponse, router_request_types::SplitRefundsRequest, }; use hyperswitch_interfaces::integrity::{CheckIntegrity, FlowIntegrity, GetIntegrityObject}; use router_env::{instrument, tracing}; @@ -499,18 +498,12 @@ pub async fn refund_retrieve_core( .await .transpose()?; - let split_refunds_req: Option = payment_intent - .split_payments - .clone() - .zip(refund.split_refunds.clone()) - .map(|(split_payments, split_refunds)| { - SplitRefundsRequest::try_from(SplitRefundInput { - refund_request: split_refunds, - payment_charges: split_payments, - charge_id: payment_attempt.charge_id.clone(), - }) - }) - .transpose()?; + let split_refunds_req = core_utils::get_split_refunds(SplitRefundInput { + split_payment_request: payment_intent.split_payments.clone(), + payment_charges: payment_attempt.charges.clone(), + charge_id: payment_attempt.charge_id.clone(), + refund_request: refund.split_refunds.clone(), + })?; let unified_translated_message = if let (Some(unified_code), Some(unified_message)) = (refund.unified_code.clone(), refund.unified_message.clone()) @@ -799,32 +792,12 @@ pub async fn validate_and_create_refund( creds_identifier: Option, ) -> RouterResult { let db = &*state.store; - - let split_refunds = match payment_intent.split_payments.as_ref() { - Some(common_types::payments::SplitPaymentsRequest::StripeSplitPayment(stripe_payment)) => { - if let Some(charge_id) = payment_attempt.charge_id.clone() { - let refund_request = req - .split_refunds - .clone() - .get_required_value("split_refunds")?; - - let options = validator::validate_charge_refund( - &refund_request, - &stripe_payment.charge_type, - )?; - - Some(SplitRefundsRequest::StripeSplitRefund(StripeSplitRefund { - charge_id, - charge_type: stripe_payment.charge_type.clone(), - transfer_account_id: stripe_payment.transfer_account_id.clone(), - options, - })) - } else { - None - } - } - _ => None, - }; + let split_refunds = core_utils::get_split_refunds(SplitRefundInput { + split_payment_request: payment_intent.split_payments.clone(), + payment_charges: payment_attempt.charges.clone(), + charge_id: payment_attempt.charge_id.clone(), + refund_request: req.split_refunds.clone(), + })?; // Only for initial dev and testing let refund_type = req.refund_type.unwrap_or_default(); @@ -1539,36 +1512,12 @@ pub async fn trigger_refund_execute_workflow( ) .await .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?; - - let split_refunds = match payment_intent.split_payments.as_ref() { - Some(common_types::payments::SplitPaymentsRequest::StripeSplitPayment( - stripe_payment, - )) => { - let refund_request = refund - .split_refunds - .clone() - .get_required_value("split_refunds")?; - - let options = validator::validate_charge_refund( - &refund_request, - &stripe_payment.charge_type, - )?; - - let charge_id = payment_attempt.charge_id.clone().ok_or_else(|| { - report!(errors::ApiErrorResponse::InternalServerError).attach_printable( - "Transaction is invalid. Missing field \"charge_id\" in payment_attempt.", - ) - })?; - - Some(SplitRefundsRequest::StripeSplitRefund(StripeSplitRefund { - charge_id, - charge_type: stripe_payment.charge_type.clone(), - transfer_account_id: stripe_payment.transfer_account_id.clone(), - options, - })) - } - _ => None, - }; + let split_refunds = core_utils::get_split_refunds(SplitRefundInput { + split_payment_request: payment_intent.split_payments.clone(), + payment_charges: payment_attempt.charges.clone(), + charge_id: payment_attempt.charge_id.clone(), + refund_request: refund.split_refunds.clone(), + })?; //trigger refund request to gateway let updated_refund = Box::pin(trigger_refund_to_gateway( diff --git a/crates/router/src/core/refunds/transformers.rs b/crates/router/src/core/refunds/transformers.rs index 256e4c345224..151c6d202343 100644 --- a/crates/router/src/core/refunds/transformers.rs +++ b/crates/router/src/core/refunds/transformers.rs @@ -1,54 +1,6 @@ -use error_stack::{report, Report}; -use hyperswitch_domain_models::router_request_types; - -use super::validator; -use crate::core::errors; - pub struct SplitRefundInput { - pub refund_request: common_types::refunds::SplitRefund, - pub payment_charges: common_types::payments::SplitPaymentsRequest, + pub refund_request: Option, + pub payment_charges: Option, + pub split_payment_request: Option, pub charge_id: Option, } - -impl TryFrom for router_request_types::SplitRefundsRequest { - type Error = Report; - - fn try_from(value: SplitRefundInput) -> Result { - let SplitRefundInput { - refund_request, - payment_charges, - charge_id, - } = value; - - match refund_request { - common_types::refunds::SplitRefund::StripeSplitRefund(stripe_refund) => { - match payment_charges { - common_types::payments::SplitPaymentsRequest::StripeSplitPayment( - stripe_payment, - ) => { - let charge_id = charge_id.ok_or_else(|| { - report!(errors::ApiErrorResponse::InternalServerError) - .attach_printable("Missing `charge_id` in PaymentAttempt.") - })?; - - let options = validator::validate_charge_refund( - &common_types::refunds::SplitRefund::StripeSplitRefund( - stripe_refund.clone(), - ), - &stripe_payment.charge_type, - )?; - - Ok(Self::StripeSplitRefund( - router_request_types::StripeSplitRefund { - charge_id, // Use `charge_id` from `PaymentAttempt` - transfer_account_id: stripe_payment.transfer_account_id, - charge_type: stripe_payment.charge_type, - options, - }, - )) - } - } - } - } - } -} diff --git a/crates/router/src/core/refunds/validator.rs b/crates/router/src/core/refunds/validator.rs index 2387f9a3b5ff..20acb0743a08 100644 --- a/crates/router/src/core/refunds/validator.rs +++ b/crates/router/src/core/refunds/validator.rs @@ -146,35 +146,112 @@ pub fn validate_for_valid_refunds( } } -pub fn validate_charge_refund( - charges: &common_types::refunds::SplitRefund, - charge_type: &api_enums::PaymentChargeType, +pub fn validate_stripe_charge_refund( + charge_type_option: Option, + split_refund_request: &Option, ) -> RouterResult { - match charge_type { - api_enums::PaymentChargeType::Stripe(api_enums::StripeChargeType::Direct) => { - let common_types::refunds::SplitRefund::StripeSplitRefund(stripe_charge) = charges; + let charge_type = charge_type_option.ok_or_else(|| { + report!(errors::ApiErrorResponse::InternalServerError) + .attach_printable("Missing `charge_type` in PaymentAttempt.") + })?; - Ok(types::ChargeRefundsOptions::Direct( - types::DirectChargeRefund { - revert_platform_fee: stripe_charge - .revert_platform_fee - .get_required_value("revert_platform_fee")?, - }, - )) + let refund_request = match split_refund_request { + Some(common_types::refunds::SplitRefund::StripeSplitRefund(stripe_split_refund)) => { + stripe_split_refund + } + _ => Err(errors::ApiErrorResponse::MissingRequiredField { + field_name: "stripe_split_refund", + })?, + }; + + let options = match charge_type { + api_enums::PaymentChargeType::Stripe(api_enums::StripeChargeType::Direct) => { + types::ChargeRefundsOptions::Direct(types::DirectChargeRefund { + revert_platform_fee: refund_request + .revert_platform_fee + .get_required_value("revert_platform_fee")?, + }) } api_enums::PaymentChargeType::Stripe(api_enums::StripeChargeType::Destination) => { - let common_types::refunds::SplitRefund::StripeSplitRefund(stripe_charge) = charges; - - Ok(types::ChargeRefundsOptions::Destination( - types::DestinationChargeRefund { - revert_platform_fee: stripe_charge - .revert_platform_fee - .get_required_value("revert_platform_fee")?, - revert_transfer: stripe_charge - .revert_transfer - .get_required_value("revert_transfer")?, - }, - )) + types::ChargeRefundsOptions::Destination(types::DestinationChargeRefund { + revert_platform_fee: refund_request + .revert_platform_fee + .get_required_value("revert_platform_fee")?, + revert_transfer: refund_request + .revert_transfer + .get_required_value("revert_transfer")?, + }) } + }; + + Ok(options) +} + +pub fn validate_adyen_charge_refund( + adyen_split_payment_response: &common_types::domain::AdyenSplitData, + adyen_split_refund_request: &common_types::domain::AdyenSplitData, +) -> RouterResult<()> { + if adyen_split_refund_request.store != adyen_split_payment_response.store { + return Err(report!(errors::ApiErrorResponse::InvalidDataValue { + field_name: "store", + })); } + + for refund_split_item in adyen_split_refund_request.split_items.iter() { + match &refund_split_item.reference { + Some(refund_split_reference) => { + let matching_payment_split_item = adyen_split_payment_response + .split_items + .iter() + .find(|payment_split_item| { + Some(refund_split_reference.clone()) == payment_split_item.reference + }); + + if let Some(payment_split_item) = matching_payment_split_item { + if let Some(refund_amount) = refund_split_item.amount { + if let Some(payment_amount) = payment_split_item.amount { + if refund_amount > payment_amount { + return Err(report!( + errors::ApiErrorResponse::InvalidRequestData { + message: format!( + "Invalid refund amount for split item, reference: {}", + refund_split_reference + ), + } + )); + } + } + } + + if refund_split_item.account != payment_split_item.account { + return Err(report!(errors::ApiErrorResponse::InvalidRequestData { + message: format!( + "Invalid refund account for split item, reference: {}", + refund_split_reference + ), + })); + } + + if refund_split_item.split_type != payment_split_item.split_type { + return Err(report!(errors::ApiErrorResponse::InvalidRequestData { + message: format!( + "Invalid refund split_type for split item, reference: {}", + refund_split_reference + ), + })); + } + } else { + return Err(report!(errors::ApiErrorResponse::InvalidRequestData { + message: format!( + "No matching payment split item found for reference: {}", + refund_split_reference + ), + })); + } + } + None => (), + } + } + + Ok(()) } diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rs index 0f775eda8553..62be44221d02 100644 --- a/crates/router/src/core/utils.rs +++ b/crates/router/src/core/utils.rs @@ -457,6 +457,85 @@ pub fn validate_uuid(uuid: String, key: &str) -> Result RouterResult> { + match split_refund_input.split_payment_request.as_ref() { + Some(common_types::payments::SplitPaymentsRequest::StripeSplitPayment(stripe_payment)) => { + let (charge_id_option, charge_type_option) = match ( + &split_refund_input.payment_charges, + &split_refund_input.split_payment_request, + ) { + ( + Some(common_types::payments::ConnectorChargeResponseData::StripeSplitPayment( + stripe_split_payment_response, + )), + _, + ) => ( + stripe_split_payment_response.charge_id.clone(), + Some(stripe_split_payment_response.charge_type.clone()), + ), + ( + _, + Some(common_types::payments::SplitPaymentsRequest::StripeSplitPayment( + stripe_split_payment_request, + )), + ) => ( + split_refund_input.charge_id, + Some(stripe_split_payment_request.charge_type.clone()), + ), + (_, _) => (None, None), + }; + + if let Some(charge_id) = charge_id_option { + let options = super::refunds::validator::validate_stripe_charge_refund( + charge_type_option, + &split_refund_input.refund_request, + )?; + + Ok(Some( + router_request_types::SplitRefundsRequest::StripeSplitRefund( + router_request_types::StripeSplitRefund { + charge_id, + charge_type: stripe_payment.charge_type.clone(), + transfer_account_id: stripe_payment.transfer_account_id.clone(), + options, + }, + ), + )) + } else { + Ok(None) + } + } + Some(common_types::payments::SplitPaymentsRequest::AdyenSplitPayment(_)) => { + match &split_refund_input.payment_charges { + Some(common_types::payments::ConnectorChargeResponseData::AdyenSplitPayment( + adyen_split_payment_response, + )) => { + if let Some(common_types::refunds::SplitRefund::AdyenSplitRefund( + split_refund_request, + )) = split_refund_input.refund_request.clone() + { + super::refunds::validator::validate_adyen_charge_refund( + &adyen_split_payment_response, + &split_refund_request, + )?; + + Ok(Some( + router_request_types::SplitRefundsRequest::AdyenSplitRefund( + split_refund_request, + ), + )) + } else { + Ok(None) + } + } + _ => Ok(None), + } + } + _ => Ok(None), + } +} #[cfg(test)] mod tests { #![allow(clippy::expect_used)] diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rs index 2cf3dc965fd6..08947a6de9b6 100644 --- a/crates/router/tests/connectors/utils.rs +++ b/crates/router/tests/connectors/utils.rs @@ -1132,7 +1132,7 @@ pub fn get_connector_metadata( network_txn_id: _, connector_response_reference_id: _, incremental_authorization_allowed: _, - charge_id: _, + charges: _, }) => connector_metadata, _ => None, } diff --git a/crates/storage_impl/src/mock_db/payment_attempt.rs b/crates/storage_impl/src/mock_db/payment_attempt.rs index 0415625f7ebb..b4f7eee42949 100644 --- a/crates/storage_impl/src/mock_db/payment_attempt.rs +++ b/crates/storage_impl/src/mock_db/payment_attempt.rs @@ -195,6 +195,7 @@ impl PaymentAttemptInterface for MockDb { organization_id: payment_attempt.organization_id, profile_id: payment_attempt.profile_id, connector_mandate_detail: payment_attempt.connector_mandate_detail, + charges: None, }; payment_attempts.push(payment_attempt.clone()); Ok(payment_attempt) diff --git a/crates/storage_impl/src/payments/payment_attempt.rs b/crates/storage_impl/src/payments/payment_attempt.rs index 06c7fefe85fa..e41e7125ba0a 100644 --- a/crates/storage_impl/src/payments/payment_attempt.rs +++ b/crates/storage_impl/src/payments/payment_attempt.rs @@ -564,6 +564,7 @@ impl PaymentAttemptInterface for KVRouterStore { organization_id: payment_attempt.organization_id.clone(), profile_id: payment_attempt.profile_id.clone(), connector_mandate_detail: payment_attempt.connector_mandate_detail.clone(), + charges: None, }; let field = format!("pa_{}", created_attempt.attempt_id); @@ -1511,6 +1512,7 @@ impl DataModelExt for PaymentAttempt { shipping_cost: self.net_amount.get_shipping_cost(), order_tax_amount: self.net_amount.get_order_tax_amount(), connector_mandate_detail: self.connector_mandate_detail, + charges: self.charges, } } @@ -1587,6 +1589,7 @@ impl DataModelExt for PaymentAttempt { organization_id: storage_model.organization_id, profile_id: storage_model.profile_id, connector_mandate_detail: storage_model.connector_mandate_detail, + charges: storage_model.charges, } } } diff --git a/migrations/2025-01-14-832737_add_charges_to_payment_attempt/down.sql b/migrations/2025-01-14-832737_add_charges_to_payment_attempt/down.sql new file mode 100644 index 000000000000..cdd8328c8ee5 --- /dev/null +++ b/migrations/2025-01-14-832737_add_charges_to_payment_attempt/down.sql @@ -0,0 +1,2 @@ +ALTER TABLE payment_attempt +DROP COLUMN charges; \ No newline at end of file diff --git a/migrations/2025-01-14-832737_add_charges_to_payment_attempt/up.sql b/migrations/2025-01-14-832737_add_charges_to_payment_attempt/up.sql new file mode 100644 index 000000000000..10fa978f9dc6 --- /dev/null +++ b/migrations/2025-01-14-832737_add_charges_to_payment_attempt/up.sql @@ -0,0 +1,3 @@ +ALTER TABLE payment_attempt +ADD COLUMN charges JSONB +DEFAULT NULL; \ No newline at end of file