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 refund coverage for facilitapay (#13275)
HS-QUALIBOTa9b723832392
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Facilitapay.js b/cypress-tests/cypress/e2e/configs/Payment/Facilitapay.jsindex d593b6b66e..9b4a3b01ac 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Facilitapay.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Facilitapay.js@@ -73,5 +73,30 @@ export const connectorDetails = {},},}),+ Refund: getCustomExchange({+ Request: {+ amount: 6000,+ },+ Response: {+ status: 200,+ body: {+ status: "succeeded",+ },+ },+ ResponseCustom: {+ status: 200,+ body: {+ status: "succeeded",+ },+ },+ }),+ SyncRefund: getCustomExchange({+ Response: {+ status: 200,+ body: {+ status: "succeeded",+ },+ },+ }),},};diff --git a/cypress-tests/cypress/e2e/spec/Payment/17-BankTransfers.cy.js b/cypress-tests/cypress/e2e/spec/Payment/17-BankTransfers.cy.jsindex a4f4b7a164..367d0f44bc 100644--- a/cypress-tests/cypress/e2e/spec/Payment/17-BankTransfers.cy.js+++ b/cypress-tests/cypress/e2e/spec/Payment/17-BankTransfers.cy.js@@ -81,6 +81,129 @@ describe("Bank Transfers", () => {});});+ context("Bank transfer - Pix Refund flow", () => {+ it("Create Payment Intent for Pix -> List Merchant Payment Methods -> Confirm Bank Transfer for Pix -> Retrieve Payment after Confirmation -> Refund Payment -> Sync Refund Payment -> List Refunds -> Retrieve Payment after Refund", () => {+ let shouldContinue = true;+ const getPixRefundData = () =>+ globalState.get("connectorId") === "facilitapay"+ ? getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["Pix"]+ : undefined;++ cy.step("Create Payment Intent for Pix", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["PaymentIntent"]("Pix");+ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "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 Bank Transfer for Pix", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Bank Transfer for Pix");+ return;+ }+ const confirmData = getPixRefundData();+ if (!confirmData) {+ shouldContinue = false;+ return;+ }+ cy.confirmBankTransferCallTest(+ fixtures.confirmBody,+ confirmData,+ true,+ globalState+ );+ });++ cy.step("Retrieve Payment after Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Confirmation"+ );+ return;+ }+ const confirmData = getPixRefundData();+ cy.retrievePaymentCallTest({ globalState, data: confirmData });+ });++ cy.step("Refund Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Refund Payment");+ return;+ }+ const refundData = getConnectorDetails(globalState.get("connectorId"))[+ "bank_transfer_pm"+ ]["Refund"];+ if (!refundData) {+ shouldContinue = false;+ return;+ }+ const newRefundData = {+ ...refundData,+ Response: refundData.ResponseCustom || refundData.Response,+ };+ cy.refundCallTest(fixtures.refundBody, newRefundData, globalState);+ if (!utils.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")+ )["bank_transfer_pm"]["SyncRefund"];+ if (!syncRefundData) {+ shouldContinue = false;+ return;+ }+ cy.syncRefundCallTest(syncRefundData, globalState);+ if (!utils.should_continue_further(syncRefundData)) {+ shouldContinue = false;+ }+ });++ cy.step("List Refunds", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: List Refunds");+ return;+ }+ cy.listRefundCallTest(fixtures.listRefundCall, globalState);+ });++ cy.step("Retrieve Payment after Refund", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Retrieve Payment after Refund");+ return;+ }+ const confirmData = getPixRefundData();+ cy.retrievePaymentCallTest({ globalState, data: confirmData });+ });+ });+ });+context("Bank transfer - Instant Bank Transfer Finland forward flow", () => {it("Create Payment Intent -> List Merchant Payment Methods -> Confirm Bank Transfer -> Handle Bank Transfer Redirection ", () => {let shouldContinue = true;diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex e5ec21aa77..09ea043a5e 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -85,6 +85,26 @@ function updateConnectorState(globalState, responseConnector) {globalState.set("connectorId", responseConnector);}+function getExpectedMerchantConnectorId(+ globalState,+ merchantConnectorPrefix,+ responseBody+) {+ const stateKey = `${merchantConnectorPrefix}Id`;+ const merchantConnectorId = globalState.get(stateKey);++ if (merchantConnectorId) {+ return merchantConnectorId;+ }++ if (responseBody?.merchant_connector_id) {+ globalState.set(stateKey, responseBody.merchant_connector_id);+ return responseBody.merchant_connector_id;+ }++ return merchantConnectorId;+}+// Helper function for creating individual rollout configfunction createIndividualRolloutConfig(methodFlow,@@ -4341,9 +4361,6 @@ Cypress.Commands.add(const { Configs: configs = {} } = data || {};const configInfo = execConfig(validateConfig(configs));- const merchant_connector_id = globalState.get(- `${configInfo.merchantConnectorPrefix}Id`- );const payment_id = globalState.get("paymentID");const headers = {@@ -4410,7 +4427,13 @@ Cypress.Commands.add(expect(response.body.merchant_connector_id,"connector_id"- ).to.equal(merchant_connector_id);+ ).to.equal(+ getExpectedMerchantConnectorId(+ globalState,+ configInfo.merchantConnectorPrefix,+ response.body+ )+ );}}