diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs index e47b570a062f..4431e2a41309 100644 --- a/crates/router/src/connector/adyen/transformers.rs +++ b/crates/router/src/connector/adyen/transformers.rs @@ -3950,7 +3950,7 @@ impl TryFrom> 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.rs index 6a3d396c8358..73da0cc1a911 100644 --- a/crates/router/src/connector/paypal/transformers.rs +++ b/crates/router/src/connector/paypal/transformers.rs @@ -1544,8 +1544,35 @@ impl TryFrom> fn try_from( item: types::PaymentsCaptureResponseRouterData, ) -> Result { - 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.js index fa72b8541ff8..6ae8a3fc0fd6 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.js index 0085a8a1146c..572f74e6d57f 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.json index 372e9c42c17c..dd482b1a3d57 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.json index 4587343ce0ad..dfb52bb4ffcb 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"