Skip to content
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
687a9a1
core changes
sumanmaji4 Nov 27, 2024
9ec8a16
clippy error fix
sumanmaji4 Nov 27, 2024
18bc1fd
clippy fix for v2
sumanmaji4 Nov 28, 2024
c23016c
comment resolved
sumanmaji4 Dec 2, 2024
3092c53
migrations update
sumanmaji4 Dec 5, 2024
846c162
comment resolved
sumanmaji4 Dec 6, 2024
d313bf1
wip
sumanmaji4 Dec 12, 2024
25c3ea6
CommonMandateReference added
sumanmaji4 Dec 18, 2024
625a49c
update should_create_connector_transfer_method
sumanmaji4 Dec 19, 2024
dfd208d
PaymentsMandate to CommonMandate Reference
sumanmaji4 Dec 19, 2024
d15d646
wip
sumanmaji4 Dec 20, 2024
3f008e7
clippy fix
sumanmaji4 Dec 20, 2024
5ff47b6
clippy fix
sumanmaji4 Dec 26, 2024
ee37bb7
transaction_flow removed from pmt
sumanmaji4 Dec 26, 2024
be95982
impl from added
sumanmaji4 Dec 26, 2024
d7f0b1d
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Dec 26, 2024
e2749f0
retrieve and payout in stages fix
sumanmaji4 Dec 29, 2024
56bd898
comments resolved
sumanmaji4 Jan 2, 2025
42f45b0
retrieve call fix and comment resolve
sumanmaji4 Jan 2, 2025
90fef34
nit fix
sumanmaji4 Jan 3, 2025
00b465a
MIT fix
sumanmaji4 Jan 3, 2025
652722d
MIT fix
sumanmaji4 Jan 7, 2025
8357acc
nit fix
sumanmaji4 Jan 7, 2025
13028d8
comments resolved
sumanmaji4 Jan 8, 2025
123b29f
WIP
sumanmaji4 Jan 10, 2025
ca9bf00
mandate structure change
sumanmaji4 Jan 10, 2025
71cbdff
clippy fix
sumanmaji4 Jan 10, 2025
15fa38c
chore: run formatter
hyperswitch-bot[bot] Jan 10, 2025
b4295f4
removed payout from mandate if null
sumanmaji4 Jan 10, 2025
c4f58c8
refactor code
sumanmaji4 Jan 13, 2025
8717d29
comments resolved
sumanmaji4 Jan 14, 2025
af509f3
github test fix
sumanmaji4 Jan 14, 2025
f8006d2
comments resolved
sumanmaji4 Jan 16, 2025
3cd9d76
comments resolved
sumanmaji4 Jan 17, 2025
2ef1dfa
CommonMandateReference added in domain_models
sumanmaji4 Jan 17, 2025
e44f499
unit test added
sumanmaji4 Jan 20, 2025
e9a645d
github checks fix
sumanmaji4 Jan 27, 2025
4ab0b34
clippy fix
sumanmaji4 Jan 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions api-reference-v2/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -16989,6 +16989,11 @@
"example": "+1",
"nullable": true,
"maxLength": 255
},
"payout_method_id": {
"type": "string",
"description": "Identifier for payout method",
"nullable": true
}
},
"additionalProperties": false
Expand Down Expand Up @@ -17228,6 +17233,11 @@
"example": "Invalid card details",
"nullable": true,
"maxLength": 1024
},
"payout_method_id": {
"type": "string",
"description": "Identifier for payout method",
"nullable": true
}
},
"additionalProperties": false
Expand Down
20 changes: 20 additions & 0 deletions api-reference/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -20916,6 +20916,11 @@
"example": "+1",
"nullable": true,
"maxLength": 255
},
"payout_method_id": {
"type": "string",
"description": "Identifier for payout method",
"nullable": true
}
}
},
Expand Down Expand Up @@ -21214,6 +21219,11 @@
"example": "Invalid card details",
"nullable": true,
"maxLength": 1024
},
"payout_method_id": {
"type": "string",
"description": "Identifier for payout method",
"nullable": true
}
},
"additionalProperties": false
Expand Down Expand Up @@ -21860,6 +21870,11 @@
"example": "+1",
"nullable": true,
"maxLength": 255
},
"payout_method_id": {
"type": "string",
"description": "Identifier for payout method",
"nullable": true
}
}
},
Expand Down Expand Up @@ -22072,6 +22087,11 @@
"example": "+1",
"nullable": true,
"maxLength": 255
},
"payout_method_id": {
"type": "string",
"description": "Identifier for payout method",
"nullable": true
}
}
},
Expand Down
104 changes: 99 additions & 5 deletions crates/api_models/src/payment_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ pub struct PaymentMethodMigrate {
pub billing: Option<payments::Address>,

/// The connector mandate details of the payment method
pub connector_mandate_details: Option<PaymentsMandateReference>,
#[serde(deserialize_with = "deserialize_connector_mandate_details")]
pub connector_mandate_details: Option<CommonMandateReference>,

// The CIT (customer initiated transaction) transaction id associated with the payment method
pub network_transaction_id: Option<String>,
Expand All @@ -267,19 +268,103 @@ pub struct PaymentMethodMigrateResponse {
pub network_transaction_id_migrated: Option<bool>,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
pub struct PaymentsMandateReference(
pub HashMap<id_type::MerchantConnectorAccountId, PaymentsMandateReferenceRecord>,
);

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
pub struct PayoutsMandateReference(
pub HashMap<id_type::MerchantConnectorAccountId, PayoutsMandateReferenceRecord>,
);

#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
pub struct PayoutsMandateReferenceRecord {
pub transfer_method_id: Option<String>,
}

#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
pub struct PaymentsMandateReferenceRecord {
pub connector_mandate_id: String,
pub payment_method_type: Option<common_enums::PaymentMethodType>,
pub original_payment_authorized_amount: Option<i64>,
pub original_payment_authorized_currency: Option<common_enums::Currency>,
}

#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
pub struct CommonMandateReference {
pub payments: Option<PaymentsMandateReference>,
pub payouts: Option<PayoutsMandateReference>,
}

impl From<CommonMandateReference> for PaymentsMandateReference {
fn from(common_mandate: CommonMandateReference) -> Self {
common_mandate.payments.unwrap_or_default()
}
}

impl From<PaymentsMandateReference> for CommonMandateReference {
fn from(payments_reference: PaymentsMandateReference) -> Self {
Self {
payments: Some(payments_reference),
payouts: None,
}
}
}

fn deserialize_connector_mandate_details<'de, D>(
deserializer: D,
) -> Result<Option<CommonMandateReference>, D::Error>
where
D: serde::Deserializer<'de>,
{
let value: Option<serde_json::Value> =
<Option<serde_json::Value> as de::Deserialize>::deserialize(deserializer)?;

let payments_data = value
.clone()
.map(|mut mandate_details| {
mandate_details
.as_object_mut()
.map(|obj| obj.remove("payouts"));

serde_json::from_value::<PaymentsMandateReference>(mandate_details)
})
.transpose()
.map_err(|err| {
let err_msg = format!("{err:?}");
de::Error::custom(format_args!(
"Failed to deserialize PaymentsMandateReference `{}`",
err_msg
))
})?;

let payouts_data = value
.clone()
.map(|mandate_details| {
serde_json::from_value::<Option<CommonMandateReference>>(mandate_details).map(
|optional_common_mandate_details| {
optional_common_mandate_details
.and_then(|common_mandate_details| common_mandate_details.payouts)
},
)
})
.transpose()
.map_err(|err| {
let err_msg = format!("{err:?}");
de::Error::custom(format_args!(
"Failed to deserialize CommonMandateReference `{}`",
err_msg
))
})?
.flatten();

Ok(Some(CommonMandateReference {
payments: payments_data,
payouts: payouts_data,
}))
}

#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "payment_methods_v2")
Expand Down Expand Up @@ -313,7 +398,12 @@ impl PaymentMethodCreate {
payment_method_issuer_code: payment_method_migrate.payment_method_issuer_code,
metadata: payment_method_migrate.metadata.clone(),
payment_method_data: payment_method_migrate.payment_method_data.clone(),
connector_mandate_details: payment_method_migrate.connector_mandate_details.clone(),
connector_mandate_details: payment_method_migrate
.connector_mandate_details
.clone()
.map(|common_mandate_reference| {
PaymentsMandateReference::from(common_mandate_reference)
}),
client_secret: None,
billing: payment_method_migrate.billing.clone(),
card: card_details,
Expand Down Expand Up @@ -2328,7 +2418,11 @@ impl
}),
email: record.email,
}),
connector_mandate_details,
connector_mandate_details: connector_mandate_details.map(
|payments_mandate_reference| {
CommonMandateReference::from(payments_mandate_reference)
},
),
metadata: None,
payment_method_issuer_code: None,
card_network: None,
Expand Down
6 changes: 6 additions & 0 deletions crates/api_models/src/payouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ pub struct PayoutCreateRequest {
/// Customer's phone country code. _Deprecated: Use customer object instead._
#[schema(deprecated, max_length = 255, example = "+1")]
pub phone_country_code: Option<String>,

/// Identifier for payout method
pub payout_method_id: Option<String>,
}

impl PayoutCreateRequest {
Expand Down Expand Up @@ -568,6 +571,9 @@ pub struct PayoutCreateResponse {
#[remove_in(PayoutCreateResponse)]
#[schema(value_type = Option<String>, max_length = 1024, example = "Invalid card details")]
pub unified_message: Option<UnifiedMessage>,

/// Identifier for payout method
pub payout_method_id: Option<String>,
}

/// The payout method information for response
Expand Down
Loading
Loading