From cd39dd4a997951b19eb4e57a54f3c126d65a940f Mon Sep 17 00:00:00 2001 From: Sangamesh Kulkarni <59434228+Sangamesh26@users.noreply.github.com> Date: Wed, 7 Dec 2022 17:30:58 +0530 Subject: [PATCH] feat: apple pay through adyen (#62) Co-authored-by: Arun Raj M --- .../src/connector/adyen/transformers.rs | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs index eaf8e8af54..80cf5d6126 100644 --- a/crates/router/src/connector/adyen/transformers.rs +++ b/crates/router/src/connector/adyen/transformers.rs @@ -141,6 +141,7 @@ pub enum AdyenPaymentMethod { AdyenCard(AdyenCard), AdyenPaypal(AdyenPaypal), Gpay(AdyenGPay), + ApplePay(AdyenApplePay), } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -185,6 +186,14 @@ pub struct AdyenGPay { google_pay_token: String, } +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct AdyenApplePay { + #[serde(rename = "type")] + payment_type: String, + #[serde(rename = "applePayToken")] + apple_pay_token: String, +} + // Refunds Request and Response #[derive(Default, Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] @@ -314,9 +323,17 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AdyenPaymentRequest { }; Ok(AdyenPaymentMethod::Gpay(gpay_data)) } - _ => Err(errors::ConnectorError::NotImplemented( - "ApplePay".to_string(), - )), + enums::WalletIssuer::ApplePay => { + let apple_pay_data = AdyenApplePay { + payment_type, + apple_pay_token: wallet_data + .get_required_value("token") + .change_context(errors::ConnectorError::RequestEncodingFailed)? + .token + .to_string(), + }; + Ok(AdyenPaymentMethod::ApplePay(apple_pay_data)) + } }, enums::PaymentMethodType::Paypal => { let wallet = AdyenPaypal { payment_type };