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
fix(connector): [Paypal] Fix payment status for PayPal cards (#1749)
Prasunna Soppa88b4b9679d6d
diff --git a/config/config.example.toml b/config/config.example.tomlindex 7f32d23783..13b6a677a0 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -182,7 +182,7 @@ opayo.base_url = "https://pi-test.sagepay.com/"opennode.base_url = "https://dev-api.opennode.com"payeezy.base_url = "https://api-cert.payeezy.com/"payme.base_url = "https://sandbox.payme.io/"-paypal.base_url = "https://www.sandbox.paypal.com/"+paypal.base_url = "https://api-m.sandbox.paypal.com/"payu.base_url = "https://secure.snd.payu.com/"powertranz.base_url = "https://staging.ptranz.com/api/"rapyd.base_url = "https://sandboxapi.rapyd.net"diff --git a/config/development.toml b/config/development.tomlindex 1c6864b5ca..b0e0bcc20c 100644--- a/config/development.toml+++ b/config/development.toml@@ -145,7 +145,7 @@ opayo.base_url = "https://pi-test.sagepay.com/"opennode.base_url = "https://dev-api.opennode.com"payeezy.base_url = "https://api-cert.payeezy.com/"payme.base_url = "https://sandbox.payme.io/"-paypal.base_url = "https://www.sandbox.paypal.com/"+paypal.base_url = "https://api-m.sandbox.paypal.com/"payu.base_url = "https://secure.snd.payu.com/"powertranz.base_url = "https://staging.ptranz.com/api/"rapyd.base_url = "https://sandboxapi.rapyd.net"diff --git a/config/docker_compose.toml b/config/docker_compose.tomlindex fde85bf21c..18ec15ca73 100644--- a/config/docker_compose.toml+++ b/config/docker_compose.toml@@ -104,7 +104,7 @@ opayo.base_url = "https://pi-test.sagepay.com/"opennode.base_url = "https://dev-api.opennode.com"payeezy.base_url = "https://api-cert.payeezy.com/"payme.base_url = "https://sandbox.payme.io/"-paypal.base_url = "https://www.sandbox.paypal.com/"+paypal.base_url = "https://api-m.sandbox.paypal.com/"payu.base_url = "https://secure.snd.payu.com/"powertranz.base_url = "https://staging.ptranz.com/api/"rapyd.base_url = "https://sandboxapi.rapyd.net"diff --git a/crates/router/src/connector/paypal/transformers.rs b/crates/router/src/connector/paypal/transformers.rsindex 2639b04e49..855199cb3c 100644--- a/crates/router/src/connector/paypal/transformers.rs+++ b/crates/router/src/connector/paypal/transformers.rs@@ -262,7 +262,7 @@ pub struct PaymentsCollectionItem {expiration_time: Option<String>,id: String,final_capture: Option<bool>,- status: PaypalOrderStatus,+ status: PaypalPaymentStatus,}#[derive(Default, Debug, Clone, Serialize, Deserialize)]@@ -376,11 +376,25 @@ impl<F, T>types::ResponseId::NoResponseId,),};- let status = storage_enums::AttemptStatus::foreign_from((- item.response.status,- item.response.intent,- ));-+ //payment collection will always have only one element as we only make one transaction per order.+ let payment_collection = &item+ .response+ .purchase_units+ .first()+ .ok_or(errors::ConnectorError::ResponseDeserializationFailed)?+ .payments;+ //payment collection item will either have "authorizations" field or "capture" field, not both at a time.+ let payment_collection_item = match (+ &payment_collection.authorizations,+ &payment_collection.captures,+ ) {+ (Some(authorizations), None) => authorizations.first(),+ (None, Some(captures)) => captures.first(),+ _ => None,+ }+ .ok_or(errors::ConnectorError::ResponseDeserializationFailed)?;+ let status = payment_collection_item.status.clone();+ let status = storage_enums::AttemptStatus::from(status);Ok(Self {status,response: Ok(types::PaymentsResponseData::TransactionResponse {diff --git a/crates/router/tests/connectors/paypal.rs b/crates/router/tests/connectors/paypal.rsindex 1fbd031314..b177ed4efb 100644--- a/crates/router/tests/connectors/paypal.rs+++ b/crates/router/tests/connectors/paypal.rs@@ -93,7 +93,7 @@ async fn should_capture_authorized_payment() {).await.expect("Capture payment response");- assert_eq!(response.status, enums::AttemptStatus::Charged);+ assert_eq!(response.status, enums::AttemptStatus::Pending);}// Partially captures a payment using the manual capture flow (Non 3DS).@@ -117,7 +117,7 @@ async fn should_partially_capture_authorized_payment() {).await.expect("Capture payment response");- assert_eq!(response.status, enums::AttemptStatus::Charged);+ assert_eq!(response.status, enums::AttemptStatus::Pending);}// Synchronizes a payment using the manual capture flow (Non 3DS).@@ -302,7 +302,7 @@ async fn should_make_payment() {.make_payment(get_payment_data(), get_default_payment_info()).await.unwrap();- assert_eq!(authorize_response.status, enums::AttemptStatus::Charged);+ assert_eq!(authorize_response.status, enums::AttemptStatus::Pending);}// Synchronizes a payment using the automatic capture flow (Non 3DS).@@ -314,7 +314,7 @@ async fn should_sync_auto_captured_payment() {.unwrap();assert_eq!(authorize_response.status.clone(),- enums::AttemptStatus::Charged+ enums::AttemptStatus::Pending);let txn_id = utils::get_connector_transaction_id(authorize_response.response.clone());assert_ne!(txn_id, None, "Empty connector transaction id");@@ -335,7 +335,7 @@ async fn should_sync_auto_captured_payment() {).await.unwrap();- assert_eq!(response.status, enums::AttemptStatus::Charged,);+ assert_eq!(response.status, enums::AttemptStatus::Pending);}// Refunds a payment using the automatic capture flow (Non 3DS).diff --git a/crates/router/tests/connectors/paypal_ui.rs b/crates/router/tests/connectors/paypal_ui.rsindex ccae55d56d..ef999f7aff 100644--- a/crates/router/tests/connectors/paypal_ui.rs+++ b/crates/router/tests/connectors/paypal_ui.rs@@ -22,7 +22,7 @@ async fn should_make_paypal_paypal_wallet_payment(Event::Assert(Assert::IsPresent("How Search works")),Event::Assert(Assert::ContainsAny(Selector::QueryParamStr,- vec!["status=succeeded"],+ vec!["status=processing"],)),],)diff --git a/loadtest/config/development.toml b/loadtest/config/development.tomlindex 7a7354d09a..8b479565c5 100644--- a/loadtest/config/development.toml+++ b/loadtest/config/development.toml@@ -91,7 +91,7 @@ opayo.base_url = "https://pi-test.sagepay.com/"opennode.base_url = "https://dev-api.opennode.com"payeezy.base_url = "https://api-cert.payeezy.com/"payme.base_url = "https://sandbox.payme.io/"-paypal.base_url = "https://www.sandbox.paypal.com/"+paypal.base_url = "https://api-m.sandbox.paypal.com/"payu.base_url = "https://secure.snd.payu.com/"powertranz.base_url = "https://staging.ptranz.com/api/"rapyd.base_url = "https://sandboxapi.rapyd.net"