Skip to content

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

test(cypress): add capture method auto-fallback coverage for trustpay (#14705)

HS-QUALIBOTd41d8aaf950d
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Cryptopay.js b/cypress-tests/cypress/e2e/configs/Payment/Cryptopay.js
index d1477b9672..2113f87681 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Cryptopay.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Cryptopay.js
@@ -68,6 +68,73 @@ export const connectorDetails = {
},
},
card_pm: {
+ // Auto fallback capture method flow (PR #14452) - cryptopay does not support
+ // manual capture; with auto_fallback_capture_method enabled on the business
+ // profile, manual capture payments fall back to automatic capture.
+ AutoFallbackCaptureMethod: {
+ PaymentIntent: {
+ Request: {
+ currency: "USD",
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ capture_method_applied: null,
+ },
+ },
+ },
+ AutoFallbackDisabled: {
+ Configs: {
+ skipBillingAssertion: true,
+ },
+ Request: {
+ payment_method: "crypto",
+ payment_method_type: "crypto_currency",
+ payment_method_data: {
+ crypto: {
+ network: "bitcoin",
+ pay_currency: "BTC",
+ },
+ },
+ billing: standardBillingAddress,
+ },
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Payment method type not supported",
+ code: "IR_19",
+ reason: "manual is not supported by cryptopay",
+ },
+ },
+ },
+ },
+ AutoFallbackEnabled: {
+ Request: {
+ payment_method: "crypto",
+ payment_method_type: "crypto_currency",
+ payment_method_data: {
+ crypto: {
+ network: "bitcoin",
+ pay_currency: "BTC",
+ },
+ },
+ billing: standardBillingAddress,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ capture_method: "manual",
+ capture_method_applied: "automatic",
+ },
+ },
+ },
+ },
ZeroAuthMandate: {
Request: {
amount: 0,
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Facilitapay.js b/cypress-tests/cypress/e2e/configs/Payment/Facilitapay.js
index 9b4a3b01ac..391045b94a 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Facilitapay.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Facilitapay.js
@@ -21,6 +21,93 @@ const billingAddress = {
export const connectorDetails = {
card_pm: {
+ // Auto fallback capture method flow (PR #14452) - facilitapay does not support
+ // manual capture; with auto_fallback_capture_method enabled on the business
+ // profile, manual capture payments fall back to automatic capture.
+ // Pix in local currency (BRL) settles synchronously, so the confirmed
+ // payment reaches the `succeeded` status without any redirection.
+ AutoFallbackCaptureMethod: {
+ PaymentIntent: {
+ Request: {
+ currency: "BRL",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ capture_method_applied: null,
+ },
+ },
+ },
+ AutoFallbackDisabled: {
+ Configs: {
+ skipBillingAssertion: true,
+ },
+ Request: {
+ payment_method: "bank_transfer",
+ payment_method_type: "pix",
+ payment_method_data: {
+ bank_transfer: {
+ pix: {
+ // since we pass the same cpf number, the connector customer id will be updated instead of new ones being created
+ cpf: "86665623580",
+ source_bank_account_id: "739d6b0a-e92a-40fd-9f58-6d4cdeb699bb",
+ pix_qr_expiry: isoTimeTomorrow(), // 1 day expiration
+ },
+ },
+ },
+ billing: {
+ ...billingAddress,
+ address: {
+ ...billingAddress.address,
+ country: "BR",
+ },
+ },
+ },
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Payment method type not supported",
+ code: "IR_19",
+ reason: "manual is not supported by facilitapay",
+ },
+ },
+ },
+ },
+ AutoFallbackEnabled: {
+ Request: {
+ payment_method: "bank_transfer",
+ payment_method_type: "pix",
+ payment_method_data: {
+ bank_transfer: {
+ pix: {
+ // since we pass the same cpf number, the connector customer id will be updated instead of new ones being created
+ cpf: "86665623580",
+ source_bank_account_id: "739d6b0a-e92a-40fd-9f58-6d4cdeb699bb",
+ pix_qr_expiry: isoTimeTomorrow(), // 1 day expiration
+ },
+ },
+ },
+ billing: {
+ ...billingAddress,
+ address: {
+ ...billingAddress.address,
+ country: "BR",
+ },
+ },
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ capture_method: "manual",
+ capture_method_applied: "automatic",
+ },
+ },
+ },
+ },
ZeroAuthPaymentIntent: {
Request: {
currency: "BRL",
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Iatapay.js b/cypress-tests/cypress/e2e/configs/Payment/Iatapay.js
index aeccce7ec9..c3df564444 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Iatapay.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Iatapay.js
@@ -125,6 +125,73 @@ export const connectorDetails = {
},
},
card_pm: {
+ // Auto fallback capture method flow (PR #14452) - iatapay does not support
+ // manual capture; with auto_fallback_capture_method enabled on the business
+ // profile, manual capture payments fall back to automatic capture.
+ AutoFallbackCaptureMethod: {
+ PaymentIntent: {
+ Request: {
+ currency: "INR",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ capture_method_applied: null,
+ },
+ },
+ },
+ AutoFallbackDisabled: {
+ Configs: {
+ skipBillingAssertion: true,
+ },
+ Request: {
+ payment_method: "upi",
+ payment_method_type: "upi_collect",
+ payment_method_data: {
+ upi: {
+ upi_collect: {
+ vpa_id: "successtest@iata",
+ },
+ },
+ },
+ billing: billingAddress,
+ },
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Payment method type not supported",
+ code: "IR_19",
+ reason: "manual is not supported by iatapay",
+ },
+ },
+ },
+ },
+ AutoFallbackEnabled: {
+ Request: {
+ payment_method: "upi",
+ payment_method_type: "upi_collect",
+ payment_method_data: {
+ upi: {
+ upi_collect: {
+ vpa_id: "successtest@iata",
+ },
+ },
+ },
+ billing: billingAddress,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ capture_method: "manual",
+ capture_method_applied: "automatic",
+ },
+ },
+ },
+ },
ZeroAuthMandate: {
Request: {
amount: 0,
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Placetopay.js b/cypress-tests/cypress/e2e/configs/Payment/Placetopay.js
index a3ed896298..a99a6e6a39 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Placetopay.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Placetopay.js
@@ -49,6 +49,52 @@ const manualCaptureConfirmRequest = {
export const connectorDetails = {
card_pm: {
+ // Auto fallback capture method flow (PR #14452) - placetopay does not
+ // support manual capture; with auto_fallback_capture_method enabled on the
+ // business profile, manual capture payments fall back to automatic capture.
+ AutoFallbackCaptureMethod: {
+ PaymentIntent: {
+ Request: {
+ currency: "COP",
+ description: "placetopay test",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ capture_method_applied: null,
+ },
+ },
+ },
+ AutoFallbackDisabled: {
+ Configs: {
+ skipBillingAssertion: true,
+ },
+ Request: manualCaptureConfirmRequest,
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Payment method type not supported",
+ code: "IR_19",
+ reason: "manual is not supported by placetopay",
+ },
+ },
+ },
+ },
+ AutoFallbackEnabled: {
+ Request: manualCaptureConfirmRequest,
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ capture_method: "manual",
+ capture_method_applied: "automatic",
+ },
+ },
+ },
+ },
PaymentIntent: {
Request: {
currency: "COP",
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Trustpay.js b/cypress-tests/cypress/e2e/configs/Payment/Trustpay.js
index a7da40e102..9fd3b0833b 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Trustpay.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Trustpay.js
@@ -28,6 +28,15 @@ const failedNo3DSCardDetails = {
card_cvc: "123",
};
+// Trustpay test card used for the auto fallback capture method flow (PR #14452)
+const autoFallbackCardDetails = {
+ card_number: "4111111111111111",
+ card_exp_month: "03",
+ card_exp_year: "30",
+ card_holder_name: "John Doe",
+ card_cvc: "737",
+};
+
const singleUseMandateData = {
customer_acceptance: customerAcceptance,
mandate_type: {
@@ -644,6 +653,65 @@ export const connectorDetails = {
},
},
},
+ // Auto fallback capture method flow (PR #14452) - trustpay does not support
+ // manual capture; with auto_fallback_capture_method enabled on the business
+ // profile, manual capture payments fall back to automatic capture.
+ AutoFallbackCaptureMethod: {
+ PaymentIntent: {
+ Request: {
+ currency: "USD",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ capture_method_applied: null,
+ },
+ },
+ },
+ AutoFallbackDisabled: {
+ Configs: {
+ skipBillingAssertion: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_type: "credit",
+ payment_method_data: {
+ card: autoFallbackCardDetails,
+ },
+ authentication_type: "no_three_ds",
+ },
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ type: "invalid_request",
+ message:
+ "No eligible connector was found for the current payment method configuration",
+ code: "IR_39",
+ },
+ },
+ },
+ },
+ AutoFallbackEnabled: {
+ Request: {
+ payment_method: "card",
+ payment_method_type: "credit",
+ payment_method_data: {
+ card: autoFallbackCardDetails,
+ },
+ authentication_type: "no_three_ds",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ capture_method: "manual",
+ capture_method_applied: "automatic",
+ },
+ },
+ },
+ },
PaymentIntentWithBillingDescriptor: {
Request: {
currency: "EUR",
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
index e67dfa5e1c..9118dd1e5c 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
@@ -835,6 +835,14 @@ export const CONNECTOR_LISTS = {
ZERO_AUTH_MANDATE: ["peachpayments"],
BLOCK_IMPLICIT_CUSTOMER_CREATION: ["adyen"],
ERROR_ON_REQUIRES_ACTION: ["stripe"],
+ AUTO_FALLBACK_CAPTURE_METHOD: [
+ "trustpay",
+ "cryptopay",
+ "facilitapay",
+ "payjustnow",
+ "placetopay",
+ "iatapay",
+ ],
AFT_PURPOSE_OF_PAYMENT: ["checkout"],
AFT_FUNDING_TRANSACTION_TYPE: ["worldpayxml"],
PEACHPAYMENTS_CONNECTOR_METADATA: ["peachpayments"],
diff --git a/cypress-tests/cypress/e2e/spec/Payment/54-AutoFallbackCaptureMethod.cy.js b/cypress-tests/cypress/e2e/spec/Payment/54-AutoFallbackCaptureMethod.cy.js
new file mode 100644
index 0000000000..519f7ceb47
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Payment/54-AutoFallbackCaptureMethod.cy.js
@@ -0,0 +1,155 @@
+import * as fixtures from "../../../fixtures/imports";
+import State from "../../../utils/State";
+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
+
+let globalState;
+
+describe("Card - Auto Fallback Capture Method flow test", () => {
+ let specShouldSkip = false;
+
+ before("seed global state", () => {
+ cy.task("getGlobalState").then((state) => {
+ globalState = new State(state);
+ const connectorId = globalState.get("connectorId");
+ specShouldSkip = utils.shouldIncludeConnector(
+ connectorId,
+ utils.CONNECTOR_LISTS.INCLUDE.AUTO_FALLBACK_CAPTURE_METHOD
+ );
+ });
+ });
+
+ beforeEach(function () {
+ if (specShouldSkip) {
+ this.skip();
+ }
+ });
+
+ afterEach("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ context(
+ "auto_fallback_capture_method disabled - manual capture confirm is rejected",
+ () => {
+ let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ it("update business profile with auto_fallback_capture_method disabled", () => {
+ const updateBusinessProfileBody = {
+ auto_fallback_capture_method: false,
+ };
+ cy.UpdateBusinessProfileTest(
+ updateBusinessProfileBody,
+ false, // is_connector_agnostic_enabled
+ false, // collect_billing_address_from_wallet_connector
+ false, // collect_shipping_address_from_wallet_connector
+ false, // always_collect_billing_address_from_wallet_connector
+ false, // always_collect_shipping_address_from_wallet_connector
+ globalState
+ );
+ });
+
+ it("create-payment-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["AutoFallbackCaptureMethod"]["PaymentIntent"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "manual",
+ globalState
+ );
+
+ if (shouldContinue)
+ shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("confirm-payment-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["AutoFallbackCaptureMethod"]["AutoFallbackDisabled"];
+
+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+ });
+
+ it("retrieve-payment-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["AutoFallbackCaptureMethod"]["AutoFallbackDisabled"];
+
+ cy.retrievePaymentCallTest({ globalState, data });
+ });
+ }
+ );
+
+ context(
+ "auto_fallback_capture_method enabled - manual capture falls back to automatic",
+ () => {
+ let shouldContinue = true; // variable that will be used to skip tests if a previous test fails
+
+ beforeEach(function () {
+ if (!shouldContinue) {
+ this.skip();
+ }
+ });
+
+ it("update business profile with auto_fallback_capture_method enabled", () => {
+ const updateBusinessProfileBody = {
+ auto_fallback_capture_method: true,
+ };
+ cy.UpdateBusinessProfileTest(
+ updateBusinessProfileBody,
+ false, // is_connector_agnostic_enabled
+ false, // collect_billing_address_from_wallet_connector
+ false, // collect_shipping_address_from_wallet_connector
+ false, // always_collect_billing_address_from_wallet_connector
+ false, // always_collect_shipping_address_from_wallet_connector
+ globalState
+ );
+ });
+
+ it("create-payment-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["AutoFallbackCaptureMethod"]["PaymentIntent"];
+
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "manual",
+ globalState
+ );
+
+ if (shouldContinue)
+ shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("confirm-payment-call-test with capture_method_applied automatic", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["AutoFallbackCaptureMethod"]["AutoFallbackEnabled"];
+
+ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);
+
+ if (shouldContinue)
+ shouldContinue = utils.should_continue_further(data);
+ });
+
+ it("retrieve-payment-call-test", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "card_pm"
+ ]["AutoFallbackCaptureMethod"]["AutoFallbackEnabled"];
+
+ cy.retrievePaymentCallTest({ globalState, data });
+ });
+ }
+ );
+});
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index 85fa2d4a08..736ae2d70f 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -25,6 +25,11 @@
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
// commands.js or your custom support file
+import {
+ connectorDetails as commonConnectorDetails,
+ integrationTypeMismatchMessage,
+ OFFER_QUOTE_ID_PLACEHOLDER,
+} from "../e2e/configs/Payment/Commons";
import getConnectorDetails, {
CONNECTOR_LISTS,
defaultErrorHandler,
@@ -36,11 +41,6 @@ import getConnectorDetails, {
shouldIncludeConnector,
stringifyWithBigInt,
} from "../e2e/configs/Payment/Utils";
-import {
- connectorDetails as commonConnectorDetails,
- integrationTypeMismatchMessage,
-} from "../e2e/configs/Payment/Commons";
-import { OFFER_QUOTE_ID_PLACEHOLDER } from "../e2e/configs/Payment/Commons";
import { injectGotymePayoutBankTransfer } from "../e2e/configs/Payout/Utils";
import { execConfig, validateConfig } from "../utils/featureFlags";
import * as RequestBodyUtils from "../utils/RequestBodyUtils";
@@ -1281,6 +1281,13 @@ Cypress.Commands.add(
updateBusinessProfileBody.merchant_category_code
);
}
+ if (
+ updateBusinessProfileBody.auto_fallback_capture_method !== undefined
+ ) {
+ expect(response.body.auto_fallback_capture_method).to.equal(
+ updateBusinessProfileBody.auto_fallback_capture_method
+ );
+ }
// Auto-retry specs rely on these flags being persisted on the
// profile; assert them so a stale/rejected update fails at the
// setup step instead of surfacing as a retry that never happened.