diff --git a/config/config.example.toml b/config/config.example.toml index b1189b51faee..08d667d72f67 100644 --- a/config/config.example.toml +++ b/config/config.example.toml @@ -183,6 +183,7 @@ adyen.payout_base_url = "https://pal-test.adyen.com/" adyen.dispute_base_url = "https://ca-test.adyen.com/" adyenplatform.base_url = "https://balanceplatform-api-test.adyen.com/" airwallex.base_url = "https://api-demo.airwallex.com/" +amazonpay.base_url = "https://pay-api.amazon.com/v2" applepay.base_url = "https://apple-pay-gateway.apple.com/" authorizedotnet.base_url = "https://apitest.authorize.net/xml/v1/request.api" bambora.base_url = "https://api.na.bambora.com" diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml index 5228f435fcd9..a60e0e15971c 100644 --- a/config/deployments/integration_test.toml +++ b/config/deployments/integration_test.toml @@ -25,6 +25,7 @@ adyen.payout_base_url = "https://pal-test.adyen.com/" adyen.dispute_base_url = "https://ca-test.adyen.com/" adyenplatform.base_url = "https://balanceplatform-api-test.adyen.com/" airwallex.base_url = "https://api-demo.airwallex.com/" +amazonpay.base_url = "https://pay-api.amazon.com/v2" applepay.base_url = "https://apple-pay-gateway.apple.com/" authorizedotnet.base_url = "https://apitest.authorize.net/xml/v1/request.api" bambora.base_url = "https://api.na.bambora.com" diff --git a/config/deployments/production.toml b/config/deployments/production.toml index ed2430b266a5..6fb62bc815d9 100644 --- a/config/deployments/production.toml +++ b/config/deployments/production.toml @@ -29,6 +29,7 @@ adyen.payout_base_url = "https://{{merchant_endpoint_prefix}}-pal-live.adyenpaym adyen.dispute_base_url = "https://{{merchant_endpoint_prefix}}-ca-live.adyen.com/" adyenplatform.base_url = "https://balanceplatform-api-live.adyen.com/" airwallex.base_url = "https://api-demo.airwallex.com/" +amazonpay.base_url = "https://pay-api.amazon.com/v2" applepay.base_url = "https://apple-pay-gateway.apple.com/" authorizedotnet.base_url = "https://api.authorize.net/xml/v1/request.api" bambora.base_url = "https://api.na.bambora.com" diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml index 3c39f31faecf..afc448d0b604 100644 --- a/config/deployments/sandbox.toml +++ b/config/deployments/sandbox.toml @@ -29,6 +29,7 @@ adyen.payout_base_url = "https://pal-test.adyen.com/" adyen.dispute_base_url = "https://ca-test.adyen.com/" adyenplatform.base_url = "https://balanceplatform-api-test.adyen.com/" airwallex.base_url = "https://api-demo.airwallex.com/" +amazonpay.base_url = "https://pay-api.amazon.com/v2" applepay.base_url = "https://apple-pay-gateway.apple.com/" authorizedotnet.base_url = "https://apitest.authorize.net/xml/v1/request.api" bambora.base_url = "https://api.na.bambora.com" diff --git a/config/development.toml b/config/development.toml index ca4dcb9529ec..3e87cbeb3bac 100644 --- a/config/development.toml +++ b/config/development.toml @@ -99,6 +99,7 @@ cards = [ "adyen", "adyenplatform", "airwallex", + "amazonpay", "authorizedotnet", "bambora", "bamboraapac", diff --git a/config/docker_compose.toml b/config/docker_compose.toml index b84c3dacd9c3..b5a6b7bb4bc5 100644 --- a/config/docker_compose.toml +++ b/config/docker_compose.toml @@ -112,6 +112,7 @@ adyenplatform.base_url = "https://balanceplatform-api-test.adyen.com/" adyen.payout_base_url = "https://pal-test.adyen.com/" adyen.dispute_base_url = "https://ca-test.adyen.com/" airwallex.base_url = "https://api-demo.airwallex.com/" +amazonpay.base_url = "https://pay-api.amazon.com/v2" applepay.base_url = "https://apple-pay-gateway.apple.com/" authorizedotnet.base_url = "https://apitest.authorize.net/xml/v1/request.api" bambora.base_url = "https://api.na.bambora.com" @@ -213,6 +214,7 @@ cards = [ "adyen", "adyenplatform", "airwallex", + "amazonpay", "authorizedotnet", "bambora", "bamboraapac", diff --git a/crates/api_models/src/connector_enums.rs b/crates/api_models/src/connector_enums.rs index 5803800f4df0..a927aefd2ea5 100644 --- a/crates/api_models/src/connector_enums.rs +++ b/crates/api_models/src/connector_enums.rs @@ -54,6 +54,7 @@ pub enum Connector { Aci, Adyen, Airwallex, + // Amazonpay, Authorizedotnet, Bambora, Bamboraapac, @@ -195,6 +196,7 @@ impl Connector { | Self::Adyen | Self::Adyenplatform | Self::Airwallex + // | Self::Amazonpay | Self::Authorizedotnet | Self::Bambora | Self::Bamboraapac diff --git a/crates/common_enums/src/connector_enums.rs b/crates/common_enums/src/connector_enums.rs index a5f6d0fe356c..f5a5b40381bb 100644 --- a/crates/common_enums/src/connector_enums.rs +++ b/crates/common_enums/src/connector_enums.rs @@ -51,6 +51,7 @@ pub enum RoutableConnectors { Aci, Adyen, Airwallex, + // Amazonpay, Authorizedotnet, Bankofamerica, Billwerk, diff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rs index bd9efa57bc60..fe033f88f218 100644 --- a/crates/hyperswitch_connectors/src/connectors.rs +++ b/crates/hyperswitch_connectors/src/connectors.rs @@ -1,4 +1,5 @@ pub mod airwallex; +pub mod amazonpay; pub mod bambora; pub mod billwerk; pub mod bitpay; @@ -37,7 +38,7 @@ pub mod zen; pub mod zsl; pub use self::{ - airwallex::Airwallex, bambora::Bambora, billwerk::Billwerk, bitpay::Bitpay, + airwallex::Airwallex, amazonpay::Amazonpay, bambora::Bambora, billwerk::Billwerk, bitpay::Bitpay, cashtocode::Cashtocode, coinbase::Coinbase, cryptopay::Cryptopay, deutschebank::Deutschebank, digitalvirgo::Digitalvirgo, dlocal::Dlocal, elavon::Elavon, fiserv::Fiserv, fiservemea::Fiservemea, fiuu::Fiuu, forte::Forte, globepay::Globepay, helcim::Helcim, diff --git a/crates/hyperswitch_connectors/src/connectors/amazonpay.rs b/crates/hyperswitch_connectors/src/connectors/amazonpay.rs new file mode 100644 index 000000000000..da4d3d79bbcf --- /dev/null +++ b/crates/hyperswitch_connectors/src/connectors/amazonpay.rs @@ -0,0 +1,567 @@ +pub mod transformers; + +use common_utils::{ + errors::CustomResult, + ext_traits::BytesExt, + request::{Method, Request, RequestBuilder, RequestContent}, + types::{AmountConvertor, StringMinorUnit, StringMinorUnitForConnector}, +}; +use error_stack::{report, ResultExt}; +use hyperswitch_domain_models::{ + router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData}, + router_flow_types::{ + access_token_auth::AccessTokenAuth, + payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void}, + refunds::{Execute, RSync}, + }, + router_request_types::{ + AccessTokenRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData, + PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData, + RefundsData, SetupMandateRequestData, + }, + router_response_types::{PaymentsResponseData, RefundsResponseData}, + types::{ + PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData, + RefundSyncRouterData, RefundsRouterData, + }, +}; +use hyperswitch_interfaces::{ + api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + configs::Connectors, + errors, + events::connector_api_logs::ConnectorEvent, + types::{self, Response}, + webhooks, +}; +use masking::{ExposeInterface, Mask}; +use transformers as amazonpay; + +use crate::{constants::headers, types::ResponseRouterData, utils}; + +#[derive(Clone)] +pub struct Amazonpay { + amount_converter: &'static (dyn AmountConvertor + Sync), +} + +impl Amazonpay { + pub fn new() -> &'static Self { + &Self { + amount_converter: &StringMinorUnitForConnector, + } + } +} + +impl api::Payment for Amazonpay {} +impl api::PaymentSession for Amazonpay {} +impl api::ConnectorAccessToken for Amazonpay {} +impl api::MandateSetup for Amazonpay {} +impl api::PaymentAuthorize for Amazonpay {} +impl api::PaymentSync for Amazonpay {} +impl api::PaymentCapture for Amazonpay {} +impl api::PaymentVoid for Amazonpay {} +impl api::Refund for Amazonpay {} +impl api::RefundExecute for Amazonpay {} +impl api::RefundSync for Amazonpay {} +impl api::PaymentToken for Amazonpay {} + +impl ConnectorIntegration + for Amazonpay +{ + // Not Implemented (R) +} + +impl ConnectorCommonExt for Amazonpay +where + Self: ConnectorIntegration, +{ + fn build_headers( + &self, + req: &RouterData, + _connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + let mut header = vec![( + headers::CONTENT_TYPE.to_string(), + self.get_content_type().to_string().into(), + )]; + let mut api_key = self.get_auth_header(&req.connector_auth_type)?; + header.append(&mut api_key); + Ok(header) + } +} + +impl ConnectorCommon for Amazonpay { + fn id(&self) -> &'static str { + "amazonpay" + } + + fn get_currency_unit(&self) -> api::CurrencyUnit { + api::CurrencyUnit::Base + // todo!() + // TODO! Check connector documentation, on which unit they are processing the currency. + // If the connector accepts amount in lower unit ( i.e cents for USD) then return api::CurrencyUnit::Minor, + // if connector accepts amount in base unit (i.e dollars for USD) then return api::CurrencyUnit::Base + } + + fn common_get_content_type(&self) -> &'static str { + "application/json" + } + + fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str { + connectors.amazonpay.base_url.as_ref() + } + + fn get_auth_header( + &self, + auth_type: &ConnectorAuthType, + ) -> CustomResult)>, errors::ConnectorError> { + let auth = amazonpay::AmazonpayAuthType::try_from(auth_type) + .change_context(errors::ConnectorError::FailedToObtainAuthType)?; + Ok(vec![( + headers::AUTHORIZATION.to_string(), + auth.api_key.expose().into_masked(), + )]) + } + + fn build_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + let response: amazonpay::AmazonpayErrorResponse = res + .response + .parse_struct("AmazonpayErrorResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + + event_builder.map(|i| i.set_response_body(&response)); + router_env::logger::info!(connector_response=?response); + + Ok(ErrorResponse { + status_code: res.status_code, + code: response.code, + message: response.message, + reason: response.reason, + attempt_status: None, + connector_transaction_id: None, + }) + } +} + +impl ConnectorValidation for Amazonpay { + //TODO: implement functions when support enabled +} + +impl ConnectorIntegration for Amazonpay { + //TODO: implement sessions flow +} + +impl ConnectorIntegration for Amazonpay {} + +impl ConnectorIntegration + for Amazonpay +{ +} + +impl ConnectorIntegration for Amazonpay { + fn get_headers( + &self, + req: &PaymentsAuthorizeRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + self.build_headers(req, connectors) + } + + fn get_content_type(&self) -> &'static str { + self.common_get_content_type() + } + + fn get_url( + &self, + _req: &PaymentsAuthorizeRouterData, + _connectors: &Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn get_request_body( + &self, + req: &PaymentsAuthorizeRouterData, + _connectors: &Connectors, + ) -> CustomResult { + let amount = utils::convert_amount( + self.amount_converter, + req.request.minor_amount, + req.request.currency, + )?; + + let connector_router_data = amazonpay::AmazonpayRouterData::from((amount, req)); + let connector_req = amazonpay::AmazonpayPaymentsRequest::try_from(&connector_router_data)?; + Ok(RequestContent::Json(Box::new(connector_req))) + } + + fn build_request( + &self, + req: &PaymentsAuthorizeRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { + Ok(Some( + RequestBuilder::new() + .method(Method::Post) + .url(&types::PaymentsAuthorizeType::get_url( + self, req, connectors, + )?) + .attach_default_headers() + .headers(types::PaymentsAuthorizeType::get_headers( + self, req, connectors, + )?) + .set_body(types::PaymentsAuthorizeType::get_request_body( + self, req, connectors, + )?) + .build(), + )) + } + + fn handle_response( + &self, + data: &PaymentsAuthorizeRouterData, + event_builder: Option<&mut ConnectorEvent>, + res: Response, + ) -> CustomResult { + let response: amazonpay::AmazonpayPaymentsResponse = res + .response + .parse_struct("Amazonpay PaymentsAuthorizeResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + event_builder.map(|i| i.set_response_body(&response)); + router_env::logger::info!(connector_response=?response); + RouterData::try_from(ResponseRouterData { + response, + data: data.clone(), + http_code: res.status_code, + }) + } + + fn get_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + self.build_error_response(res, event_builder) + } +} + +impl ConnectorIntegration for Amazonpay { + fn get_headers( + &self, + req: &PaymentsSyncRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + self.build_headers(req, connectors) + } + + fn get_content_type(&self) -> &'static str { + self.common_get_content_type() + } + + fn get_url( + &self, + _req: &PaymentsSyncRouterData, + _connectors: &Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn build_request( + &self, + req: &PaymentsSyncRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { + Ok(Some( + RequestBuilder::new() + .method(Method::Get) + .url(&types::PaymentsSyncType::get_url(self, req, connectors)?) + .attach_default_headers() + .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?) + .build(), + )) + } + + fn handle_response( + &self, + data: &PaymentsSyncRouterData, + event_builder: Option<&mut ConnectorEvent>, + res: Response, + ) -> CustomResult { + let response: amazonpay::AmazonpayPaymentsResponse = res + .response + .parse_struct("amazonpay PaymentsSyncResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + event_builder.map(|i| i.set_response_body(&response)); + router_env::logger::info!(connector_response=?response); + RouterData::try_from(ResponseRouterData { + response, + data: data.clone(), + http_code: res.status_code, + }) + } + + fn get_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + self.build_error_response(res, event_builder) + } +} + +impl ConnectorIntegration for Amazonpay { + fn get_headers( + &self, + req: &PaymentsCaptureRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + self.build_headers(req, connectors) + } + + fn get_content_type(&self) -> &'static str { + self.common_get_content_type() + } + + fn get_url( + &self, + _req: &PaymentsCaptureRouterData, + _connectors: &Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn get_request_body( + &self, + _req: &PaymentsCaptureRouterData, + _connectors: &Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into()) + } + + fn build_request( + &self, + req: &PaymentsCaptureRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { + Ok(Some( + RequestBuilder::new() + .method(Method::Post) + .url(&types::PaymentsCaptureType::get_url(self, req, connectors)?) + .attach_default_headers() + .headers(types::PaymentsCaptureType::get_headers( + self, req, connectors, + )?) + .set_body(types::PaymentsCaptureType::get_request_body( + self, req, connectors, + )?) + .build(), + )) + } + + fn handle_response( + &self, + data: &PaymentsCaptureRouterData, + event_builder: Option<&mut ConnectorEvent>, + res: Response, + ) -> CustomResult { + let response: amazonpay::AmazonpayPaymentsResponse = res + .response + .parse_struct("Amazonpay PaymentsCaptureResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + event_builder.map(|i| i.set_response_body(&response)); + router_env::logger::info!(connector_response=?response); + RouterData::try_from(ResponseRouterData { + response, + data: data.clone(), + http_code: res.status_code, + }) + } + + fn get_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + self.build_error_response(res, event_builder) + } +} + +impl ConnectorIntegration for Amazonpay {} + +impl ConnectorIntegration for Amazonpay { + fn get_headers( + &self, + req: &RefundsRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + self.build_headers(req, connectors) + } + + fn get_content_type(&self) -> &'static str { + self.common_get_content_type() + } + + fn get_url( + &self, + _req: &RefundsRouterData, + _connectors: &Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn get_request_body( + &self, + req: &RefundsRouterData, + _connectors: &Connectors, + ) -> CustomResult { + let refund_amount = utils::convert_amount( + self.amount_converter, + req.request.minor_refund_amount, + req.request.currency, + )?; + + let connector_router_data = amazonpay::AmazonpayRouterData::from((refund_amount, req)); + let connector_req = amazonpay::AmazonpayRefundRequest::try_from(&connector_router_data)?; + Ok(RequestContent::Json(Box::new(connector_req))) + } + + fn build_request( + &self, + req: &RefundsRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { + let request = RequestBuilder::new() + .method(Method::Post) + .url(&types::RefundExecuteType::get_url(self, req, connectors)?) + .attach_default_headers() + .headers(types::RefundExecuteType::get_headers( + self, req, connectors, + )?) + .set_body(types::RefundExecuteType::get_request_body( + self, req, connectors, + )?) + .build(); + Ok(Some(request)) + } + + fn handle_response( + &self, + data: &RefundsRouterData, + event_builder: Option<&mut ConnectorEvent>, + res: Response, + ) -> CustomResult, errors::ConnectorError> { + let response: amazonpay::RefundResponse = res + .response + .parse_struct("amazonpay RefundResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + event_builder.map(|i| i.set_response_body(&response)); + router_env::logger::info!(connector_response=?response); + RouterData::try_from(ResponseRouterData { + response, + data: data.clone(), + http_code: res.status_code, + }) + } + + fn get_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + self.build_error_response(res, event_builder) + } +} + +impl ConnectorIntegration for Amazonpay { + fn get_headers( + &self, + req: &RefundSyncRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + self.build_headers(req, connectors) + } + + fn get_content_type(&self) -> &'static str { + self.common_get_content_type() + } + + fn get_url( + &self, + _req: &RefundSyncRouterData, + _connectors: &Connectors, + ) -> CustomResult { + Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) + } + + fn build_request( + &self, + req: &RefundSyncRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { + Ok(Some( + RequestBuilder::new() + .method(Method::Get) + .url(&types::RefundSyncType::get_url(self, req, connectors)?) + .attach_default_headers() + .headers(types::RefundSyncType::get_headers(self, req, connectors)?) + .set_body(types::RefundSyncType::get_request_body( + self, req, connectors, + )?) + .build(), + )) + } + + fn handle_response( + &self, + data: &RefundSyncRouterData, + event_builder: Option<&mut ConnectorEvent>, + res: Response, + ) -> CustomResult { + let response: amazonpay::RefundResponse = res + .response + .parse_struct("amazonpay RefundSyncResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + event_builder.map(|i| i.set_response_body(&response)); + router_env::logger::info!(connector_response=?response); + RouterData::try_from(ResponseRouterData { + response, + data: data.clone(), + http_code: res.status_code, + }) + } + + fn get_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + self.build_error_response(res, event_builder) + } +} + +#[async_trait::async_trait] +impl webhooks::IncomingWebhook for Amazonpay { + fn get_webhook_object_reference_id( + &self, + _request: &webhooks::IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) + } + + fn get_webhook_event_type( + &self, + _request: &webhooks::IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) + } + + fn get_webhook_resource_object( + &self, + _request: &webhooks::IncomingWebhookRequestDetails<'_>, + ) -> CustomResult, errors::ConnectorError> { + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) + } +} diff --git a/crates/hyperswitch_connectors/src/connectors/amazonpay/test.rs b/crates/hyperswitch_connectors/src/connectors/amazonpay/test.rs new file mode 100644 index 000000000000..b002a1997afb --- /dev/null +++ b/crates/hyperswitch_connectors/src/connectors/amazonpay/test.rs @@ -0,0 +1,402 @@ +use masking::Secret; +use router::{ + types::{self, api, storage::enums, +}}; + +use crate::utils::{self, ConnectorActions}; +use test_utils::connector_auth; + +#[derive(Clone, Copy)] +struct AmazonpayTest; +impl ConnectorActions for AmazonpayTest {} +impl utils::Connector for AmazonpayTest { + fn get_data(&self) -> api::ConnectorData { + use router::connector::Amazonpay; + api::ConnectorData { + connector: Box::new(Amazonpay::new()), + connector_name: types::Connector::Amazonpay, + get_token: types::api::GetToken::Connector, + merchant_connector_id: None, + } + } + + fn get_auth_token(&self) -> types::ConnectorAuthType { + utils::to_connector_auth_type( + connector_auth::ConnectorAuthentication::new() + .amazonpay + .expect("Missing connector authentication configuration").into(), + ) + } + + fn get_name(&self) -> String { + "amazonpay".to_string() + } +} + +static CONNECTOR: AmazonpayTest = AmazonpayTest {}; + +fn get_default_payment_info() -> Option { + None +} + +fn payment_method_details() -> Option { + None +} + +// Cards Positive Tests +// Creates a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_only_authorize_payment() { + let response = CONNECTOR + .authorize_payment(payment_method_details(), get_default_payment_info()) + .await + .expect("Authorize payment response"); + assert_eq!(response.status, enums::AttemptStatus::Authorized); +} + +// Captures a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_capture_authorized_payment() { + let response = CONNECTOR + .authorize_and_capture_payment(payment_method_details(), None, get_default_payment_info()) + .await + .expect("Capture payment response"); + assert_eq!(response.status, enums::AttemptStatus::Charged); +} + +// Partially captures a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_partially_capture_authorized_payment() { + let response = CONNECTOR + .authorize_and_capture_payment( + payment_method_details(), + Some(types::PaymentsCaptureData { + amount_to_capture: 50, + ..utils::PaymentCaptureType::default().0 + }), + get_default_payment_info(), + ) + .await + .expect("Capture payment response"); + assert_eq!(response.status, enums::AttemptStatus::Charged); +} + +// Synchronizes a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_sync_authorized_payment() { + let authorize_response = CONNECTOR + .authorize_payment(payment_method_details(), get_default_payment_info()) + .await + .expect("Authorize payment response"); + let txn_id = utils::get_connector_transaction_id(authorize_response.response); + let response = CONNECTOR + .psync_retry_till_status_matches( + enums::AttemptStatus::Authorized, + Some(types::PaymentsSyncData { + connector_transaction_id: types::ResponseId::ConnectorTransactionId( + txn_id.unwrap(), + ), + ..Default::default() + }), + get_default_payment_info(), + ) + .await + .expect("PSync response"); + assert_eq!(response.status, enums::AttemptStatus::Authorized,); +} + +// Voids a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_void_authorized_payment() { + let response = CONNECTOR + .authorize_and_void_payment( + payment_method_details(), + Some(types::PaymentsCancelData { + connector_transaction_id: String::from(""), + cancellation_reason: Some("requested_by_customer".to_string()), + ..Default::default() + }), + get_default_payment_info(), + ) + .await + .expect("Void payment response"); + assert_eq!(response.status, enums::AttemptStatus::Voided); +} + +// Refunds a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_refund_manually_captured_payment() { + let response = CONNECTOR + .capture_payment_and_refund(payment_method_details(), None, None, get_default_payment_info()) + .await + .unwrap(); + assert_eq!( + response.response.unwrap().refund_status, + enums::RefundStatus::Success, + ); +} + +// Partially refunds a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_partially_refund_manually_captured_payment() { + let response = CONNECTOR + .capture_payment_and_refund( + payment_method_details(), + None, + Some(types::RefundsData { + refund_amount: 50, + ..utils::PaymentRefundType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap().refund_status, + enums::RefundStatus::Success, + ); +} + +// Synchronizes a refund using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_sync_manually_captured_refund() { + let refund_response = CONNECTOR + .capture_payment_and_refund(payment_method_details(), None, None, get_default_payment_info()) + .await + .unwrap(); + let response = CONNECTOR + .rsync_retry_till_status_matches( + enums::RefundStatus::Success, + refund_response.response.unwrap().connector_refund_id, + None, + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap().refund_status, + enums::RefundStatus::Success, + ); +} + +// Creates a payment using the automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_make_payment() { + let authorize_response = CONNECTOR.make_payment(payment_method_details(), get_default_payment_info()).await.unwrap(); + assert_eq!(authorize_response.status, enums::AttemptStatus::Charged); +} + +// Synchronizes a payment using the automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_sync_auto_captured_payment() { + let authorize_response = CONNECTOR.make_payment(payment_method_details(), get_default_payment_info()).await.unwrap(); + assert_eq!(authorize_response.status, enums::AttemptStatus::Charged); + let txn_id = utils::get_connector_transaction_id(authorize_response.response); + assert_ne!(txn_id, None, "Empty connector transaction id"); + let response = CONNECTOR + .psync_retry_till_status_matches( + enums::AttemptStatus::Charged, + Some(types::PaymentsSyncData { + connector_transaction_id: types::ResponseId::ConnectorTransactionId( + txn_id.unwrap(), + ), + capture_method: Some(enums::CaptureMethod::Automatic), + ..Default::default() + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!(response.status, enums::AttemptStatus::Charged,); +} + +// Refunds a payment using the automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_refund_auto_captured_payment() { + let response = CONNECTOR + .make_payment_and_refund(payment_method_details(), None, get_default_payment_info()) + .await + .unwrap(); + assert_eq!( + response.response.unwrap().refund_status, + enums::RefundStatus::Success, + ); +} + +// Partially refunds a payment using the automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_partially_refund_succeeded_payment() { + let refund_response = CONNECTOR + .make_payment_and_refund( + payment_method_details(), + Some(types::RefundsData { + refund_amount: 50, + ..utils::PaymentRefundType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + refund_response.response.unwrap().refund_status, + enums::RefundStatus::Success, + ); +} + +// Creates multiple refunds against a payment using the automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_refund_succeeded_payment_multiple_times() { + CONNECTOR + .make_payment_and_multiple_refund( + payment_method_details(), + Some(types::RefundsData { + refund_amount: 50, + ..utils::PaymentRefundType::default().0 + }), + get_default_payment_info(), + ) + .await; +} + +// Synchronizes a refund using the automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_sync_refund() { + let refund_response = CONNECTOR + .make_payment_and_refund(payment_method_details(), None, get_default_payment_info()) + .await + .unwrap(); + let response = CONNECTOR + .rsync_retry_till_status_matches( + enums::RefundStatus::Success, + refund_response.response.unwrap().connector_refund_id, + None, + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap().refund_status, + enums::RefundStatus::Success, + ); +} + +// Cards Negative scenarios +// Creates a payment with incorrect CVC. +#[actix_web::test] +async fn should_fail_payment_for_incorrect_cvc() { + let response = CONNECTOR + .make_payment( + Some(types::PaymentsAuthorizeData { + payment_method_data: types::api::PaymentMethodData::Card(api::Card { + card_cvc: Secret::new("12345".to_string()), + ..utils::CCardType::default().0 + }), + ..utils::PaymentAuthorizeType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap_err().message, + "Your card's security code is invalid.".to_string(), + ); +} + +// Creates a payment with incorrect expiry month. +#[actix_web::test] +async fn should_fail_payment_for_invalid_exp_month() { + let response = CONNECTOR + .make_payment( + Some(types::PaymentsAuthorizeData { + payment_method_data: api::PaymentMethodData::Card(api::Card { + card_exp_month: Secret::new("20".to_string()), + ..utils::CCardType::default().0 + }), + ..utils::PaymentAuthorizeType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap_err().message, + "Your card's expiration month is invalid.".to_string(), + ); +} + +// Creates a payment with incorrect expiry year. +#[actix_web::test] +async fn should_fail_payment_for_incorrect_expiry_year() { + let response = CONNECTOR + .make_payment( + Some(types::PaymentsAuthorizeData { + payment_method_data: api::PaymentMethodData::Card(api::Card { + card_exp_year: Secret::new("2000".to_string()), + ..utils::CCardType::default().0 + }), + ..utils::PaymentAuthorizeType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap_err().message, + "Your card's expiration year is invalid.".to_string(), + ); +} + +// Voids a payment using automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_fail_void_payment_for_auto_capture() { + let authorize_response = CONNECTOR.make_payment(payment_method_details(), get_default_payment_info()).await.unwrap(); + assert_eq!(authorize_response.status, enums::AttemptStatus::Charged); + let txn_id = utils::get_connector_transaction_id(authorize_response.response); + assert_ne!(txn_id, None, "Empty connector transaction id"); + let void_response = CONNECTOR + .void_payment(txn_id.unwrap(), None, get_default_payment_info()) + .await + .unwrap(); + assert_eq!( + void_response.response.unwrap_err().message, + "You cannot cancel this PaymentIntent because it has a status of succeeded." + ); +} + +// Captures a payment using invalid connector payment id. +#[actix_web::test] +async fn should_fail_capture_for_invalid_payment() { + let capture_response = CONNECTOR + .capture_payment("123456789".to_string(), None, get_default_payment_info()) + .await + .unwrap(); + assert_eq!( + capture_response.response.unwrap_err().message, + String::from("No such payment_intent: '123456789'") + ); +} + +// Refunds a payment with refund amount higher than payment amount. +#[actix_web::test] +async fn should_fail_for_refund_amount_higher_than_payment_amount() { + let response = CONNECTOR + .make_payment_and_refund( + payment_method_details(), + Some(types::RefundsData { + refund_amount: 150, + ..utils::PaymentRefundType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap_err().message, + "Refund amount (₹1.50) is greater than charge amount (₹1.00)", + ); +} + +// Connector dependent test cases goes here + +// [#478]: add unit tests for non 3DS, wallets & webhooks in connector tests diff --git a/crates/hyperswitch_connectors/src/connectors/amazonpay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/amazonpay/transformers.rs new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs index 31071bead445..949370fdb53f 100644 --- a/crates/hyperswitch_connectors/src/default_implementations.rs +++ b/crates/hyperswitch_connectors/src/default_implementations.rs @@ -90,6 +90,7 @@ macro_rules! default_imp_for_authorize_session_token { default_imp_for_authorize_session_token!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -143,6 +144,7 @@ macro_rules! default_imp_for_calculate_tax { default_imp_for_calculate_tax!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -196,6 +198,7 @@ macro_rules! default_imp_for_session_update { default_imp_for_session_update!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -250,6 +253,7 @@ macro_rules! default_imp_for_post_session_tokens { default_imp_for_post_session_tokens!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Bitpay, connectors::Billwerk, @@ -305,6 +309,7 @@ macro_rules! default_imp_for_complete_authorize { } default_imp_for_complete_authorize!( + connectors::Amazonpay, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -353,6 +358,7 @@ macro_rules! default_imp_for_incremental_authorization { default_imp_for_incremental_authorization!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -408,6 +414,7 @@ macro_rules! default_imp_for_create_customer { default_imp_for_create_customer!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -463,6 +470,7 @@ macro_rules! default_imp_for_connector_redirect_response { } default_imp_for_connector_redirect_response!( + connectors::Amazonpay, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -512,6 +520,7 @@ macro_rules! default_imp_for_pre_processing_steps{ } default_imp_for_pre_processing_steps!( + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -565,6 +574,7 @@ macro_rules! default_imp_for_post_processing_steps{ default_imp_for_post_processing_steps!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -620,6 +630,7 @@ macro_rules! default_imp_for_approve { default_imp_for_approve!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -675,6 +686,7 @@ macro_rules! default_imp_for_reject { default_imp_for_reject!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -730,6 +742,7 @@ macro_rules! default_imp_for_webhook_source_verification { default_imp_for_webhook_source_verification!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -786,6 +799,7 @@ macro_rules! default_imp_for_accept_dispute { default_imp_for_accept_dispute!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -841,6 +855,7 @@ macro_rules! default_imp_for_submit_evidence { default_imp_for_submit_evidence!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -896,6 +911,7 @@ macro_rules! default_imp_for_defend_dispute { default_imp_for_defend_dispute!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -960,6 +976,7 @@ macro_rules! default_imp_for_file_upload { default_imp_for_file_upload!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1017,6 +1034,7 @@ macro_rules! default_imp_for_payouts_create { #[cfg(feature = "payouts")] default_imp_for_payouts_create!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1074,6 +1092,7 @@ macro_rules! default_imp_for_payouts_retrieve { #[cfg(feature = "payouts")] default_imp_for_payouts_retrieve!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1131,6 +1150,7 @@ macro_rules! default_imp_for_payouts_eligibility { #[cfg(feature = "payouts")] default_imp_for_payouts_eligibility!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1188,6 +1208,7 @@ macro_rules! default_imp_for_payouts_fulfill { #[cfg(feature = "payouts")] default_imp_for_payouts_fulfill!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1245,6 +1266,7 @@ macro_rules! default_imp_for_payouts_cancel { #[cfg(feature = "payouts")] default_imp_for_payouts_cancel!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1302,6 +1324,7 @@ macro_rules! default_imp_for_payouts_quote { #[cfg(feature = "payouts")] default_imp_for_payouts_quote!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1359,6 +1382,7 @@ macro_rules! default_imp_for_payouts_recipient { #[cfg(feature = "payouts")] default_imp_for_payouts_recipient!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1416,6 +1440,7 @@ macro_rules! default_imp_for_payouts_recipient_account { #[cfg(feature = "payouts")] default_imp_for_payouts_recipient_account!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1473,6 +1498,7 @@ macro_rules! default_imp_for_frm_sale { #[cfg(feature = "frm")] default_imp_for_frm_sale!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1530,6 +1556,7 @@ macro_rules! default_imp_for_frm_checkout { #[cfg(feature = "frm")] default_imp_for_frm_checkout!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1587,6 +1614,7 @@ macro_rules! default_imp_for_frm_transaction { #[cfg(feature = "frm")] default_imp_for_frm_transaction!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1644,6 +1672,7 @@ macro_rules! default_imp_for_frm_fulfillment { #[cfg(feature = "frm")] default_imp_for_frm_fulfillment!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1701,6 +1730,7 @@ macro_rules! default_imp_for_frm_record_return { #[cfg(feature = "frm")] default_imp_for_frm_record_return!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1755,6 +1785,7 @@ macro_rules! default_imp_for_revoking_mandates { default_imp_for_revoking_mandates!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, diff --git a/crates/hyperswitch_connectors/src/default_implementations_v2.rs b/crates/hyperswitch_connectors/src/default_implementations_v2.rs index 04af32989338..f3fe09c7e41f 100644 --- a/crates/hyperswitch_connectors/src/default_implementations_v2.rs +++ b/crates/hyperswitch_connectors/src/default_implementations_v2.rs @@ -206,6 +206,7 @@ macro_rules! default_imp_for_new_connector_integration_payment { default_imp_for_new_connector_integration_payment!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -262,6 +263,7 @@ macro_rules! default_imp_for_new_connector_integration_refund { default_imp_for_new_connector_integration_refund!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -313,6 +315,7 @@ macro_rules! default_imp_for_new_connector_integration_connector_access_token { default_imp_for_new_connector_integration_connector_access_token!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -370,6 +373,7 @@ macro_rules! default_imp_for_new_connector_integration_accept_dispute { default_imp_for_new_connector_integration_accept_dispute!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -426,6 +430,7 @@ macro_rules! default_imp_for_new_connector_integration_submit_evidence { default_imp_for_new_connector_integration_submit_evidence!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -482,6 +487,7 @@ macro_rules! default_imp_for_new_connector_integration_defend_dispute { default_imp_for_new_connector_integration_defend_dispute!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -548,6 +554,7 @@ macro_rules! default_imp_for_new_connector_integration_file_upload { default_imp_for_new_connector_integration_file_upload!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -606,6 +613,7 @@ macro_rules! default_imp_for_new_connector_integration_payouts_create { #[cfg(feature = "payouts")] default_imp_for_new_connector_integration_payouts_create!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -664,6 +672,7 @@ macro_rules! default_imp_for_new_connector_integration_payouts_eligibility { #[cfg(feature = "payouts")] default_imp_for_new_connector_integration_payouts_eligibility!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -722,6 +731,7 @@ macro_rules! default_imp_for_new_connector_integration_payouts_fulfill { #[cfg(feature = "payouts")] default_imp_for_new_connector_integration_payouts_fulfill!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -780,6 +790,7 @@ macro_rules! default_imp_for_new_connector_integration_payouts_cancel { #[cfg(feature = "payouts")] default_imp_for_new_connector_integration_payouts_cancel!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -838,6 +849,7 @@ macro_rules! default_imp_for_new_connector_integration_payouts_quote { #[cfg(feature = "payouts")] default_imp_for_new_connector_integration_payouts_quote!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -896,6 +908,7 @@ macro_rules! default_imp_for_new_connector_integration_payouts_recipient { #[cfg(feature = "payouts")] default_imp_for_new_connector_integration_payouts_recipient!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -954,6 +967,7 @@ macro_rules! default_imp_for_new_connector_integration_payouts_sync { #[cfg(feature = "payouts")] default_imp_for_new_connector_integration_payouts_sync!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1012,6 +1026,7 @@ macro_rules! default_imp_for_new_connector_integration_payouts_recipient_account #[cfg(feature = "payouts")] default_imp_for_new_connector_integration_payouts_recipient_account!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1068,6 +1083,7 @@ macro_rules! default_imp_for_new_connector_integration_webhook_source_verificati default_imp_for_new_connector_integration_webhook_source_verification!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1126,6 +1142,7 @@ macro_rules! default_imp_for_new_connector_integration_frm_sale { #[cfg(feature = "frm")] default_imp_for_new_connector_integration_frm_sale!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1184,6 +1201,7 @@ macro_rules! default_imp_for_new_connector_integration_frm_checkout { #[cfg(feature = "frm")] default_imp_for_new_connector_integration_frm_checkout!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1242,6 +1260,7 @@ macro_rules! default_imp_for_new_connector_integration_frm_transaction { #[cfg(feature = "frm")] default_imp_for_new_connector_integration_frm_transaction!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1300,6 +1319,7 @@ macro_rules! default_imp_for_new_connector_integration_frm_fulfillment { #[cfg(feature = "frm")] default_imp_for_new_connector_integration_frm_fulfillment!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1358,6 +1378,7 @@ macro_rules! default_imp_for_new_connector_integration_frm_record_return { #[cfg(feature = "frm")] default_imp_for_new_connector_integration_frm_record_return!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, @@ -1413,6 +1434,7 @@ macro_rules! default_imp_for_new_connector_integration_revoking_mandates { default_imp_for_new_connector_integration_revoking_mandates!( connectors::Airwallex, + connectors::Amazonpay, connectors::Bambora, connectors::Billwerk, connectors::Bitpay, diff --git a/crates/hyperswitch_interfaces/src/configs.rs b/crates/hyperswitch_interfaces/src/configs.rs index fd09251699be..fd34d2fda481 100644 --- a/crates/hyperswitch_interfaces/src/configs.rs +++ b/crates/hyperswitch_interfaces/src/configs.rs @@ -13,6 +13,7 @@ pub struct Connectors { pub adyen: AdyenParamsWithThreeBaseUrls, pub adyenplatform: ConnectorParams, pub airwallex: ConnectorParams, + pub amazonpay: ConnectorParams, pub applepay: ConnectorParams, pub authorizedotnet: ConnectorParams, pub bambora: ConnectorParams, diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rs index 899e5f2b15c2..e490ac370377 100644 --- a/crates/router/src/connector.rs +++ b/crates/router/src/connector.rs @@ -45,7 +45,7 @@ pub mod wellsfargopayout; pub mod wise; pub use hyperswitch_connectors::connectors::{ - airwallex, airwallex::Airwallex, bambora, bambora::Bambora, billwerk, billwerk::Billwerk, + airwallex, airwallex::Airwallex, amazonpay, amazonpay::Amazonpay, bambora, bambora::Bambora, billwerk, billwerk::Billwerk, bitpay, bitpay::Bitpay, cashtocode, cashtocode::Cashtocode, coinbase, coinbase::Coinbase, cryptopay, cryptopay::Cryptopay, deutschebank, deutschebank::Deutschebank, digitalvirgo, digitalvirgo::Digitalvirgo, dlocal, dlocal::Dlocal, elavon, elavon::Elavon, fiserv, @@ -62,14 +62,15 @@ pub use hyperswitch_connectors::connectors::{ #[cfg(feature = "dummy_connector")] pub use self::dummyconnector::DummyConnector; pub use self::{ - aci::Aci, adyen::Adyen, adyenplatform::Adyenplatform, authorizedotnet::Authorizedotnet, - bamboraapac::Bamboraapac, bankofamerica::Bankofamerica, bluesnap::Bluesnap, boku::Boku, - braintree::Braintree, checkout::Checkout, cybersource::Cybersource, datatrans::Datatrans, - ebanx::Ebanx, globalpay::Globalpay, gocardless::Gocardless, gpayments::Gpayments, - iatapay::Iatapay, itaubank::Itaubank, klarna::Klarna, mifinity::Mifinity, netcetera::Netcetera, - nmi::Nmi, noon::Noon, nuvei::Nuvei, opayo::Opayo, opennode::Opennode, paybox::Paybox, - payme::Payme, payone::Payone, paypal::Paypal, placetopay::Placetopay, plaid::Plaid, - prophetpay::Prophetpay, rapyd::Rapyd, riskified::Riskified, signifyd::Signifyd, stripe::Stripe, - threedsecureio::Threedsecureio, trustpay::Trustpay, wellsfargo::Wellsfargo, - wellsfargopayout::Wellsfargopayout, wise::Wise, + aci::Aci, adyen::Adyen, adyenplatform::Adyenplatform, airwallex::Airwallex, amazonpay::Amazonpay, + authorizedotnet::Authorizedotnet, bamboraapac::Bamboraapac, bankofamerica::Bankofamerica, + bluesnap::Bluesnap, boku::Boku, braintree::Braintree, checkout::Checkout, + cybersource::Cybersource, datatrans::Datatrans, ebanx::Ebanx, globalpay::Globalpay, + gocardless::Gocardless, gpayments::Gpayments, iatapay::Iatapay, itaubank::Itaubank, + klarna::Klarna, mifinity::Mifinity, multisafepay::Multisafepay, netcetera::Netcetera, nmi::Nmi, + noon::Noon, nuvei::Nuvei, opayo::Opayo, opennode::Opennode, paybox::Paybox, payme::Payme, + payone::Payone, paypal::Paypal, placetopay::Placetopay, plaid::Plaid, prophetpay::Prophetpay, + rapyd::Rapyd, razorpay::Razorpay, riskified::Riskified, shift4::Shift4, signifyd::Signifyd, + stripe::Stripe, threedsecureio::Threedsecureio, trustpay::Trustpay, wellsfargo::Wellsfargo, + wellsfargopayout::Wellsfargopayout, wise::Wise, worldpay::Worldpay, zsl::Zsl, }; diff --git a/crates/router/src/core/payments/connector_integration_v2_impls.rs b/crates/router/src/core/payments/connector_integration_v2_impls.rs index 6ec9cd7c9321..088dd0b5e370 100644 --- a/crates/router/src/core/payments/connector_integration_v2_impls.rs +++ b/crates/router/src/core/payments/connector_integration_v2_impls.rs @@ -1111,6 +1111,7 @@ default_imp_for_new_connector_integration_payouts!( connector::Adyen, connector::Adyenplatform, connector::Airwallex, + connector::Amazonpay, connector::Authorizedotnet, connector::Bambora, connector::Bamboraapac, @@ -1755,6 +1756,7 @@ default_imp_for_new_connector_integration_frm!( connector::Adyen, connector::Adyenplatform, connector::Airwallex, + connector::Amazonpay, connector::Authorizedotnet, connector::Bambora, connector::Bamboraapac, @@ -2247,6 +2249,7 @@ default_imp_for_new_connector_integration_connector_authentication!( connector::Adyen, connector::Adyenplatform, connector::Airwallex, + connector::Amazonpay, connector::Authorizedotnet, connector::Bambora, connector::Bamboraapac, diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs index 5597ef413899..32187f938dfd 100644 --- a/crates/router/src/core/payments/flows.rs +++ b/crates/router/src/core/payments/flows.rs @@ -452,6 +452,7 @@ default_imp_for_connector_request_id!( connector::Aci, connector::Adyen, connector::Airwallex, + connector::Amazonpay, connector::Authorizedotnet, connector::Bambora, connector::Bamboraapac, @@ -977,6 +978,7 @@ impl api::Payouts for connector::DummyConnector {} default_imp_for_payouts!( connector::Aci, connector::Airwallex, + connector::Amazonpay, connector::Authorizedotnet, connector::Bambora, connector::Bamboraapac, @@ -1770,6 +1772,7 @@ default_imp_for_fraud_check!( connector::Aci, connector::Adyen, connector::Airwallex, + connector::Amazonpay, connector::Authorizedotnet, connector::Bambora, connector::Bamboraapac, @@ -2431,6 +2434,7 @@ default_imp_for_connector_authentication!( connector::Aci, connector::Adyen, connector::Airwallex, + connector::Amazonpay, connector::Authorizedotnet, connector::Bambora, connector::Bamboraapac, diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index 428506d6c8ab..3e86c36d57b2 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -324,8 +324,12 @@ impl ConnectorData { connector::Adyenplatform::new(), ))), enums::Connector::Airwallex => { + enums::Connector::Amazonpay => Ok(ConnectorEnum::Old(Box::new(connector::Amazonpay))), Ok(ConnectorEnum::Old(Box::new(&connector::Airwallex))) } + // enums::Connector::Amazonpay => { + // Ok(ConnectorEnum::Old(Box::new(connector::Amazonpay))) + // } enums::Connector::Authorizedotnet => { Ok(ConnectorEnum::Old(Box::new(&connector::Authorizedotnet))) } diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs index 8e5f0944997c..c7772934c200 100644 --- a/crates/router/src/types/transformers.rs +++ b/crates/router/src/types/transformers.rs @@ -247,6 +247,7 @@ impl ForeignTryFrom for common_enums::RoutableConnectors { api_enums::Connector::Adyen => Self::Adyen, api_enums::Connector::Adyenplatform => Self::Adyenplatform, api_enums::Connector::Airwallex => Self::Airwallex, + // api_enums::Connector::Amazonpay => Self::Amazonpay, api_enums::Connector::Authorizedotnet => Self::Authorizedotnet, api_enums::Connector::Bambora => Self::Bambora, api_enums::Connector::Bamboraapac => Self::Bamboraapac, diff --git a/crates/router/tests/connectors/amazonpay.rs b/crates/router/tests/connectors/amazonpay.rs new file mode 100644 index 000000000000..85fddf36c591 --- /dev/null +++ b/crates/router/tests/connectors/amazonpay.rs @@ -0,0 +1,420 @@ +use masking::Secret; +use router::types::{self, api, storage::enums}; +use test_utils::connector_auth; + +use crate::utils::{self, ConnectorActions}; + +#[derive(Clone, Copy)] +struct AmazonpayTest; +impl ConnectorActions for AmazonpayTest {} +impl utils::Connector for AmazonpayTest { + fn get_data(&self) -> api::ConnectorData { + use router::connector::Amazonpay; + api::ConnectorData { + connector: Box::new(Amazonpay::new()), + connector_name: types::Connector::Amazonpay, + get_token: types::api::GetToken::Connector, + merchant_connector_id: None, + } + } + + fn get_auth_token(&self) -> types::ConnectorAuthType { + utils::to_connector_auth_type( + connector_auth::ConnectorAuthentication::new() + .amazonpay + .expect("Missing connector authentication configuration") + .into(), + ) + } + + fn get_name(&self) -> String { + "amazonpay".to_string() + } +} + +static CONNECTOR: AmazonpayTest = AmazonpayTest {}; + +fn get_default_payment_info() -> Option { + None +} + +fn payment_method_details() -> Option { + None +} + +// Cards Positive Tests +// Creates a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_only_authorize_payment() { + let response = CONNECTOR + .authorize_payment(payment_method_details(), get_default_payment_info()) + .await + .expect("Authorize payment response"); + assert_eq!(response.status, enums::AttemptStatus::Authorized); +} + +// Captures a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_capture_authorized_payment() { + let response = CONNECTOR + .authorize_and_capture_payment(payment_method_details(), None, get_default_payment_info()) + .await + .expect("Capture payment response"); + assert_eq!(response.status, enums::AttemptStatus::Charged); +} + +// Partially captures a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_partially_capture_authorized_payment() { + let response = CONNECTOR + .authorize_and_capture_payment( + payment_method_details(), + Some(types::PaymentsCaptureData { + amount_to_capture: 50, + ..utils::PaymentCaptureType::default().0 + }), + get_default_payment_info(), + ) + .await + .expect("Capture payment response"); + assert_eq!(response.status, enums::AttemptStatus::Charged); +} + +// Synchronizes a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_sync_authorized_payment() { + let authorize_response = CONNECTOR + .authorize_payment(payment_method_details(), get_default_payment_info()) + .await + .expect("Authorize payment response"); + let txn_id = utils::get_connector_transaction_id(authorize_response.response); + let response = CONNECTOR + .psync_retry_till_status_matches( + enums::AttemptStatus::Authorized, + Some(types::PaymentsSyncData { + connector_transaction_id: types::ResponseId::ConnectorTransactionId( + txn_id.unwrap(), + ), + ..Default::default() + }), + get_default_payment_info(), + ) + .await + .expect("PSync response"); + assert_eq!(response.status, enums::AttemptStatus::Authorized,); +} + +// Voids a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_void_authorized_payment() { + let response = CONNECTOR + .authorize_and_void_payment( + payment_method_details(), + Some(types::PaymentsCancelData { + connector_transaction_id: String::from(""), + cancellation_reason: Some("requested_by_customer".to_string()), + ..Default::default() + }), + get_default_payment_info(), + ) + .await + .expect("Void payment response"); + assert_eq!(response.status, enums::AttemptStatus::Voided); +} + +// Refunds a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_refund_manually_captured_payment() { + let response = CONNECTOR + .capture_payment_and_refund( + payment_method_details(), + None, + None, + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap().refund_status, + enums::RefundStatus::Success, + ); +} + +// Partially refunds a payment using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_partially_refund_manually_captured_payment() { + let response = CONNECTOR + .capture_payment_and_refund( + payment_method_details(), + None, + Some(types::RefundsData { + refund_amount: 50, + ..utils::PaymentRefundType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap().refund_status, + enums::RefundStatus::Success, + ); +} + +// Synchronizes a refund using the manual capture flow (Non 3DS). +#[actix_web::test] +async fn should_sync_manually_captured_refund() { + let refund_response = CONNECTOR + .capture_payment_and_refund( + payment_method_details(), + None, + None, + get_default_payment_info(), + ) + .await + .unwrap(); + let response = CONNECTOR + .rsync_retry_till_status_matches( + enums::RefundStatus::Success, + refund_response.response.unwrap().connector_refund_id, + None, + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap().refund_status, + enums::RefundStatus::Success, + ); +} + +// Creates a payment using the automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_make_payment() { + let authorize_response = CONNECTOR + .make_payment(payment_method_details(), get_default_payment_info()) + .await + .unwrap(); + assert_eq!(authorize_response.status, enums::AttemptStatus::Charged); +} + +// Synchronizes a payment using the automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_sync_auto_captured_payment() { + let authorize_response = CONNECTOR + .make_payment(payment_method_details(), get_default_payment_info()) + .await + .unwrap(); + assert_eq!(authorize_response.status, enums::AttemptStatus::Charged); + let txn_id = utils::get_connector_transaction_id(authorize_response.response); + assert_ne!(txn_id, None, "Empty connector transaction id"); + let response = CONNECTOR + .psync_retry_till_status_matches( + enums::AttemptStatus::Charged, + Some(types::PaymentsSyncData { + connector_transaction_id: types::ResponseId::ConnectorTransactionId( + txn_id.unwrap(), + ), + capture_method: Some(enums::CaptureMethod::Automatic), + ..Default::default() + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!(response.status, enums::AttemptStatus::Charged,); +} + +// Refunds a payment using the automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_refund_auto_captured_payment() { + let response = CONNECTOR + .make_payment_and_refund(payment_method_details(), None, get_default_payment_info()) + .await + .unwrap(); + assert_eq!( + response.response.unwrap().refund_status, + enums::RefundStatus::Success, + ); +} + +// Partially refunds a payment using the automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_partially_refund_succeeded_payment() { + let refund_response = CONNECTOR + .make_payment_and_refund( + payment_method_details(), + Some(types::RefundsData { + refund_amount: 50, + ..utils::PaymentRefundType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + refund_response.response.unwrap().refund_status, + enums::RefundStatus::Success, + ); +} + +// Creates multiple refunds against a payment using the automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_refund_succeeded_payment_multiple_times() { + CONNECTOR + .make_payment_and_multiple_refund( + payment_method_details(), + Some(types::RefundsData { + refund_amount: 50, + ..utils::PaymentRefundType::default().0 + }), + get_default_payment_info(), + ) + .await; +} + +// Synchronizes a refund using the automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_sync_refund() { + let refund_response = CONNECTOR + .make_payment_and_refund(payment_method_details(), None, get_default_payment_info()) + .await + .unwrap(); + let response = CONNECTOR + .rsync_retry_till_status_matches( + enums::RefundStatus::Success, + refund_response.response.unwrap().connector_refund_id, + None, + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap().refund_status, + enums::RefundStatus::Success, + ); +} + +// Cards Negative scenarios +// Creates a payment with incorrect CVC. +#[actix_web::test] +async fn should_fail_payment_for_incorrect_cvc() { + let response = CONNECTOR + .make_payment( + Some(types::PaymentsAuthorizeData { + payment_method_data: types::api::PaymentMethodData::Card(api::Card { + card_cvc: Secret::new("12345".to_string()), + ..utils::CCardType::default().0 + }), + ..utils::PaymentAuthorizeType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap_err().message, + "Your card's security code is invalid.".to_string(), + ); +} + +// Creates a payment with incorrect expiry month. +#[actix_web::test] +async fn should_fail_payment_for_invalid_exp_month() { + let response = CONNECTOR + .make_payment( + Some(types::PaymentsAuthorizeData { + payment_method_data: api::PaymentMethodData::Card(api::Card { + card_exp_month: Secret::new("20".to_string()), + ..utils::CCardType::default().0 + }), + ..utils::PaymentAuthorizeType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap_err().message, + "Your card's expiration month is invalid.".to_string(), + ); +} + +// Creates a payment with incorrect expiry year. +#[actix_web::test] +async fn should_fail_payment_for_incorrect_expiry_year() { + let response = CONNECTOR + .make_payment( + Some(types::PaymentsAuthorizeData { + payment_method_data: api::PaymentMethodData::Card(api::Card { + card_exp_year: Secret::new("2000".to_string()), + ..utils::CCardType::default().0 + }), + ..utils::PaymentAuthorizeType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap_err().message, + "Your card's expiration year is invalid.".to_string(), + ); +} + +// Voids a payment using automatic capture flow (Non 3DS). +#[actix_web::test] +async fn should_fail_void_payment_for_auto_capture() { + let authorize_response = CONNECTOR + .make_payment(payment_method_details(), get_default_payment_info()) + .await + .unwrap(); + assert_eq!(authorize_response.status, enums::AttemptStatus::Charged); + let txn_id = utils::get_connector_transaction_id(authorize_response.response); + assert_ne!(txn_id, None, "Empty connector transaction id"); + let void_response = CONNECTOR + .void_payment(txn_id.unwrap(), None, get_default_payment_info()) + .await + .unwrap(); + assert_eq!( + void_response.response.unwrap_err().message, + "You cannot cancel this PaymentIntent because it has a status of succeeded." + ); +} + +// Captures a payment using invalid connector payment id. +#[actix_web::test] +async fn should_fail_capture_for_invalid_payment() { + let capture_response = CONNECTOR + .capture_payment("123456789".to_string(), None, get_default_payment_info()) + .await + .unwrap(); + assert_eq!( + capture_response.response.unwrap_err().message, + String::from("No such payment_intent: '123456789'") + ); +} + +// Refunds a payment with refund amount higher than payment amount. +#[actix_web::test] +async fn should_fail_for_refund_amount_higher_than_payment_amount() { + let response = CONNECTOR + .make_payment_and_refund( + payment_method_details(), + Some(types::RefundsData { + refund_amount: 150, + ..utils::PaymentRefundType::default().0 + }), + get_default_payment_info(), + ) + .await + .unwrap(); + assert_eq!( + response.response.unwrap_err().message, + "Refund amount (₹1.50) is greater than charge amount (₹1.00)", + ); +} + +// Connector dependent test cases goes here + +// [#478]: add unit tests for non 3DS, wallets & webhooks in connector tests diff --git a/crates/router/tests/connectors/main.rs b/crates/router/tests/connectors/main.rs index 24d1de432f95..ec898f22f075 100644 --- a/crates/router/tests/connectors/main.rs +++ b/crates/router/tests/connectors/main.rs @@ -10,6 +10,7 @@ mod aci; mod adyen; mod adyenplatform; mod airwallex; +mod amazonpay; mod authorizedotnet; mod bambora; mod bamboraapac; diff --git a/crates/router/tests/connectors/sample_auth.toml b/crates/router/tests/connectors/sample_auth.toml index 6ec2ec5a1dcf..d82b07c85c6d 100644 --- a/crates/router/tests/connectors/sample_auth.toml +++ b/crates/router/tests/connectors/sample_auth.toml @@ -10,6 +10,9 @@ api_key = "Bearer MyApiKey" key1 = "MerchantId" api_secret = "Secondary key" +[amazonpay] +api_key = "API Key" + [authorizedotnet] api_key = "MyMerchantName" key1 = "MyTransactionKey" diff --git a/crates/test_utils/src/connector_auth.rs b/crates/test_utils/src/connector_auth.rs index 08aa09599ca4..e7094c1a7926 100644 --- a/crates/test_utils/src/connector_auth.rs +++ b/crates/test_utils/src/connector_auth.rs @@ -17,6 +17,7 @@ pub struct ConnectorAuthentication { #[cfg(feature = "payouts")] pub adyen_uk: Option, pub airwallex: Option, + pub amazonpay: Option, pub authorizedotnet: Option, pub bambora: Option, pub bamboraapac: Option, diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml index be7d71314ac7..5317021e0433 100644 --- a/loadtest/config/development.toml +++ b/loadtest/config/development.toml @@ -78,6 +78,7 @@ adyenplatform.base_url = "https://balanceplatform-api-test.adyen.com/" adyen.payout_base_url = "https://pal-test.adyen.com/" adyen.dispute_base_url = "https://ca-test.adyen.com/" airwallex.base_url = "https://api-demo.airwallex.com/" +amazonpay.base_url = "https://pay-api.amazon.com/v2" applepay.base_url = "https://apple-pay-gateway.apple.com/" authorizedotnet.base_url = "https://apitest.authorize.net/xml/v1/request.api" bambora.base_url = "https://api.na.bambora.com" @@ -179,6 +180,7 @@ cards = [ "adyen", "adyenplatform", "airwallex", + "amazonpay", "authorizedotnet", "bambora", "bamboraapac", diff --git a/scripts/add_connector.sh b/scripts/add_connector.sh index f7609ff92922..28352104dd85 100755 --- a/scripts/add_connector.sh +++ b/scripts/add_connector.sh @@ -6,7 +6,7 @@ function find_prev_connector() { git checkout $self cp $self $self.tmp # Add new connector to existing list and sort it - connectors=(aci adyen adyenplatform airwallex applepay authorizedotnet bambora bamboraapac bankofamerica billwerk bitpay bluesnap boku braintree cashtocode checkout coinbase cryptopay cybersource datatrans deutschebank digitalvirgo dlocal dummyconnector ebanx elavon fiserv fiservemea fiuu forte globalpay globepay gocardless gpayments helcim iatapay itaubank klarna mifinity mollie multisafepay netcetera nexinets nexixpay noon novalnet nuvei opayo opennode paybox payeezy payme payone paypal payu placetopay plaid powertranz prophetpay rapyd razorpay shift4 square stax stripe taxjar threedsecureio thunes trustpay tsys volt wellsfargo wellsfargopayout wise worldline worldpay zsl "$1") + connectors=(aci adyen adyenplatform airwallex amazonpay applepay authorizedotnet bambora bamboraapac bankofamerica billwerk bitpay bluesnap boku braintree cashtocode checkout coinbase cryptopay cybersource datatrans deutschebank digitalvirgo dlocal dummyconnector ebanx elavon fiserv fiservemea fiuu forte globalpay globepay gocardless gpayments helcim iatapay itaubank klarna mifinity mollie multisafepay netcetera nexinets nexixpay noon novalnet nuvei opayo opennode paybox payeezy payme payone paypal payu placetopay plaid powertranz prophetpay rapyd razorpay shift4 square stax stripe taxjar threedsecureio thunes trustpay tsys volt wellsfargo wellsfargopayout wise worldline worldpay zsl "$1") IFS=$'\n' sorted=($(sort <<<"${connectors[*]}")); unset IFS res="$(echo ${sorted[@]})" sed -i'' -e "s/^ connectors=.*/ connectors=($res \"\$1\")/" $self.tmp