Skip to content

Commit

Permalink
feat(connector): [Adyen] Add support for Samsung Pay (#1525)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sangamesh26 authored Jun 28, 2023
1 parent 6bc4188 commit 33309da
Show file tree
Hide file tree
Showing 6 changed files with 577 additions and 342 deletions.
1 change: 1 addition & 0 deletions crates/api_models/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ pub enum PaymentMethodType {
PayBright,
Paypal,
Przelewy24,
SamsungPay,
Sepa,
Sofort,
Swish,
Expand Down
10 changes: 10 additions & 0 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,10 +845,20 @@ pub enum WalletData {
PaypalRedirect(PaypalRedirection),
/// The wallet data for Paypal
PaypalSdk(PayPalWalletData),
/// The wallet data for Samsung Pay
SamsungPay(Box<SamsungPayWalletData>),
/// The wallet data for WeChat Pay Redirection
WeChatPayRedirect(Box<WeChatPayRedirection>),
}

#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
#[serde(rename_all = "snake_case")]
pub struct SamsungPayWalletData {
/// The encrypted payment token from Samsung
#[schema(value_type = String)]
pub token: Secret<String>,
}

#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
#[serde(rename_all = "snake_case")]
pub struct GooglePayWalletData {
Expand Down
17 changes: 17 additions & 0 deletions crates/router/src/connector/adyen/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ pub enum AdyenPaymentMethod<'a> {
#[serde(rename = "sepadirectdebit")]
SepaDirectDebit(Box<SepaDirectDebitData>),
BacsDirectDebit(Box<BacsDirectDebitData>),
SamsungPay(Box<SamsungPayPmData>),
}

#[derive(Debug, Clone, Serialize)]
Expand Down Expand Up @@ -360,6 +361,14 @@ pub struct WalleyData {
payment_type: PaymentType,
}

#[derive(Debug, Clone, Serialize)]
pub struct SamsungPayPmData {
#[serde(rename = "type")]
payment_type: PaymentType,
#[serde(rename = "samsungPayToken")]
samsung_pay_token: Secret<String>,
}

#[derive(Debug, Clone, Serialize)]
pub struct PayBrightData {
#[serde(rename = "type")]
Expand Down Expand Up @@ -690,6 +699,7 @@ pub enum PaymentType {
SepaDirectDebit,
#[serde(rename = "directdebit_GB")]
BacsDirectDebit,
Samsungpay,
}

pub struct AdyenTestBankNames<'a>(&'a str);
Expand Down Expand Up @@ -1097,6 +1107,13 @@ impl<'a> TryFrom<&api::WalletData> for AdyenPaymentMethod<'a> {
};
Ok(AdyenPaymentMethod::WeChatPayWeb(Box::new(data)))
}
api_models::payments::WalletData::SamsungPay(samsung_data) => {
let data = SamsungPayPmData {
payment_type: PaymentType::Samsungpay,
samsung_pay_token: samsung_data.token.to_owned(),
};
Ok(AdyenPaymentMethod::SamsungPay(Box::new(data)))
}
_ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payments::ApplepaySessionTokenResponse,
api_models::payments::SdkNextAction,
api_models::payments::NextActionCall,
api_models::payments::SamsungPayWalletData,
api_models::payments::GpayTokenizationData,
api_models::payments::GooglePayPaymentMethodInfo,
api_models::payments::ApplePayWalletData,
Expand Down
1 change: 1 addition & 0 deletions crates/storage_models/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ pub enum PaymentMethodType {
PayBright,
Paypal,
Przelewy24,
SamsungPay,
Sepa,
Sofort,
Swish,
Expand Down
Loading

0 comments on commit 33309da

Please sign in to comment.