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(connectors): Amount received should be zero for `pending` and `failed` status (#4331)
Sakil Mostak6aa66c4243fd
diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rsindex 568eab11ff..216f100386 100644--- a/crates/router/src/connector/adyen/transformers.rs+++ b/crates/router/src/connector/adyen/transformers.rs@@ -3952,7 +3952,7 @@ impl TryFrom<types::PaymentsCaptureResponseRouterData<AdyenCaptureResponse>>connector_response_reference_id: Some(item.response.reference),incremental_authorization_allowed: None,}),- amount_captured: Some(item.response.amount.value),+ amount_captured: Some(0),..item.data})}diff --git a/crates/router/src/connector/paypal/transformers.rs b/crates/router/src/connector/paypal/transformers.rsindex e5e4d13dbb..0cc33dbe2d 100644--- a/crates/router/src/connector/paypal/transformers.rs+++ b/crates/router/src/connector/paypal/transformers.rs@@ -1541,8 +1541,35 @@ impl TryFrom<types::PaymentsCaptureResponseRouterData<PaypalCaptureResponse>>fn try_from(item: types::PaymentsCaptureResponseRouterData<PaypalCaptureResponse>,) -> Result<Self, Self::Error> {- let amount_captured = item.data.request.amount_to_capture;let status = storage_enums::AttemptStatus::from(item.response.status);+ let amount_captured = match status {+ storage_enums::AttemptStatus::Pending+ | storage_enums::AttemptStatus::Authorized+ | storage_enums::AttemptStatus::Failure+ | storage_enums::AttemptStatus::RouterDeclined+ | storage_enums::AttemptStatus::AuthenticationFailed+ | storage_enums::AttemptStatus::CaptureFailed+ | storage_enums::AttemptStatus::Started+ | storage_enums::AttemptStatus::AuthenticationPending+ | storage_enums::AttemptStatus::AuthenticationSuccessful+ | storage_enums::AttemptStatus::AuthorizationFailed+ | storage_enums::AttemptStatus::Authorizing+ | storage_enums::AttemptStatus::VoidInitiated+ | storage_enums::AttemptStatus::CodInitiated+ | storage_enums::AttemptStatus::CaptureInitiated+ | storage_enums::AttemptStatus::VoidFailed+ | storage_enums::AttemptStatus::AutoRefunded+ | storage_enums::AttemptStatus::Unresolved+ | storage_enums::AttemptStatus::PaymentMethodAwaited+ | storage_enums::AttemptStatus::ConfirmationAwaited+ | storage_enums::AttemptStatus::DeviceDataCollectionPending+ | storage_enums::AttemptStatus::Voided => 0,+ storage_enums::AttemptStatus::Charged+ | storage_enums::AttemptStatus::PartialCharged+ | storage_enums::AttemptStatus::PartialChargedAndChargeable => {+ item.data.request.amount_to_capture+ }+ };let connector_payment_id: PaypalMeta =to_connector_meta(item.data.request.connector_meta.clone())?;Ok(Self {diff --git a/postman/collection-dir/adyen_uk/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture/Payments - Capture/event.test.js b/postman/collection-dir/adyen_uk/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture/Payments - Capture/event.test.jsindex fa72b8541f..6ae8a3fc0f 100644--- a/postman/collection-dir/adyen_uk/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture/Payments - Capture/event.test.js+++ b/postman/collection-dir/adyen_uk/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture/Payments - Capture/event.test.js@@ -83,12 +83,12 @@ if (jsonData?.amount) {);}-// Response body should have value "6000" for "amount_received"+// Response body should have value "0" for "amount_received"if (jsonData?.amount_received) {pm.test(- "[POST]::/payments:id/capture - Content check if value for 'amount_received' matches '6000'",+ "[POST]::/payments:id/capture - Content check if value for 'amount_received' matches '0'",function () {- pm.expect(jsonData.amount_received).to.eql(6000);+ pm.expect(jsonData.amount_received).to.eql(0);},);}diff --git a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture/Payments - Capture/event.test.js b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture/Payments - Capture/event.test.jsindex 0085a8a114..572f74e6d5 100644--- a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture/Payments - Capture/event.test.js+++ b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario4-Create payment with Manual capture/Payments - Capture/event.test.js@@ -107,3 +107,13 @@ if (jsonData?.amount_capturable) {},);}++// Response body should have value "0" for "amount_received"+if (jsonData?.amount_received) {+ pm.test(+ "[post]:://payments/:id/capture - Content check if value for 'amount_received' matches 0",+ function () {+ pm.expect(jsonData.amount_received).to.eql(0);+ },+ );+}diff --git a/postman/collection-json/adyen_uk.postman_collection.json b/postman/collection-json/adyen_uk.postman_collection.jsonindex 372e9c42c1..dd482b1a3d 100644--- a/postman/collection-json/adyen_uk.postman_collection.json+++ b/postman/collection-json/adyen_uk.postman_collection.json@@ -2688,12 +2688,12 @@" );","}","",- "// Response body should have value \"6000\" for \"amount_received\"",+ "// Response body should have value \"0\" for \"amount_received\"","if (jsonData?.amount_received) {"," pm.test(",- " \"[POST]::/payments:id/capture - Content check if value for 'amount_received' matches '6000'\",",+ " \"[POST]::/payments:id/capture - Content check if value for 'amount_received' matches '0'\","," function () {",- " pm.expect(jsonData.amount_received).to.eql(6000);",+ " pm.expect(jsonData.amount_received).to.eql(0);"," },"," );","}",diff --git a/postman/collection-json/paypal.postman_collection.json b/postman/collection-json/paypal.postman_collection.jsonindex 4587343ce0..dfb52bb4ff 100644--- a/postman/collection-json/paypal.postman_collection.json+++ b/postman/collection-json/paypal.postman_collection.json@@ -3506,6 +3506,16 @@" },"," );","}",+ "",+ "// Response body should have value \"0\" for \"amount_received\"",+ "if (jsonData?.amount_received) {",+ " pm.test(",+ " \"[post]:://payments/:id/capture - Content check if value for 'amount_received' matches 0\",",+ " function () {",+ " pm.expect(jsonData.amount_received).to.eql(0);",+ " },",+ " );",+ "}",""],"type": "text/javascript"