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): [Airwallex] Implement Google Pay in Wallets (#1316)
Sakil Mostak7489c870d9d8
diff --git a/crates/router/src/connector/airwallex/transformers.rs b/crates/router/src/connector/airwallex/transformers.rsindex 13a4db9b24..2647cacb11 100644--- a/crates/router/src/connector/airwallex/transformers.rs+++ b/crates/router/src/connector/airwallex/transformers.rs@@ -34,7 +34,7 @@ impl TryFrom<&types::PaymentsInitRouterData> for AirwallexIntentRequest {}}-#[derive(Debug, Serialize, Eq, PartialEq)]+#[derive(Debug, Serialize)]pub struct AirwallexPaymentsRequest {// Unique ID to be sent for each transaction/operation request to the connectorrequest_id: String,@@ -43,19 +43,20 @@ pub struct AirwallexPaymentsRequest {return_url: Option<String>,}-#[derive(Debug, Serialize, Eq, PartialEq)]+#[derive(Debug, Serialize)]#[serde(untagged)]pub enum AirwallexPaymentMethod {Card(AirwallexCard),+ Wallets(WalletData),}-#[derive(Debug, Serialize, Eq, PartialEq)]+#[derive(Debug, Serialize)]pub struct AirwallexCard {card: AirwallexCardDetails,#[serde(rename = "type")]payment_method_type: AirwallexPaymentType,}-#[derive(Debug, Serialize, Eq, PartialEq)]+#[derive(Debug, Serialize)]pub struct AirwallexCardDetails {expiry_month: Secret<String>,expiry_year: Secret<String>,@@ -63,18 +64,44 @@ pub struct AirwallexCardDetails {cvc: Secret<String>,}-#[derive(Debug, Serialize, Eq, PartialEq)]+#[derive(Debug, Serialize)]+#[serde(untagged)]+pub enum WalletData {+ GooglePay(GooglePayData),+}++#[derive(Debug, Serialize)]+pub struct GooglePayData {+ googlepay: GooglePayDetails,+ #[serde(rename = "type")]+ payment_method_type: AirwallexPaymentType,+}++#[derive(Debug, Serialize)]+pub struct GooglePayDetails {+ encrypted_payment_token: Secret<String>,+ payment_data_type: GpayPaymentDataType,+}++#[derive(Debug, Serialize)]#[serde(rename_all = "snake_case")]pub enum AirwallexPaymentType {Card,+ Googlepay,}-#[derive(Debug, Serialize, Eq, PartialEq)]+#[derive(Debug, Serialize)]+#[serde(rename_all = "snake_case")]+pub enum GpayPaymentDataType {+ EncryptedPaymentToken,+}++#[derive(Debug, Serialize)]#[serde(rename_all = "snake_case")]pub enum AirwallexPaymentOptions {Card(AirwallexCardPaymentOptions),}-#[derive(Debug, Serialize, Eq, PartialEq)]+#[derive(Debug, Serialize)]pub struct AirwallexCardPaymentOptions {auto_capture: bool,}@@ -102,10 +129,12 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AirwallexPaymentsRequest {payment_method_type: AirwallexPaymentType::Card,}))}+ api::PaymentMethodData::Wallet(ref wallet_data) => get_wallet_details(wallet_data),_ => Err(errors::ConnectorError::NotImplemented("Unknown payment method".to_string(),)),}?;+Ok(Self {request_id: Uuid::new_v4().to_string(),payment_method,@@ -115,6 +144,28 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AirwallexPaymentsRequest {}}+fn get_wallet_details(+ wallet_data: &api_models::payments::WalletData,+) -> Result<AirwallexPaymentMethod, errors::ConnectorError> {+ let wallet_details: AirwallexPaymentMethod = match wallet_data {+ api_models::payments::WalletData::GooglePay(gpay_details) => {+ AirwallexPaymentMethod::Wallets(WalletData::GooglePay(GooglePayData {+ googlepay: GooglePayDetails {+ encrypted_payment_token: Secret::new(+ gpay_details.tokenization_data.token.clone(),+ ),+ payment_data_type: GpayPaymentDataType::EncryptedPaymentToken,+ },+ payment_method_type: AirwallexPaymentType::Googlepay,+ }))+ }+ _ => Err(errors::ConnectorError::NotImplemented(+ "Payment method".to_string(),+ ))?,+ };+ Ok(wallet_details)+}+#[derive(Deserialize)]pub struct AirwallexAuthUpdateResponse {#[serde(with = "common_utils::custom_serde::iso8601")]diff --git a/crates/router/tests/connectors/airwallex_ui.rs b/crates/router/tests/connectors/airwallex_ui.rsindex ef5376b132..d9b2ad5c6a 100644--- a/crates/router/tests/connectors/airwallex_ui.rs+++ b/crates/router/tests/connectors/airwallex_ui.rs@@ -37,8 +37,34 @@ async fn should_make_airwallex_3ds_payment(web_driver: WebDriver) -> Result<(),Ok(())}+async fn should_make_airwallex_gpay_payment(web_driver: WebDriver) -> Result<(), WebDriverError> {+ let conn = AirwallexSeleniumTest {};+ let merchant_name = conn+ .get_configs()+ .automation_configs+ .unwrap()+ .airwallex_merchant_name+ .unwrap();+ conn.make_gpay_payment(web_driver,+ &format!("{CHEKOUT_BASE_URL}/gpay?gatewayname=airwallex&gatewaymerchantid={merchant_name}&amount=70.00&country=US¤cy=USD"),+ vec![+ Event::Trigger(Trigger::Query(By::ClassName("title"))),+ Event::Assert(Assert::Eq(Selector::Title, "Airwallex - Create 3D Secure Payment")),+ Event::Trigger(Trigger::SendKeys(By::Id("challengeDataEntry"), "1234")),+ Event::Trigger(Trigger::Click(By::Id("submit"))),+ Event::Assert(Assert::IsPresent("succeeded")),+ ]).await?;+ Ok(())+}+#[test]#[serial]fn should_make_airwallex_3ds_payment_test() {tester!(should_make_airwallex_3ds_payment);}++#[test]+#[serial]+fn should_make_airwallex_gpay_payment_test() {+ tester!(should_make_airwallex_gpay_payment);+}diff --git a/crates/router/tests/connectors/connector_auth.rs b/crates/router/tests/connectors/connector_auth.rsindex 3651f29f56..4e3820e071 100644--- a/crates/router/tests/connectors/connector_auth.rs+++ b/crates/router/tests/connectors/connector_auth.rs@@ -143,4 +143,5 @@ pub struct AutomationConfigs {pub bluesnap_gateway_merchant_id: Option<String>,pub globalpay_gateway_merchant_id: Option<String>,pub run_minimum_steps: Option<bool>,+ pub airwallex_merchant_name: Option<String>,}