Skip to content

Commit

Permalink
feat(payment_methods): receive card_holder_name in confirm flow whe…
Browse files Browse the repository at this point in the history
…n using token for payment (#2982)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
  • Loading branch information
Chethan-rao and hyperswitch-bot[bot] authored Nov 28, 2023
1 parent c0116db commit e7ad3a4
Show file tree
Hide file tree
Showing 40 changed files with 375 additions and 237 deletions.
15 changes: 14 additions & 1 deletion crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,14 @@ pub struct Card {
pub nick_name: Option<Secret<String>>,
}

#[derive(Eq, PartialEq, Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
#[serde(rename_all = "snake_case")]
pub struct CardToken {
/// The card holder's name
#[schema(value_type = String, example = "John Test")]
pub card_holder_name: Option<Secret<String>>,
}

#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
#[serde(rename_all = "snake_case")]
pub enum CardRedirectData {
Expand Down Expand Up @@ -846,6 +854,7 @@ pub enum PaymentMethodData {
Upi(UpiData),
Voucher(VoucherData),
GiftCard(Box<GiftCardData>),
CardToken(CardToken),
}

impl PaymentMethodData {
Expand Down Expand Up @@ -873,7 +882,8 @@ impl PaymentMethodData {
| Self::Reward
| Self::Upi(_)
| Self::Voucher(_)
| Self::GiftCard(_) => None,
| Self::GiftCard(_)
| Self::CardToken(_) => None,
}
}
}
Expand Down Expand Up @@ -1092,6 +1102,7 @@ pub enum AdditionalPaymentData {
GiftCard {},
Voucher {},
CardRedirect {},
CardToken {},
}

#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
Expand Down Expand Up @@ -1660,6 +1671,7 @@ pub enum PaymentMethodDataResponse {
Voucher,
GiftCard,
CardRedirect,
CardToken,
}

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, ToSchema)]
Expand Down Expand Up @@ -2455,6 +2467,7 @@ impl From<AdditionalPaymentData> for PaymentMethodDataResponse {
AdditionalPaymentData::Voucher {} => Self::Voucher,
AdditionalPaymentData::GiftCard {} => Self::GiftCard,
AdditionalPaymentData::CardRedirect {} => Self::CardRedirect,
AdditionalPaymentData::CardToken {} => Self::CardToken,
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion crates/router/src/connector/aci/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@ impl TryFrom<&AciRouterData<&types::PaymentsAuthorizeRouterData>> for AciPayment
| api::PaymentMethodData::GiftCard(_)
| api::PaymentMethodData::CardRedirect(_)
| api::PaymentMethodData::Upi(_)
| api::PaymentMethodData::Voucher(_) => Err(errors::ConnectorError::NotSupported {
| api::PaymentMethodData::Voucher(_)
| api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotSupported {
message: format!("{:?}", item.router_data.payment_method),
connector: "Aci",
})?,
Expand Down
6 changes: 4 additions & 2 deletions crates/router/src/connector/adyen/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,8 @@ impl<'a> TryFrom<&AdyenRouterData<&types::PaymentsAuthorizeRouterData>>
payments::PaymentMethodData::Crypto(_)
| payments::PaymentMethodData::MandatePayment
| payments::PaymentMethodData::Reward
| payments::PaymentMethodData::Upi(_) => {
| payments::PaymentMethodData::Upi(_)
| payments::PaymentMethodData::CardToken(_) => {
Err(errors::ConnectorError::NotSupported {
message: utils::SELECTED_PAYMENT_METHOD.to_string(),
connector: "Adyen",
Expand Down Expand Up @@ -2276,7 +2277,8 @@ impl<'a>
| payments::PaymentMethodData::Reward
| payments::PaymentMethodData::Upi(_)
| payments::PaymentMethodData::Voucher(_)
| payments::PaymentMethodData::GiftCard(_) => {
| payments::PaymentMethodData::GiftCard(_)
| api::PaymentMethodData::CardToken(_) => {
Err(errors::ConnectorError::NotSupported {
message: "Network tokenization for payment method".to_string(),
connector: "Adyen",
Expand Down
3 changes: 2 additions & 1 deletion crates/router/src/connector/airwallex/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ impl TryFrom<&AirwallexRouterData<&types::PaymentsAuthorizeRouterData>>
| api::PaymentMethodData::Reward
| api::PaymentMethodData::Upi(_)
| api::PaymentMethodData::Voucher(_)
| api::PaymentMethodData::GiftCard(_) => Err(errors::ConnectorError::NotImplemented(
| api::PaymentMethodData::GiftCard(_)
| api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("airwallex"),
)),
}?;
Expand Down
3 changes: 2 additions & 1 deletion crates/router/src/connector/bankofamerica/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsAuthorizeRouterData>>
| payments::PaymentMethodData::Reward
| payments::PaymentMethodData::Upi(_)
| payments::PaymentMethodData::Voucher(_)
| payments::PaymentMethodData::GiftCard(_) => {
| payments::PaymentMethodData::GiftCard(_)
| payments::PaymentMethodData::CardToken(_) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("Bank of America"),
)
Expand Down
Loading

0 comments on commit e7ad3a4

Please sign in to comment.