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 connector intent metadata coverage for checkout, peachpayments, stripe, worldpayxml (#14601)
HS-QUALIBOTe2ed5cbf2752
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Checkout.js b/cypress-tests/cypress/e2e/configs/Payment/Checkout.jsindex e31a43a2e2..2de5d585ae 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Checkout.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Checkout.js@@ -1018,5 +1018,117 @@ export const connectorDetails = {},},},+ ConnectorIntentMetadata: {+ Request: {+ amount: 6000,+ payment_method: "card",+ payment_method_type: "debit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ customer_acceptance: null,+ setup_future_usage: null,+ customer: {+ date_of_birth: "1990-01-31",+ },+ connector_metadata: {+ checkout: {+ purpose_of_payment: "wallet top-up",+ },+ },+ },+ // Non-AFT payment: purpose_of_payment is optional at the API level, but+ // hyperswitch validates the connector_metadata schema (unknown fields are+ // rejected with IR_06) and echoes connector_metadata back on the payment+ // response. The payment itself proceeds as a standard card payment and+ // succeeds.+ Response: {+ status: 200,+ body: {+ status: "succeeded",+ connector_metadata: {+ apple_pay: null,+ airwallex: null,+ noon: null,+ braintree: null,+ adyen: null,+ peachpayments: null,+ santander: null,+ worldpayxml: null,+ checkout: {+ purpose_of_payment: "wallet top-up",+ },+ stripe: null,+ },+ },+ },+ },+ ConnectorIntentMetadataMissing: {+ Request: {+ amount: 6000,+ payment_method: "card",+ payment_method_type: "debit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ customer_acceptance: null,+ setup_future_usage: null,+ customer: {+ date_of_birth: "1990-01-31",+ },+ is_account_funded_transaction: true,+ connector_metadata: null,+ },+ // With the AFT flag set, connector_metadata.checkout.purpose_of_payment+ // becomes a required field: hyperswitch rejects the payment with IR_04+ // before the recipient_details validation is reached, so this negative+ // is asserted without recipient_details.+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ message:+ "Missing required param: connector_metadata.checkout.purpose_of_payment",+ code: "IR_04",+ },+ },+ },+ },+ ConnectorIntentMetadataUnknownField: {+ Request: {+ amount: 6000,+ payment_method: "card",+ payment_method_type: "debit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ customer_acceptance: null,+ setup_future_usage: null,+ customer: {+ date_of_birth: "1990-01-31",+ },+ connector_metadata: {+ checkout: {+ purpose_of_payment: "wallet top-up",+ unknown_field: "x",+ },+ },+ },+ Response: {+ status: 400,+ body: {+ error: {+ error_type: "invalid_request",+ message:+ "Json deserialize error: unknown field `unknown_field`, expected `purpose_of_payment`",+ code: "IR_06",+ },+ },+ },+ },},};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Peachpayments.js b/cypress-tests/cypress/e2e/configs/Payment/Peachpayments.jsindex 6f8619714c..0671da577e 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Peachpayments.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Peachpayments.js@@ -695,5 +695,45 @@ export const connectorDetails = {},},},+ ConnectorIntentMetadata: {+ Request: {+ amount: 6000,+ payment_method: "card",+ payment_method_type: "credit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ customer_acceptance: null,+ setup_future_usage: null,+ connector_metadata: {+ peachpayments: {+ rrn: "123456789012",+ card_on_file_transaction_type: "merchant_initiated_transaction",+ },+ },+ },+ Response: {+ status: 200,+ body: {+ status: "succeeded",+ connector_metadata: {+ apple_pay: null,+ airwallex: null,+ noon: null,+ braintree: null,+ adyen: null,+ peachpayments: {+ rrn: "123456789012",+ card_on_file_transaction_type: "merchant_initiated_transaction",+ },+ santander: null,+ worldpayxml: null,+ checkout: null,+ stripe: null,+ },+ },+ },+ },},};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.jsindex c665313a99..0e293b1c79 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js@@ -834,6 +834,9 @@ export const CONNECTOR_LISTS = {ZERO_AUTH_MANDATE: ["peachpayments"],BLOCK_IMPLICIT_CUSTOMER_CREATION: ["adyen"],ERROR_ON_REQUIRES_ACTION: ["stripe"],+ AFT_PURPOSE_OF_PAYMENT: ["checkout"],+ AFT_FUNDING_TRANSACTION_TYPE: ["worldpayxml"],+ PEACHPAYMENTS_CONNECTOR_METADATA: ["peachpayments"],// Add more inclusion lists},};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Worldpayxml.js b/cypress-tests/cypress/e2e/configs/Payment/Worldpayxml.jsindex bfae74af9a..13851331ea 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Worldpayxml.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Worldpayxml.js@@ -650,5 +650,170 @@ export const connectorDetails = {},},},+ ConnectorIntentMetadata: {+ Request: {+ amount: 6000,+ payment_method: "card",+ payment_method_type: "debit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ customer_acceptance: null,+ setup_future_usage: null,+ customer: {+ date_of_birth: "1990-01-31",+ },+ connector_metadata: {+ worldpayxml: {+ funding_transaction_type: "funds_transfer_me_to_me",+ payment_purpose: "family_support",+ },+ },+ },+ // Non-AFT payment: funding_transaction_type and payment_purpose are optional at+ // the API level, but hyperswitch validates the connector_metadata schema (unknown+ // fields are rejected with IR_06) and echoes connector_metadata back on the+ // payment response. The payment itself proceeds as a standard card payment and+ // succeeds.+ Response: {+ status: 200,+ body: {+ status: "succeeded",+ connector_metadata: {+ apple_pay: null,+ airwallex: null,+ noon: null,+ braintree: null,+ adyen: null,+ peachpayments: null,+ santander: null,+ worldpayxml: {+ funding_transaction_type: "funds_transfer_me_to_me",+ payment_purpose: "family_support",+ },+ checkout: null,+ stripe: null,+ },+ },+ },+ },+ ConnectorIntentMetadataMissing: {+ Request: {+ amount: 6000,+ payment_method: "card",+ payment_method_type: "debit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ customer_acceptance: null,+ setup_future_usage: null,+ customer: {+ date_of_birth: "1990-01-31",+ },+ connector_metadata: null,+ },+ // Without the AFT flag, connector_metadata is optional: hyperswitch accepts+ // the payment and returns success even when it is absent.+ Response: {+ status: 200,+ body: {+ status: "succeeded",+ },+ },+ },+ ConnectorIntentMetadataMissingFundingTransactionType: {+ Request: {+ amount: 6000,+ payment_method: "card",+ payment_method_type: "debit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ customer_acceptance: null,+ setup_future_usage: null,+ customer: {+ date_of_birth: "1990-01-31",+ },+ connector_metadata: {+ worldpayxml: {+ payment_purpose: "family_support",+ },+ },+ },+ // funding_transaction_type is only required for AFT payments: without the AFT+ // flag, partial connector_metadata is accepted and the payment succeeds.+ Response: {+ status: 200,+ body: {+ status: "succeeded",+ },+ },+ },+ ConnectorIntentMetadataMissingPaymentPurpose: {+ Request: {+ amount: 6000,+ payment_method: "card",+ payment_method_type: "debit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ customer_acceptance: null,+ setup_future_usage: null,+ customer: {+ date_of_birth: "1990-01-31",+ },+ connector_metadata: {+ worldpayxml: {+ funding_transaction_type: "funds_transfer_me_to_me",+ },+ },+ },+ // payment_purpose is only required for AFT payments: without the AFT flag,+ // partial connector_metadata is accepted and the payment succeeds.+ Response: {+ status: 200,+ body: {+ status: "succeeded",+ },+ },+ },+ ConnectorIntentMetadataUnknownField: {+ Request: {+ amount: 6000,+ payment_method: "card",+ payment_method_type: "debit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ customer_acceptance: null,+ setup_future_usage: null,+ customer: {+ date_of_birth: "1990-01-31",+ },+ connector_metadata: {+ worldpayxml: {+ funding_transaction_type: "funds_transfer_me_to_me",+ payment_purpose: "family_support",+ unknown_field: "x",+ },+ },+ },+ Response: {+ status: 400,+ body: {+ error: {+ error_type: "invalid_request",+ message:+ "Json deserialize error: unknown field `unknown_field`, expected `funding_transaction_type` or `payment_purpose`",+ code: "IR_06",+ },+ },+ },+ },},};diff --git a/cypress-tests/cypress/e2e/spec/Payment/54-ConnectorIntentMetadata.cy.js b/cypress-tests/cypress/e2e/spec/Payment/54-ConnectorIntentMetadata.cy.jsnew file mode 100644index 0000000000..321a23fc68--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Payment/54-ConnectorIntentMetadata.cy.js@@ -0,0 +1,218 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import getConnectorDetails, * as utils from "../../configs/Payment/Utils";++let globalState;++describe("Card - Connector Intent Metadata 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("Card - Create+Confirm payment with connector metadata", function () {+ before(+ "skip connectors without connector metadata echo support",+ function () {+ if (+ utils.shouldIncludeConnector(+ globalState.get("connectorId"),+ utils.CONNECTOR_LISTS.INCLUDE.PEACHPAYMENTS_CONNECTOR_METADATA+ )+ ) {+ this.skip();+ }+ }+ );++ it("Create+Confirm Payment with connector metadata -> Retrieve Payment", () => {+ let shouldContinue = true;++ cy.step("Create+Confirm Payment with connector metadata", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["ConnectorIntentMetadata"];++ cy.createConfirmPaymentTest(+ fixtures.createConfirmPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );++ if (!utils.should_continue_further(data)) {+ shouldContinue = false;+ }+ });++ cy.step("Retrieve Payment", () => {+ if (!shouldContinue) {+ cy.task("cli_log", "Skipping step: Retrieve Payment");+ return;+ }++ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["ConnectorIntentMetadata"];++ cy.retrievePaymentCallTest({ globalState, data });+ });+ });+ });++ context(+ "Card - Payment with purpose of payment connector metadata",+ function () {+ before(+ "skip connectors without purpose of payment metadata support",+ function () {+ if (+ utils.shouldIncludeConnector(+ globalState.get("connectorId"),+ utils.CONNECTOR_LISTS.INCLUDE.AFT_PURPOSE_OF_PAYMENT+ )+ ) {+ this.skip();+ }+ }+ );++ it("Create+Confirm payment with connector metadata", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["ConnectorIntentMetadata"];++ cy.createConfirmPaymentTest(+ fixtures.createConfirmPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ });++ it("Create+Confirm AFT payment without connector metadata", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["ConnectorIntentMetadataMissing"];++ cy.createConfirmPaymentTest(+ fixtures.createConfirmPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ });++ it("Create+Confirm payment with unknown field in connector metadata", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["ConnectorIntentMetadataUnknownField"];++ cy.createConfirmPaymentTest(+ fixtures.createConfirmPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ });+ }+ );++ context(+ "Card - Payment with funding transaction type and payment purpose connector metadata",+ function () {+ before(+ "skip connectors without funding transaction type metadata support",+ function () {+ if (+ utils.shouldIncludeConnector(+ globalState.get("connectorId"),+ utils.CONNECTOR_LISTS.INCLUDE.AFT_FUNDING_TRANSACTION_TYPE+ )+ ) {+ this.skip();+ }+ }+ );++ it("Create+Confirm payment with connector metadata", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["ConnectorIntentMetadata"];++ cy.createConfirmPaymentTest(+ fixtures.createConfirmPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ });++ it("Create+Confirm payment without connector metadata", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["ConnectorIntentMetadataMissing"];++ cy.createConfirmPaymentTest(+ fixtures.createConfirmPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ });++ it("Create+Confirm payment with connector metadata missing funding transaction type", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["ConnectorIntentMetadataMissingFundingTransactionType"];++ cy.createConfirmPaymentTest(+ fixtures.createConfirmPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ });++ it("Create+Confirm payment with connector metadata missing payment purpose", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["ConnectorIntentMetadataMissingPaymentPurpose"];++ cy.createConfirmPaymentTest(+ fixtures.createConfirmPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ });++ it("Create+Confirm payment with unknown field in connector metadata", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "card_pm"+ ]["ConnectorIntentMetadataUnknownField"];++ cy.createConfirmPaymentTest(+ fixtures.createConfirmPaymentBody,+ data,+ "no_three_ds",+ "automatic",+ globalState+ );+ });+ }+ );+});