mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 12:15:40 +08:00
refactor(customers_v2): address panics and some bugs in customers v2 endpoints (#6836)
This commit is contained in:
@ -121,8 +121,13 @@ pub struct PaymentMethodCreate {
|
||||
pub metadata: Option<pii::SecretSerdeValue>,
|
||||
|
||||
/// The unique identifier of the customer.
|
||||
#[schema(value_type = String, max_length = 64, min_length = 1, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]
|
||||
pub customer_id: id_type::CustomerId,
|
||||
#[schema(
|
||||
min_length = 32,
|
||||
max_length = 64,
|
||||
example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
|
||||
value_type = String
|
||||
)]
|
||||
pub customer_id: id_type::GlobalCustomerId,
|
||||
|
||||
/// Payment method data to be passed
|
||||
pub payment_method_data: PaymentMethodCreateData,
|
||||
@ -145,8 +150,13 @@ pub struct PaymentMethodIntentCreate {
|
||||
pub billing: Option<payments::Address>,
|
||||
|
||||
/// The unique identifier of the customer.
|
||||
#[schema(value_type = String, max_length = 64, min_length = 1, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]
|
||||
pub customer_id: id_type::CustomerId,
|
||||
#[schema(
|
||||
min_length = 32,
|
||||
max_length = 64,
|
||||
example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
|
||||
value_type = String
|
||||
)]
|
||||
pub customer_id: id_type::GlobalCustomerId,
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
@ -782,8 +792,13 @@ pub struct PaymentMethodResponse {
|
||||
pub merchant_id: id_type::MerchantId,
|
||||
|
||||
/// The unique identifier of the customer.
|
||||
#[schema(value_type = Option<String>, max_length = 64, min_length = 1, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]
|
||||
pub customer_id: id_type::CustomerId,
|
||||
#[schema(
|
||||
min_length = 32,
|
||||
max_length = 64,
|
||||
example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
|
||||
value_type = String
|
||||
)]
|
||||
pub customer_id: id_type::GlobalCustomerId,
|
||||
|
||||
/// The unique identifier of the Payment method
|
||||
#[schema(example = "card_rGK4Vi5iSW70MY7J2mIg")]
|
||||
@ -1780,8 +1795,13 @@ pub struct CustomerPaymentMethod {
|
||||
pub payment_method_id: String,
|
||||
|
||||
/// The unique identifier of the customer.
|
||||
#[schema(value_type = String, max_length = 64, min_length = 1, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]
|
||||
pub customer_id: id_type::CustomerId,
|
||||
#[schema(
|
||||
min_length = 32,
|
||||
max_length = 64,
|
||||
example = "12345_cus_01926c58bc6e77c09e809964e72af8c8",
|
||||
value_type = String
|
||||
)]
|
||||
pub customer_id: id_type::GlobalCustomerId,
|
||||
|
||||
/// The type of payment method use for the payment.
|
||||
#[schema(value_type = PaymentMethod,example = "card")]
|
||||
@ -2253,36 +2273,6 @@ impl From<PaymentMethodMigrationResponseType> for PaymentMethodMigrationResponse
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
|
||||
impl From<PaymentMethodMigrationResponseType> for PaymentMethodMigrationResponse {
|
||||
fn from((response, record): PaymentMethodMigrationResponseType) -> Self {
|
||||
match response {
|
||||
Ok(res) => Self {
|
||||
payment_method_id: Some(res.payment_method_response.payment_method_id),
|
||||
payment_method: res.payment_method_response.payment_method_type,
|
||||
payment_method_type: res.payment_method_response.payment_method_subtype,
|
||||
customer_id: Some(res.payment_method_response.customer_id),
|
||||
migration_status: MigrationStatus::Success,
|
||||
migration_error: None,
|
||||
card_number_masked: Some(record.card_number_masked),
|
||||
line_number: record.line_number,
|
||||
card_migrated: res.card_migrated,
|
||||
network_token_migrated: res.network_token_migrated,
|
||||
connector_mandate_details_migrated: res.connector_mandate_details_migrated,
|
||||
network_transaction_id_migrated: res.network_transaction_id_migrated,
|
||||
},
|
||||
Err(e) => Self {
|
||||
customer_id: Some(record.customer_id),
|
||||
migration_status: MigrationStatus::Failed,
|
||||
migration_error: Some(e),
|
||||
card_number_masked: Some(record.card_number_masked),
|
||||
line_number: record.line_number,
|
||||
..Self::default()
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl
|
||||
TryFrom<(
|
||||
PaymentMethodRecord,
|
||||
|
||||
Reference in New Issue
Block a user