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): Platform Refund for stripe (#11876)
HS-QUALIBOTb02ee626206d
diff --git a/cypress-tests/cypress/e2e/spec/Platform/00012-RefundPayment.cy.js b/cypress-tests/cypress/e2e/spec/Platform/00012-RefundPayment.cy.jsnew file mode 100644index 0000000000..3ecf8adfef--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Platform/00012-RefundPayment.cy.js@@ -0,0 +1,1437 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";++let globalState;++describe("Platform - Card Refund Payment flow test", () => {+ before("seed global state", () => {+ cy.task("getGlobalState").then((state) => {+ globalState = new State(state);+ });+ });++ after("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ context(+ "Platform acts on behalf of Connected Merchant 1 - Full Refund for Auto-Capture payment",+ () => {+ let savedApiKey,+ savedPublishableKey,+ savedProfileId,+ savedMerchantConnectorId;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ savedPublishableKey = globalState.get("publishableKey");+ savedProfileId = globalState.get("profileId");+ savedMerchantConnectorId = globalState.get("merchantConnectorId");++ globalState.set("apiKey", globalState.get("platformApiKey"));+ globalState.set(+ "publishableKey",+ globalState.get("platformPublishableKey")+ );+ globalState.set("profileId", globalState.get("profileIdCm1"));+ globalState.set(+ "merchantConnectorId",+ globalState.get("connectorIdCm1")+ );+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ globalState.set("publishableKey", savedPublishableKey);+ globalState.set("profileId", savedProfileId);+ globalState.set("merchantConnectorId", savedMerchantConnectorId);+ });++ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> Refund Payment -> Sync Refund Payment", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent for CM1 using header", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Payment Methods Call", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Payment Methods Call");+ return;+ }+ const savedPublishableKey = globalState.get("publishableKey");+ globalState.set(+ "publishableKey",+ globalState.get("publishableKeyCm1")+ );+ cy.paymentMethodsCallTest(globalState).then(() => {+ globalState.set("publishableKey", savedPublishableKey);+ });+ });++ cy.step("Confirm Payment Intent for CM1 using header", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ data,+ true,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Confirmation"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];++ cy.retrievePaymentCallTest({+ globalState,+ connectedMerchantId: globalState.get("connectedMerchantId1"),+ data,+ });++ if (!utils.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")+ )["card_pm"]["Refund"];++ cy.refundCallTest(+ fixtures.refundBody,+ refundData,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ 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")+ )["card_pm"]["SyncRefund"];++ cy.syncRefundCallTest(+ syncRefundData,+ globalState,+ globalState.get("connectedMerchantId1")+ );+ });+ });+ }+ );++ context(+ "Connected Merchant 2 makes own payment - Full Refund for Auto-Capture payment",+ () => {+ let savedApiKey, savedPublishableKey, savedMerchantConnectorId;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ savedPublishableKey = globalState.get("publishableKey");+ savedMerchantConnectorId = globalState.get("merchantConnectorId");++ globalState.set("apiKey", globalState.get("apiKeyCm2"));+ globalState.set("publishableKey", globalState.get("publishableKeyCm2"));+ globalState.set(+ "merchantConnectorId",+ globalState.get("connectorIdCm2")+ );+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ globalState.set("publishableKey", savedPublishableKey);+ globalState.set("merchantConnectorId", savedMerchantConnectorId);+ });++ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> Refund Payment -> Sync Refund Payment", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Payment Methods Call", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Payment Methods Call");+ return;+ }+ cy.paymentMethodsCallTest(globalState);+ });++ cy.step("Confirm Payment Intent", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const confirmData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["No3DSAutoCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ confirmData,+ true,+ globalState+ );++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Confirmation"+ );+ return;+ }+ const confirmData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["No3DSAutoCapture"];++ cy.retrievePaymentCallTest({ globalState, data: confirmData });++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Refund Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Refund Payment");+ return;+ }+ const refundData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["Refund"];++ cy.refundCallTest(fixtures.refundBody, refundData, 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")+ )["card_pm"]["SyncRefund"];++ cy.syncRefundCallTest(syncRefundData, globalState);+ });+ });+ }+ );++ context(+ "Platform acts on behalf of Connected Merchant 1 - Partial Refund for Auto-Capture payment",+ () => {+ let savedApiKey,+ savedPublishableKey,+ savedProfileId,+ savedMerchantConnectorId;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ savedPublishableKey = globalState.get("publishableKey");+ savedProfileId = globalState.get("profileId");+ savedMerchantConnectorId = globalState.get("merchantConnectorId");++ globalState.set("apiKey", globalState.get("platformApiKey"));+ globalState.set(+ "publishableKey",+ globalState.get("platformPublishableKey")+ );+ globalState.set("profileId", globalState.get("profileIdCm1"));+ globalState.set(+ "merchantConnectorId",+ globalState.get("connectorIdCm1")+ );+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ globalState.set("publishableKey", savedPublishableKey);+ globalState.set("profileId", savedProfileId);+ globalState.set("merchantConnectorId", savedMerchantConnectorId);+ });++ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> Partial Refund Payment -> Partial Refund Payment - 2nd Attempt -> Sync Refund Payment", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent for CM1 using header", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Payment Methods Call", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Payment Methods Call");+ return;+ }+ const savedPublishableKey = globalState.get("publishableKey");+ globalState.set(+ "publishableKey",+ globalState.get("publishableKeyCm1")+ );+ cy.paymentMethodsCallTest(globalState).then(() => {+ globalState.set("publishableKey", savedPublishableKey);+ });+ });++ cy.step("Confirm Payment Intent for CM1 using header", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ data,+ true,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Confirmation"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSAutoCapture"];++ cy.retrievePaymentCallTest({+ globalState,+ connectedMerchantId: globalState.get("connectedMerchantId1"),+ data,+ });++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Partial Refund Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Partial Refund Payment");+ return;+ }+ const partialRefundData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["PartialRefund"];++ cy.refundCallTest(+ fixtures.refundBody,+ partialRefundData,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(partialRefundData)) {+ shouldContinue = false;+ }+ });++ cy.step("Partial Refund Payment - 2nd Attempt", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Partial Refund Payment - 2nd Attempt"+ );+ return;+ }+ const partialRefundData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["PartialRefund"];++ cy.refundCallTest(+ fixtures.refundBody,+ partialRefundData,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(partialRefundData)) {+ 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")+ )["card_pm"]["SyncRefund"];++ cy.syncRefundCallTest(+ syncRefundData,+ globalState,+ globalState.get("connectedMerchantId1")+ );+ });+ });+ }+ );++ context(+ "Connected Merchant 2 makes own payment - Partial Refund for Auto-Capture payment",+ () => {+ let savedApiKey, savedPublishableKey, savedMerchantConnectorId;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ savedPublishableKey = globalState.get("publishableKey");+ savedMerchantConnectorId = globalState.get("merchantConnectorId");++ globalState.set("apiKey", globalState.get("apiKeyCm2"));+ globalState.set("publishableKey", globalState.get("publishableKeyCm2"));+ globalState.set(+ "merchantConnectorId",+ globalState.get("connectorIdCm2")+ );+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ globalState.set("publishableKey", savedPublishableKey);+ globalState.set("merchantConnectorId", savedMerchantConnectorId);+ });++ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> Partial Refund Payment -> Partial Refund Payment - 2nd Attempt -> Sync Refund Payment", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Payment Methods Call", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Payment Methods Call");+ return;+ }+ cy.paymentMethodsCallTest(globalState);+ });++ cy.step("Confirm Payment Intent", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const confirmData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["No3DSAutoCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ confirmData,+ true,+ globalState+ );++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Confirmation"+ );+ return;+ }+ const confirmData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["No3DSAutoCapture"];++ cy.retrievePaymentCallTest({ globalState, data: confirmData });++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Partial Refund Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Partial Refund Payment");+ return;+ }+ const partialRefundData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["PartialRefund"];++ cy.refundCallTest(+ fixtures.refundBody,+ partialRefundData,+ globalState+ );++ if (!utils.should_continue_further(partialRefundData)) {+ shouldContinue = false;+ }+ });++ cy.step("Partial Refund Payment - 2nd Attempt", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Partial Refund Payment - 2nd Attempt"+ );+ return;+ }+ const partialRefundData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["PartialRefund"];++ cy.refundCallTest(+ fixtures.refundBody,+ partialRefundData,+ globalState+ );++ if (!utils.should_continue_further(partialRefundData)) {+ 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")+ )["card_pm"]["SyncRefund"];++ cy.syncRefundCallTest(syncRefundData, globalState);+ });+ });+ }+ );++ context(+ "Platform acts on behalf of Connected Merchant 1 - Full Refund for Manual-Capture payment",+ () => {+ let savedApiKey,+ savedPublishableKey,+ savedProfileId,+ savedMerchantConnectorId;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ savedPublishableKey = globalState.get("publishableKey");+ savedProfileId = globalState.get("profileId");+ savedMerchantConnectorId = globalState.get("merchantConnectorId");++ globalState.set("apiKey", globalState.get("platformApiKey"));+ globalState.set(+ "publishableKey",+ globalState.get("platformPublishableKey")+ );+ globalState.set("profileId", globalState.get("profileIdCm1"));+ globalState.set(+ "merchantConnectorId",+ globalState.get("connectorIdCm1")+ );+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ globalState.set("publishableKey", savedPublishableKey);+ globalState.set("profileId", savedProfileId);+ globalState.set("merchantConnectorId", savedMerchantConnectorId);+ });++ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> Capture Payment -> Retrieve Payment after Capture -> Refund Payment -> Sync Refund Payment", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent for CM1 using header", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "manual",+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Payment Methods Call", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Payment Methods Call");+ return;+ }+ const savedPublishableKey = globalState.get("publishableKey");+ globalState.set(+ "publishableKey",+ globalState.get("publishableKeyCm1")+ );+ cy.paymentMethodsCallTest(globalState).then(() => {+ globalState.set("publishableKey", savedPublishableKey);+ });+ });++ cy.step("Confirm Payment Intent for CM1 using header", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSManualCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ data,+ true,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Confirmation"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSManualCapture"];++ cy.retrievePaymentCallTest({+ globalState,+ connectedMerchantId: globalState.get("connectedMerchantId1"),+ data,+ });++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Capture Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Capture Payment");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["Capture"];++ cy.captureCallTest(+ fixtures.captureBody,+ captureData,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(captureData)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Capture", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Retrieve Payment after Capture");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["Capture"];++ cy.retrievePaymentCallTest({+ globalState,+ connectedMerchantId: globalState.get("connectedMerchantId1"),+ data: captureData,+ });++ if (!utils.should_continue_further(captureData)) {+ shouldContinue = false;+ }+ });++ cy.step("Refund Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Refund Payment");+ return;+ }+ const refundData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["manualPaymentRefund"];+ const newRefundData = {+ ...refundData,+ Response: refundData.ResponseCustom || refundData.Response,+ };++ cy.refundCallTest(+ fixtures.refundBody,+ newRefundData,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ 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")+ )["card_pm"]["SyncRefund"];++ cy.syncRefundCallTest(+ syncRefundData,+ globalState,+ globalState.get("connectedMerchantId1")+ );+ });+ });+ }+ );++ context(+ "Connected Merchant 2 makes own payment - Full Refund for Manual-Capture payment",+ () => {+ let savedApiKey, savedPublishableKey, savedMerchantConnectorId;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ savedPublishableKey = globalState.get("publishableKey");+ savedMerchantConnectorId = globalState.get("merchantConnectorId");++ globalState.set("apiKey", globalState.get("apiKeyCm2"));+ globalState.set("publishableKey", globalState.get("publishableKeyCm2"));+ globalState.set(+ "merchantConnectorId",+ globalState.get("connectorIdCm2")+ );+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ globalState.set("publishableKey", savedPublishableKey);+ globalState.set("merchantConnectorId", savedMerchantConnectorId);+ });++ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> Capture Payment -> Retrieve Payment after Capture -> Refund Payment -> Sync Refund Payment", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "manual",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Payment Methods Call", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Payment Methods Call");+ return;+ }+ cy.paymentMethodsCallTest(globalState);+ });++ cy.step("Confirm Payment Intent", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const confirmData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["No3DSManualCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ confirmData,+ true,+ globalState+ );++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Confirmation"+ );+ return;+ }+ const confirmData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["No3DSManualCapture"];++ cy.retrievePaymentCallTest({ globalState, data: confirmData });++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Capture Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Capture Payment");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["Capture"];++ cy.captureCallTest(fixtures.captureBody, captureData, globalState);++ if (!utils.should_continue_further(captureData)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Capture", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Retrieve Payment after Capture");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["Capture"];++ cy.retrievePaymentCallTest({ globalState, data: captureData });++ if (!utils.should_continue_further(captureData)) {+ shouldContinue = false;+ }+ });++ cy.step("Refund Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Refund Payment");+ return;+ }+ const refundData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["manualPaymentRefund"];+ 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")+ )["card_pm"]["SyncRefund"];++ cy.syncRefundCallTest(syncRefundData, globalState);+ });+ });+ }+ );++ context(+ "Platform acts on behalf of Connected Merchant 1 - Partial Refund for Manual-Capture payment",+ () => {+ let savedApiKey,+ savedPublishableKey,+ savedProfileId,+ savedMerchantConnectorId;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ savedPublishableKey = globalState.get("publishableKey");+ savedProfileId = globalState.get("profileId");+ savedMerchantConnectorId = globalState.get("merchantConnectorId");++ globalState.set("apiKey", globalState.get("platformApiKey"));+ globalState.set(+ "publishableKey",+ globalState.get("platformPublishableKey")+ );+ globalState.set("profileId", globalState.get("profileIdCm1"));+ globalState.set(+ "merchantConnectorId",+ globalState.get("connectorIdCm1")+ );+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ globalState.set("publishableKey", savedPublishableKey);+ globalState.set("profileId", savedProfileId);+ globalState.set("merchantConnectorId", savedMerchantConnectorId);+ });++ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> Capture Payment -> Retrieve Payment after Capture -> Partial Refund Payment -> Partial Refund Payment - 2nd Attempt -> Sync Refund Payment -> List Refunds", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent for CM1 using header", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "manual",+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Payment Methods Call", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Payment Methods Call");+ return;+ }+ const savedPublishableKey = globalState.get("publishableKey");+ globalState.set(+ "publishableKey",+ globalState.get("publishableKeyCm1")+ );+ cy.paymentMethodsCallTest(globalState).then(() => {+ globalState.set("publishableKey", savedPublishableKey);+ });+ });++ cy.step("Confirm Payment Intent for CM1 using header", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSManualCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ data,+ true,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Confirmation"+ );+ return;+ }+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["No3DSManualCapture"];++ cy.retrievePaymentCallTest({+ globalState,+ connectedMerchantId: globalState.get("connectedMerchantId1"),+ data,+ });++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Capture Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Capture Payment");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["Capture"];++ cy.captureCallTest(+ fixtures.captureBody,+ captureData,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(captureData)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Capture", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Retrieve Payment after Capture");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["Capture"];++ cy.retrievePaymentCallTest({+ globalState,+ connectedMerchantId: globalState.get("connectedMerchantId1"),+ data: captureData,+ });++ if (!utils.should_continue_further(captureData)) {+ shouldContinue = false;+ }+ });++ cy.step("Partial Refund Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Partial Refund Payment");+ return;+ }+ const partialRefundData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["manualPaymentPartialRefund"];+ const newPartialRefundData = {+ ...partialRefundData,+ Response:+ partialRefundData.ResponseCustom || partialRefundData.Response,+ };++ cy.refundCallTest(+ fixtures.refundBody,+ newPartialRefundData,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(partialRefundData)) {+ shouldContinue = false;+ }+ });++ cy.step("Partial Refund Payment - 2nd Attempt", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Partial Refund Payment - 2nd Attempt"+ );+ return;+ }+ const partialRefundData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["manualPaymentPartialRefund"];+ const newPartialRefundData = {+ ...partialRefundData,+ Response:+ partialRefundData.ResponseCustom || partialRefundData.Response,+ };++ cy.refundCallTest(+ fixtures.refundBody,+ newPartialRefundData,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ if (!utils.should_continue_further(partialRefundData)) {+ 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")+ )["card_pm"]["SyncRefund"];++ cy.syncRefundCallTest(+ syncRefundData,+ globalState,+ globalState.get("connectedMerchantId1")+ );++ 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,+ globalState.get("connectedMerchantId1")+ );+ });+ });+ }+ );++ context(+ "Connected Merchant 2 makes own payment - Partial Refund for Manual-Capture payment",+ () => {+ let savedApiKey, savedPublishableKey, savedMerchantConnectorId;++ before(() => {+ savedApiKey = globalState.get("apiKey");+ savedPublishableKey = globalState.get("publishableKey");+ savedMerchantConnectorId = globalState.get("merchantConnectorId");++ globalState.set("apiKey", globalState.get("apiKeyCm2"));+ globalState.set("publishableKey", globalState.get("publishableKeyCm2"));+ globalState.set(+ "merchantConnectorId",+ globalState.get("connectorIdCm2")+ );+ });++ after(() => {+ globalState.set("apiKey", savedApiKey);+ globalState.set("publishableKey", savedPublishableKey);+ globalState.set("merchantConnectorId", savedMerchantConnectorId);+ });++ it("Create Payment Intent -> Payment Methods Call -> Confirm Payment Intent -> Retrieve Payment after Confirmation -> Capture Payment -> Retrieve Payment after Capture -> Partial Refund Payment -> Partial Refund Payment - 2nd Attempt -> Sync Refund Payment -> List Refunds", () => {+ let shouldContinue = true;++ cy.step("Create Payment Intent", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["PaymentIntent"];++ cy.createPaymentIntentTest(+ fixtures.createPaymentBody,+ data,+ "no_three_ds",+ "manual",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Payment Methods Call", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Payment Methods Call");+ return;+ }+ cy.paymentMethodsCallTest(globalState);+ });++ cy.step("Confirm Payment Intent", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Confirm Payment Intent");+ return;+ }+ const confirmData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["No3DSManualCapture"];++ cy.confirmCallTest(+ fixtures.confirmBody,+ confirmData,+ true,+ globalState+ );++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Confirmation", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Retrieve Payment after Confirmation"+ );+ return;+ }+ const confirmData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["No3DSManualCapture"];++ cy.retrievePaymentCallTest({ globalState, data: confirmData });++ if (!utils.should_continue_further(confirmData)) {+ shouldContinue = false;+ }+ });++ cy.step("Capture Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Capture Payment");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["Capture"];++ cy.captureCallTest(fixtures.captureBody, captureData, globalState);++ if (!utils.should_continue_further(captureData)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment after Capture", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Retrieve Payment after Capture");+ return;+ }+ const captureData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["Capture"];++ cy.retrievePaymentCallTest({ globalState, data: captureData });++ if (!utils.should_continue_further(captureData)) {+ shouldContinue = false;+ }+ });++ cy.step("Partial Refund Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Partial Refund Payment");+ return;+ }+ const partialRefundData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["manualPaymentPartialRefund"];+ const newPartialRefundData = {+ ...partialRefundData,+ Response:+ partialRefundData.ResponseCustom || partialRefundData.Response,+ };++ cy.refundCallTest(+ fixtures.refundBody,+ newPartialRefundData,+ globalState+ );++ if (!utils.should_continue_further(partialRefundData)) {+ shouldContinue = false;+ }+ });++ cy.step("Partial Refund Payment - 2nd Attempt", () => {+ if (!shouldContinue) {+ cy.task(+ "cli_log",+ "Skipping step: Partial Refund Payment - 2nd Attempt"+ );+ return;+ }+ const partialRefundData = getConnectorDetails(+ globalState.get("connectorId")+ )["card_pm"]["manualPaymentPartialRefund"];+ const newPartialRefundData = {+ ...partialRefundData,+ Response:+ partialRefundData.ResponseCustom || partialRefundData.Response,+ };++ cy.refundCallTest(+ fixtures.refundBody,+ newPartialRefundData,+ globalState+ );++ if (!utils.should_continue_further(partialRefundData)) {+ 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")+ )["card_pm"]["SyncRefund"];++ 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);+ });+ });+ }+ );+});diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 59284e3ee9..23a99b72ac 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -3469,78 +3469,102 @@ Cypress.Commands.add(});-Cypress.Commands.add("refundCallTest", (requestBody, data, globalState) => {- const {- Configs: configs = {},- Request: reqData,- Response: resData,- } = data || {};+Cypress.Commands.add(+ "refundCallTest",+ (requestBody, data, globalState, connectedMerchantId) => {+ const {+ Configs: configs = {},+ Request: reqData,+ Response: resData,+ } = data || {};- const payment_id = globalState.get("paymentID");+ const payment_id = globalState.get("paymentID");- // we only need this to set the delay. We don't need the return value- execConfig(validateConfig(configs));+ // we only need this to set the delay. We don't need the return value+ execConfig(validateConfig(configs));- for (const key in reqData) {- requestBody[key] = reqData[key];- }- requestBody.payment_id = payment_id;+ for (const key in reqData) {+ requestBody[key] = reqData[key];+ }+ requestBody.payment_id = payment_id;- cy.request({- method: "POST",- url: `${globalState.get("baseUrl")}/refunds`,- headers: {+ const headers = {"Content-Type": "application/json","api-key": globalState.get("apiKey"),- },- failOnStatusCode: false,- body: requestBody,- }).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("refundId", response.body.refund_id);- globalState.set("connectorRefundId", response.body.connector_refund_id);- for (const key in resData.body) {- expect(resData.body[key]).to.equal(response.body[key]);+ if (connectedMerchantId) {+ headers["x-connected-merchant-id"] = connectedMerchantId;+ }++ cy.request({+ method: "POST",+ url: `${globalState.get("baseUrl")}/refunds`,+ headers,+ failOnStatusCode: false,+ body: requestBody,+ }).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("refundId", response.body.refund_id);+ globalState.set(+ "connectorRefundId",+ response.body.connector_refund_id+ );+ for (const key in resData.body) {+ expect(resData.body[key]).to.equal(response.body[key]);+ }+ expect(response.body.payment_id).to.equal(payment_id);+ } else {+ defaultErrorHandler(response, resData);}- expect(response.body.payment_id).to.equal(payment_id);- } else {- defaultErrorHandler(response, resData);- }+ });});- });-});+ }+);-Cypress.Commands.add("syncRefundCallTest", (data, globalState) => {- const { Response: resData } = data || {};+Cypress.Commands.add(+ "syncRefundCallTest",+ (data, globalState, connectedMerchantId) => {+ const { Response: resData } = data || {};- const refundId = globalState.get("refundId");+ const refundId = globalState.get("refundId");- cy.request({- method: "GET",- url: `${globalState.get("baseUrl")}/refunds/${refundId}`,- headers: {+ const headers = {"Content-Type": "application/json","api-key": globalState.get("apiKey"),- },- failOnStatusCode: false,- }).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("connectorRefundId", response.body.connector_refund_id);- }- for (const key in resData.body) {- expect(resData.body[key]).to.equal(response.body[key]);- }+ if (connectedMerchantId) {+ headers["x-connected-merchant-id"] = connectedMerchantId;+ }++ cy.request({+ method: "GET",+ url: `${globalState.get("baseUrl")}/refunds/${refundId}`,+ headers,+ failOnStatusCode: false,+ }).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(+ "connectorRefundId",+ response.body.connector_refund_id+ );+ }+ for (const key in resData.body) {+ expect(resData.body[key]).to.equal(response.body[key]);+ }+ });});- });-});+ }+);Cypress.Commands.add("citForMandatesCallTest",@@ -4638,24 +4662,33 @@ Cypress.Commands.add("listCustomerPMByClientSecret", (globalState) => {});});-Cypress.Commands.add("listRefundCallTest", (requestBody, globalState) => {- cy.request({- method: "POST",- url: `${globalState.get("baseUrl")}/refunds/list`,- headers: {+Cypress.Commands.add(+ "listRefundCallTest",+ (requestBody, globalState, connectedMerchantId) => {+ const headers = {"Content-Type": "application/json","api-key": globalState.get("apiKey"),- },- body: requestBody,- }).then((response) => {- logRequestId(response.headers["x-request-id"]);+ };- cy.wrap(response).then(() => {- expect(response.headers["content-type"]).to.include("application/json");- expect(response.body.data).to.be.an("array").and.not.empty;+ if (connectedMerchantId) {+ headers["x-connected-merchant-id"] = connectedMerchantId;+ }++ cy.request({+ method: "POST",+ url: `${globalState.get("baseUrl")}/refunds/list`,+ headers,+ body: requestBody,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ expect(response.headers["content-type"]).to.include("application/json");+ expect(response.body.data).to.be.an("array").and.not.empty;+ });});- });-});+ }+);Cypress.Commands.add("createConfirmPayoutTest",