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 giftcard payment coverage for adyen (#12342)
HS-QUALIBOT009168ff2707
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Adyen.js b/cypress-tests/cypress/e2e/configs/Payment/Adyen.jsindex 0a0738583a..9dd217b0e9 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Adyen.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Adyen.js@@ -1324,6 +1324,70 @@ export const connectorDetails = {},},}),+ PaymentIntent: () => {+ return getCustomExchange({+ Request: {+ currency: "EUR",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payment_method",+ },+ },+ });+ },+ PaySafeCardGiftCard: getCustomExchange({+ Request: {+ payment_method: "gift_card",+ payment_method_type: "pay_safe_card",+ payment_method_data: {+ gift_card: {+ pay_safe_card: {},+ },+ },+ billing: {+ address: {+ line1: "1467",+ line2: "Harrison Street",+ line3: "Harrison Street",+ city: "San Francisco",+ state: "California",+ zip: "94122",+ country: "US",+ first_name: "joseph",+ last_name: "Doe",+ },+ },+ return_url: "https://example.com",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_customer_action",+ },+ },+ }),+ GivexGiftCardRefund: {+ Request: {+ amount: 1000,+ reason: "Test refund",+ },+ Response: {+ status: 200,+ body: {+ status: "pending",+ },+ },+ },+ GivexGiftCardSyncRefund: {+ Response: {+ status: 200,+ body: {+ status: "pending",+ },+ },+ },},pay_later_pm: {diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.jsindex 7dc144cf65..46e8b9fdcc 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js@@ -612,6 +612,17 @@ export const payment_methods_enabled = [recurring_enabled: false,installment_payment_enabled: false,},+ {+ payment_method_type: "pay_safe_card",+ 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,+ },],},{diff --git a/cypress-tests/cypress/e2e/spec/Payment/42-GiftCardPayment.cy.js b/cypress-tests/cypress/e2e/spec/Payment/42-GiftCardPayment.cy.jsindex cbc7fcd3a2..2df99b7d60 100644--- a/cypress-tests/cypress/e2e/spec/Payment/42-GiftCardPayment.cy.js+++ b/cypress-tests/cypress/e2e/spec/Payment/42-GiftCardPayment.cy.js@@ -3,6 +3,7 @@ import State from "../../../utils/State";import getConnectorDetails, {CONNECTOR_LISTS,shouldIncludeConnector,+ should_continue_further,} from "../../configs/Payment/Utils";let globalState;@@ -60,7 +61,7 @@ describe("Gift Card Payment - Adyen Givex", () => {);if (!shouldContinue) return;- if (data && data.Response && data.Response.status === 501) {+ if (!should_continue_further(data)) {shouldContinue = false;}});@@ -99,7 +100,7 @@ describe("Gift Card Payment - Adyen Givex", () => {);if (!shouldContinue) return;- if (data && data.Response && data.Response.status === 501) {+ if (!should_continue_further(data)) {shouldContinue = false;}}@@ -139,7 +140,7 @@ describe("Gift Card Payment - Adyen Givex", () => {);if (!shouldContinue) return;- if (data && data.Response && data.Response.status === 501) {+ if (!should_continue_further(data)) {shouldContinue = false;}}@@ -158,4 +159,143 @@ describe("Gift Card Payment - Adyen Givex", () => {});});});++ context("PaySafeCard gift card - redirect flow", () => {+ it("Create Payment Intent -> Confirm Payment -> Handle Bank Redirect Redirection -> Retrieve Payment", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "gift_card_pm"+ ]["PaymentIntent"]("PaySafeCard");++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );++ if (!shouldContinue) return;+ if (!should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Confirm Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment");+ return;+ }+ const confirmData = getConnectorDetails(globalState.get("connectorId"))[+ "gift_card_pm"+ ]["PaySafeCardGiftCard"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ confirmData,+ true,+ globalState+ );++ if (confirmData.Request && confirmData.Request.payment_method_type) {+ globalState.set(+ "paymentMethodType",+ confirmData.Request.payment_method_type+ );+ }++ if (!shouldContinue) return;+ if (!should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Handle Bank Redirect Redirection", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Handle Bank Redirect Redirection");+ return;+ }+ const expected_redirection = fixtures.confirmBody["return_url"];+ const payment_method_type = globalState.get("paymentMethodType");+ cy.handleBankRedirectRedirection(+ 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"))[+ "gift_card_pm"+ ]["PaySafeCardGiftCard"];++ cy.retrievePaymentCallTest({ globalState, data });+ });+ });+ });++ context("Givex gift card - refund flow", () => {+ it("Create and Confirm Givex Gift Card Payment -> Refund Payment -> Sync Refund Payment", () => {+ let shouldContinue = true;++ cy.step("Create and Confirm Givex Gift Card Payment", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "gift_card_pm"+ ]["GivexGiftCard"];++ cy.createConfirmPaymentTest(+ fixtures.createConfirmPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );++ if (!shouldContinue) return;+ if (!should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Refund Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Refund Payment");+ return;+ }+ const refundData = getConnectorDetails(globalState.get("connectorId"))[+ "gift_card_pm"+ ]["GivexGiftCardRefund"];++ if (!should_continue_further(refundData)) {+ shouldContinue = false;+ return;+ }++ cy.refundCallTest(fixtures.refundBody, refundData, globalState);++ if (!shouldContinue) return;+ if (!should_continue_further(refundData)) {+ shouldContinue = false;+ }+ });++ cy.step("Sync Refund Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Sync Refund Payment");+ return;+ }+ const syncRefundData = getConnectorDetails(+ globalState.get("connectorId")+ )["gift_card_pm"]["GivexGiftCardSyncRefund"];++ cy.syncRefundCallTest(syncRefundData, globalState);+ });+ });+ });});diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 206a630c78..f2da36ab2e 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -2804,6 +2804,15 @@ Cypress.Commands.add();}} else if (response.body.authentication_type === "no_three_ds") {+ if (response.body.next_action) {+ expect(response.body)+ .to.have.property("next_action")+ .to.have.property("redirect_to_url");+ globalState.set(+ "nextActionUrl",+ response.body.next_action.redirect_to_url+ );+ }for (const key in resData.body) {expect(resData.body[key], [key]).to.deep.equal(response.body[key]@@ -2850,6 +2859,15 @@ Cypress.Commands.add();}} else if (response.body.authentication_type === "no_three_ds") {+ if (response.body.next_action) {+ expect(response.body)+ .to.have.property("next_action")+ .to.have.property("redirect_to_url");+ globalState.set(+ "nextActionUrl",+ response.body.next_action.redirect_to_url+ );+ }for (const key in resData.body) {expect(resData.body[key], [key]).to.deep.equal(response.body[key]diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.jsindex 9e93d34660..bf0e95e469 100644--- a/cypress-tests/cypress/support/redirectionHandler.js+++ b/cypress-tests/cypress/support/redirectionHandler.js@@ -698,6 +698,10 @@ function bankRedirectRedirection(cy.get('[value="authorised"]').click();verifyUrl = true;break;+ case "pay_safe_card":+ cy.url().should("include", "paysafecard");+ verifyUrl = false;+ break;// The 'ideal' case is handled outside handleFlowdefault:throw new Error(