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
fix(cypress): Update ExtendAuthorization spec for Adyen async and PayPal sync flows (#12123)
HS-QUALIBOTf12084ae141b
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Adyen.js b/cypress-tests/cypress/e2e/configs/Payment/Adyen.jsindex 9184a75f83..01cfb1b931 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Adyen.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Adyen.js@@ -306,6 +306,38 @@ export const connectorDetails = {},},},+ ExtendAuthorizationNo3DSManual: {+ Request: {+ extended_authorization_days: 7,+ },+ Response: {+ status: 200,+ body: {+ status: "processing", // Adyen: Extend Authorization is async, returns processing+ amount: 6000,+ amount_capturable: 6000,+ amount_received: null,+ request_extended_authorization: true,+ },+ },+ // Adyen: Extend Authorization is async (processing), capture is skipped+ },+ ExtendAuthorizationInvalidStatus: {+ Request: {+ extended_authorization_days: 7,+ },+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ message:+ "You cannot extend authorization this payment because it has status succeeded",+ code: "IR_16",+ },+ },+ },+ },MandateSingleUse3DSAutoCapture: {Request: {payment_method: "card",diff --git a/cypress-tests/cypress/e2e/configs/Payment/Paypal.js b/cypress-tests/cypress/e2e/configs/Payment/Paypal.jsindex 3c5b9f26a1..0ce041b30e 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Paypal.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Paypal.js@@ -296,6 +296,37 @@ export const connectorDetails = {},},},+ ExtendAuthorizationNo3DSManual: {+ Request: {+ extended_authorization_days: 7,+ },+ Response: {+ status: 200,+ body: {+ status: "requires_capture",+ amount: 6000,+ amount_capturable: 6000,+ amount_received: null,+ request_extended_authorization: true,+ },+ },+ },+ ExtendAuthorizationInvalidStatus: {+ Request: {+ extended_authorization_days: 7,+ },+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ message:+ "You cannot extend authorization this payment because it has status succeeded",+ code: "IR_16",+ },+ },+ },+ },ZeroAuthMandate: {Request: {payment_method: "card",diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.jsindex 8d22dcd717..edaaf9251a 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js@@ -545,6 +545,7 @@ export const CONNECTOR_LISTS = {EXTERNAL_THREE_DS: ["stripe", "finix"],BANK_DEBIT: ["novalnet"],PARTNER_MERCHANT_IDENTIFIER: ["adyen", "checkout"],+ EXTEND_AUTHORIZATION: ["adyen", "paypal"],GIFT_CARD: ["adyen"],PAY_LATER: ["klarna", "adyen", "aci", "stripe"],AUTH_SERVICE_ELIGIBILITY: ["stripe", "cybersource"],diff --git a/cypress-tests/cypress/e2e/spec/Payment/46-ExtendAuthorization.cy.js b/cypress-tests/cypress/e2e/spec/Payment/46-ExtendAuthorization.cy.jsnew file mode 100644index 0000000000..942f2ed128--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Payment/46-ExtendAuthorization.cy.js@@ -0,0 +1,167 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";++let connector;+let globalState;++describe("[Payment] Extend Authorization", () => {+ before(function () {+ let skip = false;++ cy.task("getGlobalState")+ .then((state) => {+ globalState = new State(state);+ connector = globalState.get("connectorId");+ // Skip the test if the connector is not in the inclusion list+ if (+ utils.shouldIncludeConnector(+ connector,+ utils.CONNECTOR_LISTS.INCLUDE.EXTEND_AUTHORIZATION+ )+ ) {+ skip = true;+ }+ })+ .then(() => {+ if (skip) {+ this.skip();+ }+ });+ });++ afterEach("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ context("[Payment] Extend Authorization - Happy Path", () => {+ let shouldContinue = true;++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("[Payment] Create Payment Intent", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ const newData = {+ ...data,+ Request: {+ ...data.Request,+ request_extended_authorization: true,+ },+ };++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ newData,+ "no_three_ds",+ "manual",+ globalState+ );++ if (shouldContinue) {+ shouldContinue = utils.should_continue_further(data);+ }+ });++ it("[Payment] Confirm Payment Intent", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSManualCapture"];++ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);++ if (shouldContinue) {+ shouldContinue = utils.should_continue_further(data);+ }+ });++ it("[Payment] Extend Authorization", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["ExtendAuthorizationNo3DSManual"];++ cy.extendAuthorizationCallTest(+ fixtures.extendAuthBody,+ data,+ globalState+ );++ if (shouldContinue) {+ shouldContinue = utils.should_continue_further(data);+ }+ });++ it("[Payment] Connector Specific Behavior", () => {+ cy.extendAuthorizationPostCallTest(fixtures, globalState);+ });+ });++ context(+ "[Payment] Extend Authorization - Negative Case - Invalid Status",+ () => {+ let shouldContinue = true;++ beforeEach(function () {+ if (!shouldContinue) {+ this.skip();+ }+ });++ it("[Payment] Create Payment Intent", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ const newData = {+ ...data,+ Request: {+ ...data.Request,+ request_extended_authorization: true,+ },+ };++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ newData,+ "no_three_ds",+ "automatic",+ globalState+ );++ if (shouldContinue) {+ shouldContinue = utils.should_continue_further(data);+ }+ });++ it("[Payment] Confirm Payment Intent (Auto Capture)", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];++ cy.confirmCallTest(fixtures.confirmBody, data, true, globalState);++ if (shouldContinue) {+ shouldContinue = utils.should_continue_further(data);+ }+ });++ it("[Payment] Extend Authorization - Should Fail (Payment Succeeded)", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["ExtendAuthorizationInvalidStatus"];++ cy.extendAuthorizationCallTest(+ fixtures.extendAuthBody,+ data,+ globalState+ );+ });+ }+ );+});diff --git a/cypress-tests/cypress/fixtures/extend-auth-body.json b/cypress-tests/cypress/fixtures/extend-auth-body.jsonnew file mode 100644index 0000000000..04e1ced37e--- /dev/null+++ b/cypress-tests/cypress/fixtures/extend-auth-body.json@@ -0,0 +1,3 @@+{+ "extended_authorization_days": 7+}diff --git a/cypress-tests/cypress/fixtures/imports.js b/cypress-tests/cypress/fixtures/imports.jsindex 9797131564..4b913d373d 100644--- a/cypress-tests/cypress/fixtures/imports.js+++ b/cypress-tests/cypress/fixtures/imports.js@@ -28,6 +28,7 @@ import blocklistCreateBody from "./blocklist-create-body.json";import disputeEvidenceBody from "./dispute-evidence-body.json";import cardLimitedDataMITBody from "./create-card-limited-data-mit.json";import eligibilityCheckBody from "./eligibility-check-body.json";+import extendAuthBody from "./extend-auth-body.json";import * as IncomingWebhookBody from "./webhooks/import";import customerCreate from "./modularPmService/modularPmServiceCustomerCreate.json";import paymentMethodCreate from "./modularPmService/modular-pm-service-pm-create.json";@@ -54,6 +55,7 @@ export {customerUpdateBody,disputeEvidenceBody,eligibilityCheckBody,+ extendAuthBody,gsmBody,listRefundCall,merchantCreateBody,diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 27b1b87264..ecfcee0382 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -24,7 +24,7 @@// -- This will overwrite an existing command --// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })// commands.js or your custom support file-import {+import getConnectorDetails, {defaultErrorHandler,extractIntegerAtEnd,getOriginalConnectorName,@@ -5437,6 +5437,77 @@ Cypress.Commands.add("incrementalAuth", (globalState, data) => {});});+Cypress.Commands.add(+ "extendAuthorizationCallTest",+ (requestBody, data, globalState) => {+ const {+ Configs: configs = {},+ Response: resData,+ Request: reqData,+ } = data || {};++ const configInfo = execConfig(validateConfig(configs));+ const payment_id = globalState.get("paymentID");+ const profile_id = globalState.get(`${configInfo.profilePrefix}Id`);++ requestBody.profile_id = profile_id;++ for (const key in reqData) {+ requestBody[key] = reqData[key];+ }++ const headers = {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ };++ cy.request({+ method: "POST",+ url: `${globalState.get("baseUrl")}/payments/${payment_id}/extend_authorization`,+ headers,+ failOnStatusCode: false,+ body: requestBody,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);+ storeRequestId(response.headers["x-request-id"], globalState);++ cy.wrap(response).then(() => {+ expect(response.headers["content-type"]).to.include("application/json");++ if (response.status === 200) {+ for (const key in resData.body) {+ if (key !== "extended_authorization_expires_at") {+ expect(resData.body[key]).to.equal(response.body[key]);+ }+ }++ expect(response.body.request_extended_authorization).to.equal(true);+ expect(response.body).to.have.property("expires_on");+ } else {+ defaultErrorHandler(response, resData);+ }+ });+ });+ }+);++Cypress.Commands.add(+ "extendAuthorizationPostCallTest",+ (fixtures, globalState) => {+ const connector = globalState.get("connectorId");+ if (connector === "adyen") {+ const data =+ getConnectorDetails(connector)["card_pm"][+ "ExtendAuthorizationNo3DSManual"+ ];+ cy.retrievePaymentCallTest({ globalState, data });+ } else if (connector === "paypal") {+ const data = getConnectorDetails(connector)["card_pm"]["Capture"];+ cy.captureCallTest(fixtures.captureBody, data, globalState);+ }+ }+);+Cypress.Commands.add("setConfigs", (globalState, key, value, requestType) => {if (!key || !requestType) {throw new Error("Key and requestType are required parameters");