Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(connector): [Adyen] Add support for PayPal wallet mandates (#1686)
Prasunna Soppa82fd84462072
diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rsindex 97fdee30f2..5837e1522c 100644--- a/crates/router/src/connector/adyen/transformers.rs+++ b/crates/router/src/connector/adyen/transformers.rs@@ -19,6 +19,7 @@ use crate::{api::{self, enums as api_enums},storage::enums as storage_enums,transformers::ForeignFrom,+ PaymentsAuthorizeData,},};@@ -1054,6 +1055,21 @@ impl<'a> TryFrom<&api::Card> for AdyenPaymentMethod<'a> {}}+impl TryFrom<&storage_enums::PaymentMethodType> for PaymentType {+ type Error = Error;+ fn try_from(item: &storage_enums::PaymentMethodType) -> Result<Self, Self::Error> {+ match item {+ storage_enums::PaymentMethodType::Credit | storage_enums::PaymentMethodType::Debit => {+ Ok(Self::Scheme)+ }+ storage_enums::PaymentMethodType::Paypal => Ok(Self::Paypal),+ _ => Err(errors::ConnectorError::NotImplemented(+ "Payment Method Type".to_string(),+ ))?,+ }+ }+}+impl TryFrom<&utils::CardIssuer> for CardBrand {type Error = Error;fn try_from(card_issuer: &utils::CardIssuer) -> Result<Self, Self::Error> {@@ -1302,10 +1318,15 @@ impl<'a>let browser_info = get_browser_info(item)?;let additional_data = get_additional_data(item);let return_url = item.request.get_return_url()?;+ let payment_method_type = item+ .request+ .payment_method_type+ .as_ref()+ .ok_or(errors::ConnectorError::MissingPaymentMethodType)?;let payment_method = match mandate_ref_id {payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids) => {let adyen_mandate = AdyenMandate {- payment_type: PaymentType::Scheme,+ payment_type: PaymentType::try_from(payment_method_type)?,stored_payment_method_id: connector_mandate_ids.get_connector_mandate_id()?,};Ok::<AdyenPaymentMethod<'_>, Self::Error>(AdyenPaymentMethod::Mandate(Box::new(@@ -1521,6 +1542,24 @@ fn get_sofort_extra_details(}}+fn get_shopper_email(+ item: &PaymentsAuthorizeData,+ is_mandate_payment: bool,+) -> errors::CustomResult<Option<Email>, errors::ConnectorError> {+ if is_mandate_payment {+ let payment_method_type = item+ .payment_method_type+ .as_ref()+ .ok_or(errors::ConnectorError::MissingPaymentMethodType)?;+ match payment_method_type {+ storage_enums::PaymentMethodType::Paypal => Ok(Some(item.get_email()?)),+ _ => Ok(item.email.clone()),+ }+ } else {+ Ok(item.email.clone())+ }+}+impl<'a> TryFrom<(&types::PaymentsAuthorizeRouterData, &api::WalletData)>for AdyenPaymentRequest<'a>{@@ -1538,6 +1577,7 @@ impl<'a> TryFrom<(&types::PaymentsAuthorizeRouterData, &api::WalletData)>let (recurring_processing_model, store_payment_method, shopper_reference) =get_recurring_processing_model(item)?;let return_url = item.request.get_return_url()?;+ let shopper_email = get_shopper_email(&item.request, store_payment_method.is_some())?;Ok(AdyenPaymentRequest {amount,merchant_account: auth_type.merchant_account,@@ -1550,7 +1590,7 @@ impl<'a> TryFrom<(&types::PaymentsAuthorizeRouterData, &api::WalletData)>additional_data,telephone_number: None,shopper_name: None,- shopper_email: None,+ shopper_email,shopper_locale: None,billing_address: None,delivery_address: None,diff --git a/crates/router/src/core/errors.rs b/crates/router/src/core/errors.rsindex 609d137c71..d79e120c5c 100644--- a/crates/router/src/core/errors.rs+++ b/crates/router/src/core/errors.rs@@ -308,6 +308,8 @@ pub enum ConnectorError {FileValidationFailed { reason: String },#[error("Missing 3DS redirection payload: {field_name}")]MissingConnectorRedirectionPayload { field_name: &'static str },+ #[error("Payment Method Type not found")]+ MissingPaymentMethodType,}#[derive(Debug, thiserror::Error)]