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 Voucher payment coverage for adyen (#12362)

HS-QUALIBOTf83a44aef26c
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Adyen.js b/cypress-tests/cypress/e2e/configs/Payment/Adyen.js
index 5aafd548a8..313ca88b1f 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Adyen.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Adyen.js
@@ -39,6 +39,19 @@ const singleUseMandateData = {
},
};
+const voucherCurrencyMap = {
+ Boleto: "BRL",
+ Oxxo: "MXN",
+ Alfamart: "IDR",
+ Indomaret: "IDR",
+ SevenEleven: "JPY",
+ Lawson: "JPY",
+ MiniStop: "JPY",
+ FamilyMart: "JPY",
+ Seicomart: "JPY",
+ PayEasy: "JPY",
+};
+
const mandateBrowserInfo = {
user_agent:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
@@ -1813,6 +1826,438 @@ export const connectorDetails = {
}),
},
+ voucher_pm: {
+ PaymentIntent: (paymentMethodType) => {
+ return {
+ Request: {
+ currency: voucherCurrencyMap[paymentMethodType] || "USD",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ },
+ },
+ };
+ },
+ Boleto: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "boleto",
+ payment_method_data: {
+ voucher: {
+ boleto: {
+ social_security_number: "12345678909",
+ document_type: "cpf",
+ },
+ },
+ },
+ billing: {
+ address: {
+ line1: "Rua Test 123",
+ city: "Sao Paulo",
+ state: "SP",
+ zip: "01310100",
+ country: "BR",
+ first_name: "Test",
+ last_name: "User",
+ },
+ phone: {
+ number: "11987654321",
+ country_code: "+55",
+ },
+ email: "[email protected]",
+ },
+ currency: voucherCurrencyMap.Boleto,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ payment_method: "voucher",
+ payment_method_type: "boleto",
+ },
+ },
+ }),
+ Oxxo: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "oxxo",
+ payment_method_data: {
+ voucher: {
+ oxxo: null,
+ },
+ },
+ billing: {
+ address: {
+ line1: "123 Test St",
+ city: "Mexico City",
+ state: "Mexico",
+ zip: "06600",
+ country: "MX",
+ first_name: "Test",
+ last_name: "User",
+ },
+ email: "[email protected]",
+ },
+ currency: voucherCurrencyMap.Oxxo,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ payment_method: "voucher",
+ payment_method_type: "oxxo",
+ },
+ },
+ }),
+ Alfamart: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "alfamart",
+ payment_method_data: {
+ voucher: {
+ alfamart: {
+ first_name: "Test",
+ last_name: "User",
+ email: "[email protected]",
+ },
+ },
+ },
+ billing: {
+ address: {
+ line1: "Jl Test 123",
+ city: "Jakarta",
+ state: "DKI Jakarta",
+ zip: "10110",
+ country: "ID",
+ first_name: "Test",
+ last_name: "User",
+ },
+ email: "[email protected]",
+ },
+ currency: voucherCurrencyMap.Alfamart,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ payment_method: "voucher",
+ payment_method_type: "alfamart",
+ },
+ },
+ }),
+ Indomaret: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "indomaret",
+ payment_method_data: {
+ voucher: {
+ indomaret: {
+ first_name: "Test",
+ last_name: "User",
+ email: "[email protected]",
+ },
+ },
+ },
+ billing: {
+ address: {
+ line1: "Jl Test 123",
+ city: "Jakarta",
+ state: "DKI Jakarta",
+ zip: "10110",
+ country: "ID",
+ first_name: "Test",
+ last_name: "User",
+ },
+ email: "[email protected]",
+ },
+ currency: voucherCurrencyMap.Indomaret,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ payment_method: "voucher",
+ payment_method_type: "indomaret",
+ },
+ },
+ }),
+ SevenEleven: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "seven_eleven",
+ payment_method_data: {
+ voucher: {
+ seven_eleven: {
+ first_name: "Test",
+ last_name: "User",
+ email: "[email protected]",
+ },
+ },
+ },
+ billing: {
+ address: {
+ line1: "1-1 Test",
+ city: "Tokyo",
+ state: "Tokyo",
+ zip: "1000001",
+ country: "JP",
+ first_name: "Test",
+ last_name: "User",
+ },
+ phone: {
+ number: "312345678",
+ country_code: "+81",
+ },
+ email: "[email protected]",
+ },
+ currency: voucherCurrencyMap.SevenEleven,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ payment_method: "voucher",
+ payment_method_type: "seven_eleven",
+ },
+ },
+ }),
+ Lawson: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "lawson",
+ payment_method_data: {
+ voucher: {
+ lawson: {
+ first_name: "Test",
+ last_name: "User",
+ email: "[email protected]",
+ },
+ },
+ },
+ billing: {
+ address: {
+ line1: "1-1 Test",
+ city: "Tokyo",
+ state: "Tokyo",
+ zip: "1000001",
+ country: "JP",
+ first_name: "Test",
+ last_name: "User",
+ },
+ phone: {
+ number: "312345678",
+ country_code: "+81",
+ },
+ email: "[email protected]",
+ },
+ currency: voucherCurrencyMap.Lawson,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ payment_method: "voucher",
+ payment_method_type: "lawson",
+ },
+ },
+ }),
+ MiniStop: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "mini_stop",
+ payment_method_data: {
+ voucher: {
+ mini_stop: {
+ first_name: "Test",
+ last_name: "User",
+ email: "[email protected]",
+ },
+ },
+ },
+ billing: {
+ address: {
+ line1: "1-1 Test",
+ city: "Tokyo",
+ state: "Tokyo",
+ zip: "1000001",
+ country: "JP",
+ first_name: "Test",
+ last_name: "User",
+ },
+ phone: {
+ number: "312345678",
+ country_code: "+81",
+ },
+ email: "[email protected]",
+ },
+ currency: voucherCurrencyMap.MiniStop,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ payment_method: "voucher",
+ payment_method_type: "mini_stop",
+ },
+ },
+ }),
+ FamilyMart: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "family_mart",
+ payment_method_data: {
+ voucher: {
+ family_mart: {
+ first_name: "Test",
+ last_name: "User",
+ email: "[email protected]",
+ },
+ },
+ },
+ billing: {
+ address: {
+ line1: "1-1 Test",
+ city: "Tokyo",
+ state: "Tokyo",
+ zip: "1000001",
+ country: "JP",
+ first_name: "Test",
+ last_name: "User",
+ },
+ phone: {
+ number: "312345678",
+ country_code: "+81",
+ },
+ email: "[email protected]",
+ },
+ currency: voucherCurrencyMap.FamilyMart,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ payment_method: "voucher",
+ payment_method_type: "family_mart",
+ },
+ },
+ }),
+ Seicomart: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "seicomart",
+ payment_method_data: {
+ voucher: {
+ seicomart: {
+ first_name: "Test",
+ last_name: "User",
+ email: "[email protected]",
+ },
+ },
+ },
+ billing: {
+ address: {
+ line1: "1-1 Test",
+ city: "Tokyo",
+ state: "Tokyo",
+ zip: "1000001",
+ country: "JP",
+ first_name: "Test",
+ last_name: "User",
+ },
+ phone: {
+ number: "312345678",
+ country_code: "+81",
+ },
+ email: "[email protected]",
+ },
+ currency: voucherCurrencyMap.Seicomart,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ payment_method: "voucher",
+ payment_method_type: "seicomart",
+ },
+ },
+ }),
+ PayEasy: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "pay_easy",
+ payment_method_data: {
+ voucher: {
+ pay_easy: {
+ first_name: "Test",
+ last_name: "User",
+ email: "[email protected]",
+ },
+ },
+ },
+ billing: {
+ address: {
+ line1: "1-1 Test",
+ city: "Tokyo",
+ state: "Tokyo",
+ zip: "1000001",
+ country: "JP",
+ first_name: "Test",
+ last_name: "User",
+ },
+ phone: {
+ number: "312345678",
+ country_code: "+81",
+ },
+ email: "[email protected]",
+ },
+ currency: voucherCurrencyMap.PayEasy,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_customer_action",
+ payment_method: "voucher",
+ payment_method_type: "pay_easy",
+ },
+ },
+ }),
+ OxxoInvalidFormat: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "oxxo",
+ payment_method_data: {
+ voucher: {
+ oxxo: "oxxo",
+ },
+ },
+ billing: {
+ address: {
+ line1: "123 Test St",
+ city: "Mexico City",
+ state: "Mexico",
+ zip: "06600",
+ country: "MX",
+ first_name: "Test",
+ last_name: "User",
+ },
+ email: "[email protected]",
+ },
+ currency: voucherCurrencyMap.Oxxo,
+ },
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ message: 'invalid type: string "oxxo", expected unit',
+ code: "IR_06",
+ },
+ },
+ },
+ }),
+ },
+
pm_list: {
PmListResponse: {
PmListNull: {
@@ -2073,6 +2518,7 @@ export const connectorDetails = {
},
},
},
+
bank_debit_pm: {
PaymentIntent: (paymentMethodType) => {
if (paymentMethodType === "Ach") {
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
index 98f3ac70c8..8140ae4b32 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
@@ -598,6 +598,121 @@ export const payment_methods_enabled = [
},
],
},
+ {
+ payment_method: "voucher",
+ payment_method_types: [
+ {
+ payment_method_type: "boleto",
+ payment_experience: null,
+ card_networks: null,
+ accepted_currencies: null,
+ accepted_countries: null,
+ minimum_amount: 1,
+ maximum_amount: 68607706,
+ recurring_enabled: false,
+ installment_payment_enabled: false,
+ },
+ {
+ payment_method_type: "oxxo",
+ payment_experience: null,
+ card_networks: null,
+ accepted_currencies: null,
+ accepted_countries: null,
+ minimum_amount: 1,
+ maximum_amount: 68607706,
+ recurring_enabled: false,
+ installment_payment_enabled: false,
+ },
+ {
+ payment_method_type: "alfamart",
+ payment_experience: null,
+ card_networks: null,
+ accepted_currencies: null,
+ accepted_countries: null,
+ minimum_amount: 1,
+ maximum_amount: 68607706,
+ recurring_enabled: false,
+ installment_payment_enabled: false,
+ },
+ {
+ payment_method_type: "indomaret",
+ payment_experience: null,
+ card_networks: null,
+ accepted_currencies: null,
+ accepted_countries: null,
+ minimum_amount: 1,
+ maximum_amount: 68607706,
+ recurring_enabled: false,
+ installment_payment_enabled: false,
+ },
+ {
+ payment_method_type: "seven_eleven",
+ payment_experience: null,
+ card_networks: null,
+ accepted_currencies: null,
+ accepted_countries: null,
+ minimum_amount: 1,
+ maximum_amount: 68607706,
+ recurring_enabled: false,
+ installment_payment_enabled: false,
+ },
+ {
+ payment_method_type: "lawson",
+ payment_experience: null,
+ card_networks: null,
+ accepted_currencies: null,
+ accepted_countries: null,
+ minimum_amount: 1,
+ maximum_amount: 68607706,
+ recurring_enabled: false,
+ installment_payment_enabled: false,
+ },
+ {
+ payment_method_type: "mini_stop",
+ payment_experience: null,
+ card_networks: null,
+ accepted_currencies: null,
+ accepted_countries: null,
+ minimum_amount: 1,
+ maximum_amount: 68607706,
+ recurring_enabled: false,
+ installment_payment_enabled: false,
+ },
+ {
+ payment_method_type: "family_mart",
+ payment_experience: null,
+ card_networks: null,
+ accepted_currencies: null,
+ accepted_countries: null,
+ minimum_amount: 1,
+ maximum_amount: 68607706,
+ recurring_enabled: false,
+ installment_payment_enabled: false,
+ },
+ {
+ payment_method_type: "seicomart",
+ payment_experience: null,
+ card_networks: null,
+ accepted_currencies: null,
+ accepted_countries: null,
+ minimum_amount: 1,
+ maximum_amount: 68607706,
+ recurring_enabled: false,
+ installment_payment_enabled: false,
+ },
+ {
+ payment_method_type: "pay_easy",
+ payment_experience: null,
+ card_networks: null,
+ accepted_currencies: null,
+ accepted_countries: null,
+ minimum_amount: 1,
+ maximum_amount: 68607706,
+ recurring_enabled: false,
+ installment_payment_enabled: false,
+ },
+ ],
+ },
{
payment_method: "gift_card",
payment_method_types: [
@@ -3840,6 +3955,323 @@ export const connectorDetails = {
},
}),
},
+ voucher_pm: {
+ PaymentIntent: (paymentMethodType) =>
+ getCustomExchange({
+ Request: {
+ currency: getCurrency(paymentMethodType),
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ },
+ },
+ }),
+ Boleto: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "boleto",
+ payment_method_data: {
+ voucher: {
+ boleto: {
+ social_security_number: "12345678909",
+ document_type: "cpf",
+ },
+ },
+ },
+ billing: {
+ address: {
+ line1: "Rua Test 123",
+ city: "Sao Paulo",
+ state: "SP",
+ zip: "01310100",
+ country: "BR",
+ first_name: "Test",
+ last_name: "User",
+ },
+ phone: {
+ number: "11987654321",
+ country_code: "+55",
+ },
+ email: "[email protected]",
+ },
+ currency: "BRL",
+ },
+ }),
+ Oxxo: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "oxxo",
+ payment_method_data: {
+ voucher: {
+ oxxo: null,
+ },
+ },
+ billing: {
+ address: {
+ line1: "123 Test St",
+ city: "Mexico City",
+ state: "Mexico",
+ zip: "06600",
+ country: "MX",
+ first_name: "Test",
+ last_name: "User",
+ },
+ email: "[email protected]",
+ },
+ currency: "MXN",
+ },
+ }),
+ Alfamart: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "alfamart",
+ payment_method_data: {
+ voucher: {
+ alfamart: {
+ first_name: "Test",
+ last_name: "User",
+ email: "[email protected]",
+ },
+ },
+ },
+ billing: {
+ address: {
+ line1: "Jl Test 123",
+ city: "Jakarta",
+ state: "DKI Jakarta",
+ zip: "10110",
+ country: "ID",
+ first_name: "Test",
+ last_name: "User",
+ },
+ email: "[email protected]",
+ },
+ currency: "IDR",
+ },
+ }),
+ Indomaret: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "indomaret",
+ payment_method_data: {
+ voucher: {
+ indomaret: {
+ first_name: "Test",
+ last_name: "User",
+ email: "[email protected]",
+ },
+ },
+ },
+ billing: {
+ address: {
+ line1: "Jl Test 123",
+ city: "Jakarta",
+ state: "DKI Jakarta",
+ zip: "10110",
+ country: "ID",
+ first_name: "Test",
+ last_name: "User",
+ },
+ email: "[email protected]",
+ },
+ currency: "IDR",
+ },
+ }),
+ SevenEleven: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "seven_eleven",
+ payment_method_data: {
+ voucher: {
+ seven_eleven: {
+ first_name: "Test",
+ last_name: "User",
+ email: "[email protected]",
+ },
+ },
+ },
+ billing: {
+ address: {
+ line1: "1-1 Test",
+ city: "Tokyo",
+ state: "Tokyo",
+ zip: "1000001",
+ country: "JP",
+ first_name: "Test",
+ last_name: "User",
+ },
+ phone: {
+ number: "312345678",
+ country_code: "+81",
+ },
+ email: "[email protected]",
+ },
+ currency: "JPY",
+ },
+ }),
+ Lawson: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "lawson",
+ payment_method_data: {
+ voucher: {
+ lawson: {
+ first_name: "Test",
+ last_name: "User",
+ email: "[email protected]",
+ },
+ },
+ },
+ billing: {
+ address: {
+ line1: "1-1 Test",
+ city: "Tokyo",
+ state: "Tokyo",
+ zip: "1000001",
+ country: "JP",
+ first_name: "Test",
+ last_name: "User",
+ },
+ phone: {
+ number: "312345678",
+ country_code: "+81",
+ },
+ email: "[email protected]",
+ },
+ currency: "JPY",
+ },
+ }),
+ MiniStop: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "mini_stop",
+ payment_method_data: {
+ voucher: {
+ mini_stop: {
+ first_name: "Test",
+ last_name: "User",
+ email: "[email protected]",
+ },
+ },
+ },
+ billing: {
+ address: {
+ line1: "1-1 Test",
+ city: "Tokyo",
+ state: "Tokyo",
+ zip: "1000001",
+ country: "JP",
+ first_name: "Test",
+ last_name: "User",
+ },
+ phone: {
+ number: "312345678",
+ country_code: "+81",
+ },
+ email: "[email protected]",
+ },
+ currency: "JPY",
+ },
+ }),
+ FamilyMart: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "family_mart",
+ payment_method_data: {
+ voucher: {
+ family_mart: {
+ first_name: "Test",
+ last_name: "User",
+ email: "[email protected]",
+ },
+ },
+ },
+ billing: {
+ address: {
+ line1: "1-1 Test",
+ city: "Tokyo",
+ state: "Tokyo",
+ zip: "1000001",
+ country: "JP",
+ first_name: "Test",
+ last_name: "User",
+ },
+ phone: {
+ number: "312345678",
+ country_code: "+81",
+ },
+ email: "[email protected]",
+ },
+ currency: "JPY",
+ },
+ }),
+ Seicomart: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "seicomart",
+ payment_method_data: {
+ voucher: {
+ seicomart: {
+ first_name: "Test",
+ last_name: "User",
+ email: "[email protected]",
+ },
+ },
+ },
+ billing: {
+ address: {
+ line1: "1-1 Test",
+ city: "Tokyo",
+ state: "Tokyo",
+ zip: "1000001",
+ country: "JP",
+ first_name: "Test",
+ last_name: "User",
+ },
+ phone: {
+ number: "312345678",
+ country_code: "+81",
+ },
+ email: "[email protected]",
+ },
+ currency: "JPY",
+ },
+ }),
+ PayEasy: getCustomExchange({
+ Request: {
+ payment_method: "voucher",
+ payment_method_type: "pay_easy",
+ payment_method_data: {
+ voucher: {
+ pay_easy: {
+ first_name: "Test",
+ last_name: "User",
+ email: "[email protected]",
+ },
+ },
+ },
+ billing: {
+ address: {
+ line1: "1-1 Test",
+ city: "Tokyo",
+ state: "Tokyo",
+ zip: "1000001",
+ country: "JP",
+ first_name: "Test",
+ last_name: "User",
+ },
+ phone: {
+ number: "312345678",
+ country_code: "+81",
+ },
+ email: "[email protected]",
+ },
+ currency: "JPY",
+ },
+ }),
+ },
pm_collect_link: {
pmCollectLinkCreate: {
Request: {
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js b/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js
index c2b588a337..1b81e87214 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Modifiers.js
@@ -199,6 +199,18 @@ const CURRENCY_MAP = {
AliPayHk: "HKD", // Hong Kong payment method
Affirm: "USD", // US BNPL payment method
Mifinity: "EUR", // Mifinity wallet payment method
+
+ // Voucher payment methods
+ Boleto: "BRL",
+ Oxxo: "MXN",
+ Alfamart: "IDR",
+ Indomaret: "IDR",
+ SevenEleven: "JPY",
+ Lawson: "JPY",
+ MiniStop: "JPY",
+ FamilyMart: "JPY",
+ Seicomart: "JPY",
+ PayEasy: "JPY",
Skrill: "USD", // Skrill wallet payment method
PaySafeCard: "USD", // PaySafeCard gift card payment method
};
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
index 519f902970..29b36c2aea 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
@@ -577,6 +577,7 @@ export const CONNECTOR_LISTS = {
AFFIRM_PAY_LATER: ["affirm"],
EXTEND_AUTHORIZATION: ["adyen", "paypal"],
GIFT_CARD: ["adyen"],
+ VOUCHER: ["adyen"],
RELAY_OPERATIONS: ["bankofamerica"],
PAY_LATER: [
"klarna",
diff --git a/cypress-tests/cypress/e2e/spec/Payment/52-VoucherPayment.cy.js b/cypress-tests/cypress/e2e/spec/Payment/52-VoucherPayment.cy.js
new file mode 100644
index 0000000000..76c5912cfa
--- /dev/null
+++ b/cypress-tests/cypress/e2e/spec/Payment/52-VoucherPayment.cy.js
@@ -0,0 +1,806 @@
+import * as fixtures from "../../../fixtures/imports";
+import State from "../../../utils/State";
+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";
+
+let globalState;
+let connector;
+
+describe("Voucher Payment tests", () => {
+ before("seed global state", function () {
+ let skip = false;
+
+ cy.task("getGlobalState")
+ .then((state) => {
+ globalState = new State(state);
+ connector = globalState.get("connectorId");
+
+ if (
+ utils.shouldIncludeConnector(
+ connector,
+ utils.CONNECTOR_LISTS.INCLUDE.VOUCHER
+ )
+ ) {
+ skip = true;
+ return;
+ }
+ })
+ .then(() => {
+ if (skip) {
+ cy.log(
+ `Skipping voucher payment tests for connector: ${connector} -- not in VOUCHER inclusion list`
+ );
+ this.skip();
+ }
+ });
+ });
+
+ afterEach("flush global state", () => {
+ cy.task("setGlobalState", globalState.data);
+ });
+
+ context("Boleto Voucher Payment", () => {
+ it("Create Payment Intent -> List Payment Methods -> Confirm Voucher Payment -> Handle Voucher Redirection -> Retrieve Payment", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["PaymentIntent"]("Boleto");
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("List Merchant Payment Methods", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: List Merchant Payment Methods");
+ return;
+ }
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ cy.step("Confirm Boleto Voucher Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Confirm Boleto Voucher Payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["Boleto"];
+ cy.confirmVoucherCallTest(
+ fixtures.confirmBody,
+ data,
+ true,
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Handle Voucher Redirection", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Handle Voucher Redirection");
+ return;
+ }
+ const expected_redirection = fixtures.confirmBody["return_url"];
+ const payment_method_type = globalState.get("paymentMethodType");
+ cy.handleVoucherRedirection(
+ globalState,
+ payment_method_type,
+ expected_redirection
+ );
+ });
+
+ cy.step("Retrieve Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Retrieve Payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["Boleto"];
+ cy.retrievePaymentCallTest({ globalState, data });
+ });
+ });
+ });
+
+ context("OXXO Voucher Payment", () => {
+ it("Create Payment Intent -> List Payment Methods -> Confirm Voucher Payment -> Handle Voucher Redirection -> Retrieve Payment", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["PaymentIntent"]("Oxxo");
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("List Merchant Payment Methods", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: List Merchant Payment Methods");
+ return;
+ }
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ cy.step("Confirm OXXO Voucher Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Confirm OXXO Voucher Payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["Oxxo"];
+ cy.confirmVoucherCallTest(
+ fixtures.confirmBody,
+ data,
+ true,
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Handle Voucher Redirection", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Handle Voucher Redirection");
+ return;
+ }
+ const expected_redirection = fixtures.confirmBody["return_url"];
+ const payment_method_type = globalState.get("paymentMethodType");
+ cy.handleVoucherRedirection(
+ globalState,
+ payment_method_type,
+ expected_redirection
+ );
+ });
+
+ cy.step("Retrieve Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Retrieve Payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["Oxxo"];
+ cy.retrievePaymentCallTest({ globalState, data });
+ });
+ });
+
+ it("OXXO invalid voucher data format (string instead of null) should error", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["OxxoInvalidFormat"];
+
+ cy.createConfirmPaymentTest(
+ fixtures.createConfirmPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+ });
+ });
+
+ context("Alfamart Voucher Payment", () => {
+ it("Create Payment Intent -> List Payment Methods -> Confirm Voucher Payment -> Handle Voucher Redirection -> Retrieve Payment", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["PaymentIntent"]("Alfamart");
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("List Merchant Payment Methods", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: List Merchant Payment Methods");
+ return;
+ }
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ cy.step("Confirm Alfamart Voucher Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Confirm Alfamart Voucher Payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["Alfamart"];
+ cy.confirmVoucherCallTest(
+ fixtures.confirmBody,
+ data,
+ true,
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Handle Voucher Redirection", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Handle Voucher Redirection");
+ return;
+ }
+ const expected_redirection = fixtures.confirmBody["return_url"];
+ const payment_method_type = globalState.get("paymentMethodType");
+ cy.handleVoucherRedirection(
+ globalState,
+ payment_method_type,
+ expected_redirection
+ );
+ });
+
+ cy.step("Retrieve Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Retrieve Payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["Alfamart"];
+ cy.retrievePaymentCallTest({ globalState, data });
+ });
+ });
+ });
+
+ context("Indomaret Voucher Payment", () => {
+ it("Create Payment Intent -> List Payment Methods -> Confirm Voucher Payment -> Handle Voucher Redirection -> Retrieve Payment", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["PaymentIntent"]("Indomaret");
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("List Merchant Payment Methods", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: List Merchant Payment Methods");
+ return;
+ }
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ cy.step("Confirm Indomaret Voucher Payment", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Confirm Indomaret Voucher Payment"
+ );
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["Indomaret"];
+ cy.confirmVoucherCallTest(
+ fixtures.confirmBody,
+ data,
+ true,
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Handle Voucher Redirection", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Handle Voucher Redirection");
+ return;
+ }
+ const expected_redirection = fixtures.confirmBody["return_url"];
+ const payment_method_type = globalState.get("paymentMethodType");
+ cy.handleVoucherRedirection(
+ globalState,
+ payment_method_type,
+ expected_redirection
+ );
+ });
+
+ cy.step("Retrieve Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Retrieve Payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["Indomaret"];
+ cy.retrievePaymentCallTest({ globalState, data });
+ });
+ });
+ });
+
+ context("Seven-Eleven Voucher Payment", () => {
+ it("Create Payment Intent -> List Payment Methods -> Confirm Voucher Payment -> Handle Voucher Redirection -> Retrieve Payment", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["PaymentIntent"]("SevenEleven");
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("List Merchant Payment Methods", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: List Merchant Payment Methods");
+ return;
+ }
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ cy.step("Confirm Seven-Eleven Voucher Payment", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Confirm Seven-Eleven Voucher Payment"
+ );
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["SevenEleven"];
+ cy.confirmVoucherCallTest(
+ fixtures.confirmBody,
+ data,
+ true,
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Handle Voucher Redirection", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Handle Voucher Redirection");
+ return;
+ }
+ const expected_redirection = fixtures.confirmBody["return_url"];
+ const payment_method_type = globalState.get("paymentMethodType");
+ cy.handleVoucherRedirection(
+ globalState,
+ payment_method_type,
+ expected_redirection
+ );
+ });
+
+ cy.step("Retrieve Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Retrieve Payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["SevenEleven"];
+ cy.retrievePaymentCallTest({ globalState, data });
+ });
+ });
+ });
+
+ context("Lawson Voucher Payment", () => {
+ it("Create Payment Intent -> List Payment Methods -> Confirm Voucher Payment -> Handle Voucher Redirection -> Retrieve Payment", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["PaymentIntent"]("Lawson");
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("List Merchant Payment Methods", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: List Merchant Payment Methods");
+ return;
+ }
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ cy.step("Confirm Lawson Voucher Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Confirm Lawson Voucher Payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["Lawson"];
+ cy.confirmVoucherCallTest(
+ fixtures.confirmBody,
+ data,
+ true,
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Handle Voucher Redirection", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Handle Voucher Redirection");
+ return;
+ }
+ const expected_redirection = fixtures.confirmBody["return_url"];
+ const payment_method_type = globalState.get("paymentMethodType");
+ cy.handleVoucherRedirection(
+ globalState,
+ payment_method_type,
+ expected_redirection
+ );
+ });
+
+ cy.step("Retrieve Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Retrieve Payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["Lawson"];
+ cy.retrievePaymentCallTest({ globalState, data });
+ });
+ });
+ });
+
+ context("MiniStop Voucher Payment", () => {
+ it("Create Payment Intent -> List Payment Methods -> Confirm Voucher Payment -> Handle Voucher Redirection -> Retrieve Payment", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["PaymentIntent"]("MiniStop");
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("List Merchant Payment Methods", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: List Merchant Payment Methods");
+ return;
+ }
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ cy.step("Confirm MiniStop Voucher Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Confirm MiniStop Voucher Payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["MiniStop"];
+ cy.confirmVoucherCallTest(
+ fixtures.confirmBody,
+ data,
+ true,
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Handle Voucher Redirection", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Handle Voucher Redirection");
+ return;
+ }
+ const expected_redirection = fixtures.confirmBody["return_url"];
+ const payment_method_type = globalState.get("paymentMethodType");
+ cy.handleVoucherRedirection(
+ globalState,
+ payment_method_type,
+ expected_redirection
+ );
+ });
+
+ cy.step("Retrieve Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Retrieve Payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["MiniStop"];
+ cy.retrievePaymentCallTest({ globalState, data });
+ });
+ });
+ });
+
+ context("FamilyMart Voucher Payment", () => {
+ it("Create Payment Intent -> List Payment Methods -> Confirm Voucher Payment -> Handle Voucher Redirection -> Retrieve Payment", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["PaymentIntent"]("FamilyMart");
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("List Merchant Payment Methods", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: List Merchant Payment Methods");
+ return;
+ }
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ cy.step("Confirm FamilyMart Voucher Payment", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Confirm FamilyMart Voucher Payment"
+ );
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["FamilyMart"];
+ cy.confirmVoucherCallTest(
+ fixtures.confirmBody,
+ data,
+ true,
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Handle Voucher Redirection", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Handle Voucher Redirection");
+ return;
+ }
+ const expected_redirection = fixtures.confirmBody["return_url"];
+ const payment_method_type = globalState.get("paymentMethodType");
+ cy.handleVoucherRedirection(
+ globalState,
+ payment_method_type,
+ expected_redirection
+ );
+ });
+
+ cy.step("Retrieve Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Retrieve Payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["FamilyMart"];
+ cy.retrievePaymentCallTest({ globalState, data });
+ });
+ });
+ });
+
+ context("Seicomart Voucher Payment", () => {
+ it("Create Payment Intent -> List Payment Methods -> Confirm Voucher Payment -> Handle Voucher Redirection -> Retrieve Payment", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["PaymentIntent"]("Seicomart");
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("List Merchant Payment Methods", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: List Merchant Payment Methods");
+ return;
+ }
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ cy.step("Confirm Seicomart Voucher Payment", () => {
+ if (!shouldContinue) {
+ cy.task(
+ "cli_log",
+ "Skipping step: Confirm Seicomart Voucher Payment"
+ );
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["Seicomart"];
+ cy.confirmVoucherCallTest(
+ fixtures.confirmBody,
+ data,
+ true,
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Handle Voucher Redirection", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Handle Voucher Redirection");
+ return;
+ }
+ const expected_redirection = fixtures.confirmBody["return_url"];
+ const payment_method_type = globalState.get("paymentMethodType");
+ cy.handleVoucherRedirection(
+ globalState,
+ payment_method_type,
+ expected_redirection
+ );
+ });
+
+ cy.step("Retrieve Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Retrieve Payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["Seicomart"];
+ cy.retrievePaymentCallTest({ globalState, data });
+ });
+ });
+ });
+
+ context("PayEasy Voucher Payment", () => {
+ it("Create Payment Intent -> List Payment Methods -> Confirm Voucher Payment -> Handle Voucher Redirection -> Retrieve Payment", () => {
+ let shouldContinue = true;
+
+ cy.step("Create Payment Intent", () => {
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["PaymentIntent"]("PayEasy");
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ data,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("List Merchant Payment Methods", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: List Merchant Payment Methods");
+ return;
+ }
+ cy.paymentMethodsCallTest(globalState);
+ });
+
+ cy.step("Confirm PayEasy Voucher Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Confirm PayEasy Voucher Payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["PayEasy"];
+ cy.confirmVoucherCallTest(
+ fixtures.confirmBody,
+ data,
+ true,
+ globalState
+ );
+ if (!utils.should_continue_further(data)) {
+ shouldContinue = false;
+ }
+ });
+
+ cy.step("Handle Voucher Redirection", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Handle Voucher Redirection");
+ return;
+ }
+ const expected_redirection = fixtures.confirmBody["return_url"];
+ const payment_method_type = globalState.get("paymentMethodType");
+ cy.handleVoucherRedirection(
+ globalState,
+ payment_method_type,
+ expected_redirection
+ );
+ });
+
+ cy.step("Retrieve Payment", () => {
+ if (!shouldContinue) {
+ cy.task("cli_log", "Skipping step: Retrieve Payment");
+ return;
+ }
+ const data = getConnectorDetails(globalState.get("connectorId"))[
+ "voucher_pm"
+ ]["PayEasy"];
+ cy.retrievePaymentCallTest({ globalState, data });
+ });
+ });
+ });
+});
diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js
index 30f9b525ae..b9b51b571d 100644
--- a/cypress-tests/cypress/support/commands.js
+++ b/cypress-tests/cypress/support/commands.js
@@ -5428,6 +5428,129 @@ Cypress.Commands.add(
}
);
+Cypress.Commands.add(
+ "confirmVoucherCallTest",
+ (confirmBody, data, confirm, globalState) => {
+ const {
+ Configs: configs = {},
+ Request: reqData,
+ Response: resData,
+ } = data || {};
+
+ const configInfo = execConfig(validateConfig(configs));
+ const paymentIntentID = globalState.get("paymentID");
+ const profile_id = globalState.get(`${configInfo.profilePrefix}Id`);
+
+ for (const key in reqData) {
+ confirmBody[key] = reqData[key];
+ }
+ confirmBody.client_secret = globalState.get("clientSecret");
+ confirmBody.confirm = confirm;
+ confirmBody.profile_id = profile_id;
+
+ globalState.set("paymentMethodType", confirmBody.payment_method_type);
+
+ cy.request({
+ method: "POST",
+ url: `${globalState.get("baseUrl")}/payments/${paymentIntentID}/confirm`,
+ headers: {
+ "Content-Type": "application/json",
+ "api-key": globalState.get("publishableKey"),
+ },
+ failOnStatusCode: false,
+ body: confirmBody,
+ }).then((response) => {
+ logRequestId(response.headers["x-request-id"]);
+
+ cy.wrap(response).then(() => {
+ expect(response.headers["content-type"]).to.include("application/json");
+ if (response.status === 200) {
+ globalState.set("paymentID", paymentIntentID);
+
+ validateErrorMessage(response, resData);
+
+ if (
+ response.body.capture_method === "automatic" ||
+ response.body.capture_method === "manual"
+ ) {
+ if (response.body.next_action) {
+ if (response.body.next_action.display_voucher_information) {
+ globalState.set(
+ "nextActionType",
+ "display_voucher_information"
+ );
+ globalState.set("nextActionUrl", null);
+ } else if (response.body.next_action.redirect_to_url) {
+ globalState.set(
+ "nextActionUrl",
+ response.body.next_action.redirect_to_url
+ );
+ globalState.set("nextActionType", "redirect_to_url");
+ }
+ }
+
+ for (const key in resData.body) {
+ expect(resData.body[key], [key]).to.deep.equal(
+ response.body[key]
+ );
+ }
+ } else {
+ throw new Error(
+ `Invalid capture method ${response.body.capture_method}`
+ );
+ }
+ } else {
+ defaultErrorHandler(response, resData);
+ }
+ });
+ });
+ }
+);
+
+Cypress.Commands.add(
+ "handleVoucherRedirection",
+ (globalState, paymentMethodType, expectedRedirection) => {
+ const DISPLAY_ONLY_VOUCHERS = ["boleto", "oxxo", "alfamart", "indomaret"];
+ if (DISPLAY_ONLY_VOUCHERS.includes(paymentMethodType)) {
+ cy.log(
+ `Skipping cy.visit() for display-only voucher: ${paymentMethodType}`
+ );
+ return;
+ }
+
+ const nextActionType = globalState.get("nextActionType");
+ const nextActionUrl = globalState.get("nextActionUrl");
+
+ if (nextActionType === "display_voucher_information" || !nextActionUrl) {
+ cy.log(
+ `Skipping voucher redirect for ${paymentMethodType} (nextActionType: ${nextActionType}). ` +
+ `Voucher information is displayed in the API response.`
+ );
+ return;
+ }
+
+ if (RequestBodyUtils.isCI()) {
+ cy.task(
+ "cli_log",
+ `Skipping voucher redirect for ${paymentMethodType} in CI environment. ` +
+ `Voucher payment is validated via Retrieve Payment.`
+ );
+ return;
+ }
+
+ const connectorId = globalState.get("connectorId");
+ const expectedUrl = new URL(expectedRedirection);
+ const redirectionUrl = new URL(nextActionUrl);
+
+ handleRedirection(
+ "voucher",
+ { redirectionUrl, expectedUrl },
+ connectorId,
+ paymentMethodType
+ );
+ }
+);
+
Cypress.Commands.add(
"handleUpiRedirection",
(globalState, paymentMethodType, expected_redirection) => {
diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.js
index b432a8dff0..8ad8c148f0 100644
--- a/cypress-tests/cypress/support/redirectionHandler.js
+++ b/cypress-tests/cypress/support/redirectionHandler.js
@@ -106,6 +106,14 @@ export function handleRedirection(
handlerMetadata?.globalState
);
break;
+ case "voucher":
+ voucherRedirection(
+ urls.redirectionUrl,
+ urls.expectedUrl,
+ resolvedConnectorId,
+ paymentMethodType
+ );
+ break;
case "payment_link_card":
paymentLinkCardRedirection(
urls.redirectionUrl,
@@ -2426,6 +2434,99 @@ function rewardRedirection(
});
}
+function voucherRedirection(
+ redirectionUrl,
+ expectedUrl,
+ connectorId,
+ paymentMethodType
+) {
+ let verifyUrl = false;
+
+ if (redirectionUrl && redirectionUrl.href) {
+ cy.visit(redirectionUrl.href);
+ waitForRedirect(redirectionUrl.href);
+
+ handleFlow(
+ redirectionUrl,
+ expectedUrl,
+ connectorId,
+ ({ connectorId, paymentMethodType, constants }) => {
+ switch (connectorId) {
+ case "adyen":
+ switch (paymentMethodType) {
+ case "boleto":
+ case "oxxo":
+ case "alfamart":
+ case "indomaret":
+ // display_voucher_information vouchers — never reach here because
+ // handleVoucherRedirection skips the redirect step entirely
+ cy.log(
+ `Unexpected redirect for display_voucher_information voucher: ${paymentMethodType}`
+ );
+ verifyUrl = false;
+ break;
+ case "seven_eleven":
+ case "lawson":
+ case "mini_stop":
+ case "family_mart":
+ case "seicomart":
+ case "pay_easy":
+ // Adyen voucher redirect pages show branded Japanese-language
+ // payment receipts. They are NOT Acquirer Simulator pages.
+ // Just verify the page loads with voucher content.
+ cy.get("body", { timeout: constants.TIMEOUT }).should("exist");
+ // Voucher pages have a non-standard h1 (often a full-width
+ // space) so we avoid asserting on heading text. Instead
+ // confirm that page load succeeded by checking for known
+ // vendor logos or Japanese payment terminology.
+ cy.get("body").then(($body) => {
+ const bodyText = $body.text();
+ const voucherIndicators = [
+ /お支払い/i,
+ /払込/i,
+ /セブン|lawson|ミニストップ|ファミリーマート|セイコーマート|ペイジー/i,
+ /お客様名/i,
+ /前払い/i,
+ /\u3000/, // full-width space
+ ];
+ const isVoucherPage = voucherIndicators.some((pat) =>
+ pat.test(bodyText)
+ );
+ if (isVoucherPage) {
+ cy.log(
+ `Verified Adyen voucher redirect page loaded for ${paymentMethodType}`
+ );
+ } else {
+ cy.log(
+ `Warning: Voucher page content not recognized for ${paymentMethodType}. Body length: ${bodyText.length}`
+ );
+ }
+ });
+ verifyUrl = false;
+ break;
+ default:
+ cy.log(`Unhandled Adyen voucher type: ${paymentMethodType}`);
+ verifyUrl = false;
+ }
+ break;
+ default:
+ cy.log(
+ `Generic voucher handling for ${connectorId}/${paymentMethodType}`
+ );
+ verifyUrl = false;
+ }
+ },
+ { paymentMethodType }
+ );
+ } else {
+ cy.log("Skipping voucher redirection - no valid redirect URL provided");
+ }
+
+ cy.then(() => {
+ verifyReturnUrl(redirectionUrl, expectedUrl, verifyUrl);
+ });
+}
+
function verifyReturnUrl(redirectionUrl, expectedUrl, forwardFlow) {
if (!forwardFlow) {
cy.log("Skipping return URL verification as forwardFlow is false.");