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
test(cypress): add Multiple Capture coverage for adyen and checkout (#12340)
HS-QUALIBOT9f4b75fe8913
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Adyen.js b/cypress-tests/cypress/e2e/configs/Payment/Adyen.jsindex 5e78be1d40..5aafd548a8 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Adyen.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Adyen.js@@ -268,6 +268,65 @@ export const connectorDetails = {},},},+ MultipleCapture: {+ Request: {+ amount_to_capture: 2000,+ },+ Response: {+ status: 200,+ body: {+ status: "processing",+ },+ },+ },+ MultipleCapturePartial: {+ Request: {+ amount_to_capture: 2000,+ },+ Response: {+ status: 200,+ body: {+ status: "processing",+ },+ },+ },+ MultipleCaptureFinal: {+ Request: {+ amount_to_capture: 2000,+ },+ Response: {+ status: 200,+ body: {+ status: "processing",+ },+ },+ },+ MultipleCaptureRetrieve: {+ Response: {+ status: 200,+ body: {+ status: "processing",+ amount: 6000,+ amount_capturable: 0,+ amount_received: 6000,+ },+ },+ },+ MultipleCaptureOvercapture: {+ Request: {+ amount_to_capture: 7000,+ },+ Response: {+ status: 422,+ body: {+ error: {+ type: "invalid_request",+ message: "amount_to_capture is greater than amount",+ code: "IR_06",+ },+ },+ },+ },VoidAfterConfirm: getCustomExchange({Request: {},Response: {diff --git a/cypress-tests/cypress/e2e/configs/Payment/Checkout.js b/cypress-tests/cypress/e2e/configs/Payment/Checkout.jsindex 1e68368c5f..76779859fa 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Checkout.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Checkout.js@@ -259,6 +259,65 @@ export const connectorDetails = {},},},+ MultipleCapture: {+ Request: {+ amount_to_capture: 2000,+ },+ Response: {+ status: 200,+ body: {+ status: "processing",+ },+ },+ },+ MultipleCapturePartial: {+ Request: {+ amount_to_capture: 2000,+ },+ Response: {+ status: 200,+ body: {+ status: "partially_captured_and_capturable",+ },+ },+ },+ MultipleCaptureFinal: {+ Request: {+ amount_to_capture: 2000,+ },+ Response: {+ status: 200,+ body: {+ status: "succeeded",+ },+ },+ },+ MultipleCaptureRetrieve: {+ Response: {+ status: 200,+ body: {+ status: "succeeded",+ amount: 6000,+ amount_capturable: 0,+ amount_received: 6000,+ },+ },+ },+ MultipleCaptureOvercapture: {+ Request: {+ amount_to_capture: 7000,+ },+ Response: {+ status: 422,+ body: {+ error: {+ type: "invalid_request",+ message: "amount_to_capture is greater than amount",+ code: "IR_06",+ },+ },+ },+ },Void: {Request: {},Response: {diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.jsindex aaf64f5722..60d5a6a42d 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js@@ -1679,6 +1679,27 @@ export const connectorDetails = {amount_to_capture: 2000,},}),+ MultipleCapture: getCustomExchange({+ Request: {+ amount_to_capture: 3000,+ },+ }),+ MultipleCapturePartial: getCustomExchange({+ Request: {+ amount_to_capture: 2000,+ },+ }),+ MultipleCaptureFinal: getCustomExchange({+ Request: {+ amount_to_capture: 2000,+ },+ }),+ MultipleCaptureRetrieve: getCustomExchange({}),+ MultipleCaptureOvercapture: getCustomExchange({+ Request: {+ amount_to_capture: 7000,+ },+ }),Void: getCustomExchange({Request: {},Response: {diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.jsindex 0ed410482d..80634d1871 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js@@ -586,6 +586,7 @@ export const CONNECTOR_LISTS = {AUTH_SERVICE_ELIGIBILITY: ["stripe", "cybersource"],STEP_UP_AUTH: ["cybersource"],PARTIAL_AUTH: ["nuvei", "checkout", "worldpay", "worldpayvantiv"],+ MULTIPLE_CAPTURE: ["adyen", "checkout"],USE_BILLING_AS_PAYMENT_METHOD_BILLING: ["bankofamerica"],MIT_WITH_LIMITED_CARD_DATA: ["peachpayments"],PAYMENT_LINK_CARD: ["stripe"],diff --git a/cypress-tests/cypress/e2e/spec/Payment/52-MultipleCapture.cy.js b/cypress-tests/cypress/e2e/spec/Payment/52-MultipleCapture.cy.jsnew file mode 100644index 0000000000..d75d738524--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Payment/52-MultipleCapture.cy.js@@ -0,0 +1,260 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import getConnectorDetails, {+ CONNECTOR_LISTS,+ shouldIncludeConnector,+} from "../../configs/Payment/Utils";+import * as utils from "../../configs/Payment/Utils";++let globalState;+let connector;++describe("Card - Multiple Capture payment flow test", () => {+ before("seed global state", function () {+ let skip = false;++ cy.task("getGlobalState")+ .then((state) => {+ globalState = new State(state);+ connector = globalState.get("connectorId");++ if (+ shouldIncludeConnector(+ connector,+ CONNECTOR_LISTS.INCLUDE.MULTIPLE_CAPTURE+ )+ ) {+ skip = true;+ return;+ }+ })+ .then(() => {+ if (skip) {+ this.skip();+ }+ });+ });++ afterEach("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ context(+ "Card - NoThreeDS Multiple Partial Capture payment flow test - Create and Confirm",+ () => {+ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> First Partial Capture -> Second Partial Capture -> Third Partial Capture -> Retrieve Payment after Multiple Captures", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent with manual_multiple", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "manual_multiple",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Payment Methods Call", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Payment Methods Call");+ return;+ }+ cy.paymentMethodsCallTest(globalState);+ });++ cy.step("Confirm Payment Intent", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const confirmData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["No3DSManualCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ confirmData,+ true,+ globalState+ );++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Confirmation"+ );+ return;+ }+ const confirmData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["No3DSManualCapture"];++ cy.retrievePaymentCallTest({ globalState, data: confirmData });++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("First Partial Capture", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: First Partial Capture");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["MultipleCapturePartial"];++ cy.captureCallTest(fixtures.captureBody, captureData, globalState);++ if (!utils.should_continue_further(captureData)) {+ shouldContinue = false;+ }+ });++ cy.step("Second Partial Capture", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Second Partial Capture");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["MultipleCapturePartial"];++ cy.captureCallTest(fixtures.captureBody, captureData, globalState);++ if (!utils.should_continue_further(captureData)) {+ shouldContinue = false;+ }+ });++ cy.step("Third Partial Capture", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Third Partial Capture");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["MultipleCaptureFinal"];++ cy.captureCallTest(fixtures.captureBody, captureData, globalState);++ if (!utils.should_continue_further(captureData)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Multiple Captures", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Multiple Captures"+ );+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["MultipleCaptureRetrieve"];++ cy.retrievePaymentCallTest({ globalState, data: captureData });+ });+ });+ }+ );++ context("Card - NoThreeDS Multiple Capture with over-capture attempt", () => {+ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> First Partial Capture -> Over-capture Attempt", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent with manual_multiple", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "manual_multiple",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Payment Methods Call", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Payment Methods Call");+ return;+ }+ cy.paymentMethodsCallTest(globalState);+ });++ cy.step("Confirm Payment Intent", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const confirmData = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSManualCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ confirmData,+ true,+ globalState+ );++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("First Partial Capture", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: First Partial Capture");+ return;+ }+ const captureData = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["MultipleCapturePartial"];++ cy.captureCallTest(fixtures.captureBody, captureData, globalState);++ if (!utils.should_continue_further(captureData)) {+ shouldContinue = false;+ }+ });++ cy.step("Over-capture Attempt", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Over-capture Attempt");+ return;+ }+ const overcaptureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["MultipleCaptureOvercapture"];++ cy.captureCallTest(fixtures.captureBody, overcaptureData, globalState);+ });+ });+ });+});diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 2cc218e18a..7f34342d87 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -2860,7 +2860,10 @@ Cypress.Commands.add(`Invalid authentication type ${response.body.authentication_type}`);}- } else if (response.body.capture_method === "manual") {+ } else if (+ response.body.capture_method === "manual" ||+ response.body.capture_method === "manual_multiple"+ ) {if (response.body.authentication_type === "three_ds") {if (response.body.next_action) {if (response.body.next_action.type === "invoke_ddc") {@@ -3068,7 +3071,8 @@ Cypress.Commands.add(case "three_ds":if (response.body.capture_method === "automatic" ||- response.body.capture_method === "manual"+ response.body.capture_method === "manual" ||+ response.body.capture_method === "manual_multiple") {if (response.body.status !== "failed") {// we get many statuses here, hence this verification@@ -3110,7 +3114,8 @@ Cypress.Commands.add(case "no_three_ds":if (response.body.capture_method === "automatic" ||- response.body.capture_method === "manual"+ response.body.capture_method === "manual" ||+ response.body.capture_method === "manual_multiple") {expect(response.body).to.have.property("next_action")@@ -3261,7 +3266,8 @@ Cypress.Commands.add(if (response.body.capture_method === "automatic" ||- response.body.capture_method === "manual"+ response.body.capture_method === "manual" ||+ response.body.capture_method === "manual_multiple") {switch (response.body.payment_method_type) {case "pix":@@ -3381,7 +3387,8 @@ Cypress.Commands.add(if (response.body.capture_method === "automatic" ||- response.body.capture_method === "manual"+ response.body.capture_method === "manual" ||+ response.body.capture_method === "manual_multiple") {if (response.body.payment_method_type === "upi_collect") {expect(response.body)@@ -3553,7 +3560,10 @@ Cypress.Commands.add(`Invalid authentication type: ${response.body.authentication_type}`);}- } else if (response.body.capture_method === "manual") {+ } else if (+ response.body.capture_method === "manual" ||+ response.body.capture_method === "manual_multiple"+ ) {if (response.body.authentication_type === "three_ds") {if (response.body.next_action) {if (response.body.next_action.type === "invoke_ddc") {@@ -3742,7 +3752,10 @@ Cypress.Commands.add(`Invalid authentication type: ${response.body.authentication_type}`);}- } else if (response.body.capture_method === "manual") {+ } else if (+ response.body.capture_method === "manual" ||+ response.body.capture_method === "manual_multiple"+ ) {if (response.body.authentication_type === "three_ds") {expect(response.body).to.have.property("next_action")@@ -3998,7 +4011,10 @@ Cypress.Commands.add(// If capture method is manual, 'processing' status also means 'active'// for the payment method's usability.- if (response.body.capture_method === "manual") {+ if (+ response.body.capture_method === "manual" ||+ response.body.capture_method === "manual_multiple"+ ) {allowedActiveStatuses.push("processing");}@@ -4449,7 +4465,10 @@ Cypress.Commands.add(`Invalid authentication type ${response.body.authentication_type}`);}- } else if (response.body.capture_method === "manual") {+ } else if (+ response.body.capture_method === "manual" ||+ response.body.capture_method === "manual_multiple"+ ) {if (response.body.authentication_type === "three_ds") {if (response.body.status !== "succeeded") {let nextActionUrl = null;@@ -4603,7 +4622,10 @@ Cypress.Commands.add(`Invalid authentication type ${response.body.authentication_type}`);}- } else if (response.body.capture_method === "manual") {+ } else if (+ response.body.capture_method === "manual" ||+ response.body.capture_method === "manual_multiple"+ ) {if (response.body.authentication_type === "three_ds") {expect(response.body).to.have.property("next_action")@@ -4792,7 +4814,10 @@ Cypress.Commands.add(`Invalid authentication type ${response.body.authentication_type}`);}- } else if (response.body.capture_method === "manual") {+ } else if (+ response.body.capture_method === "manual" ||+ response.body.capture_method === "manual_multiple"+ ) {if (response.body.authentication_type === "three_ds") {expect(response.body).to.have.property("next_action")@@ -4887,7 +4912,10 @@ Cypress.Commands.add(`Invalid authentication type ${response.body.authentication_type}`);}- } else if (response.body.capture_method === "manual") {+ } else if (+ response.body.capture_method === "manual" ||+ response.body.capture_method === "manual_multiple"+ ) {if (response.body.authentication_type === "three_ds") {expect(response.body).to.have.property("next_action")@@ -5215,7 +5243,8 @@ Cypress.Commands.add(if (response.body.capture_method === "automatic" ||- response.body.capture_method === "manual"+ response.body.capture_method === "manual" ||+ response.body.capture_method === "manual_multiple") {switch (response.body.payment_method_type) {case "duit_now":@@ -5301,7 +5330,8 @@ Cypress.Commands.add(if (response.body.capture_method === "automatic" ||- response.body.capture_method === "manual"+ response.body.capture_method === "manual" ||+ response.body.capture_method === "manual_multiple") {expect(response.body).to.have.property("next_action")