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 and Mandate/Payment coverage for givepayments (UCS-only) (#13547)
venkatakarthikm-maker199e2f986509
diff --git a/cypress-tests/.gitignore b/cypress-tests/.gitignoreindex dbcaec5b6c..c8ac3147de 100644--- a/cypress-tests/.gitignore+++ b/cypress-tests/.gitignore@@ -7,7 +7,9 @@ screenshots/videos/creds.json+cypress.env.jsonrun_all.sh+run-givepayments-ucs.sh# Cypress Dashboard build**/distdiff --git a/cypress-tests/cypress/e2e/configs/Payment/Givepayments.js b/cypress-tests/cypress/e2e/configs/Payment/Givepayments.jsnew file mode 100644index 0000000000..cfea35256b--- /dev/null+++ b/cypress-tests/cypress/e2e/configs/Payment/Givepayments.js@@ -0,0 +1,483 @@+import {+ customerAcceptance,+ multiUseMandateData,+ singleUseMandateData,+} from "./Commons";++const generateGivepaymentsEmail = () => "[email protected]";++const successfulNo3DSCardDetails = {+ card_number: "4111111111111111",+ card_exp_month: "12",+ card_exp_year: "2029",+ card_holder_name: "John Doe",+ card_cvc: "123",+ card_network: "Visa",+};++const billingWithEmail = (email) => ({+ address: {+ line1: "1467",+ line2: "Harrison Street",+ city: "San Francisco",+ state: "California",+ zip: "94122",+ country: "US",+ first_name: "John",+ last_name: "Doe",+ },+ email,+});++const captureMethodNotSupportedError = {+ error: {+ type: "invalid_request",+ message:+ "Capture method not supported. Givepayments connector supports Automatic capture method. is not implemented",+ code: "IR_00",+ },+};++export const connectorDetails = {+ card_pm: {+ PaymentIntent: {+ Request: {+ currency: "USD",+ customer_acceptance: null,+ setup_future_usage: "on_session",+ email: generateGivepaymentsEmail(),+ billing: billingWithEmail(generateGivepaymentsEmail()),+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payment_method",+ },+ },+ },+ PaymentIntentWithShippingCost: {+ Request: {+ currency: "USD",+ shipping_cost: 50,+ email: generateGivepaymentsEmail(),+ billing: billingWithEmail(generateGivepaymentsEmail()),+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payment_method",+ shipping_cost: 50,+ amount: 6000,+ },+ },+ },+ PaymentConfirmWithShippingCost: {+ Request: {+ payment_method: "card",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ customer_acceptance: null,+ setup_future_usage: "on_session",+ email: generateGivepaymentsEmail(),+ billing: billingWithEmail(generateGivepaymentsEmail()),+ },+ Response: {+ status: 200,+ body: {+ status: "processing",+ amount: 6000,+ shipping_cost: 50,+ net_amount: 6050,+ },+ },+ },+ No3DSAutoCapture: {+ Request: {+ payment_method: "card",+ payment_method_type: "credit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ customer_acceptance: null,+ setup_future_usage: "on_session",+ email: generateGivepaymentsEmail(),+ billing: billingWithEmail(generateGivepaymentsEmail()),+ },+ Response: {+ status: 200,+ body: {+ status: "processing",+ amount: 6000,+ net_amount: 6000,+ },+ },+ },+ "3DSAutoCapture": {+ Configs: {+ TRIGGER_SKIP: true,+ },+ Request: {+ payment_method: "card",+ payment_method_type: "credit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ customer_acceptance: null,+ setup_future_usage: "on_session",+ email: generateGivepaymentsEmail(),+ billing: billingWithEmail(generateGivepaymentsEmail()),+ },+ Response: {+ status: 200,+ body: {+ status: "processing",+ amount: 6000,+ net_amount: 6000,+ },+ },+ },+ "3DSManualCapture": {+ Request: {+ payment_method: "card",+ payment_method_type: "credit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ customer_acceptance: null,+ setup_future_usage: "on_session",+ email: generateGivepaymentsEmail(),+ billing: billingWithEmail(generateGivepaymentsEmail()),+ },+ Response: {+ status: 501,+ body: captureMethodNotSupportedError,+ },+ },+ No3DSManualCapture: {+ Request: {+ payment_method: "card",+ payment_method_type: "credit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ customer_acceptance: null,+ setup_future_usage: "on_session",+ email: generateGivepaymentsEmail(),+ billing: billingWithEmail(generateGivepaymentsEmail()),+ },+ Response: {+ status: 501,+ body: captureMethodNotSupportedError,+ },+ },+ Refund: {+ Configs: {+ POLL_BEFORE: true,+ },+ Request: {+ amount: 6000,+ },+ Response: {+ status: 200,+ body: {+ status: "pending",+ amount: 6000,+ },+ },+ },+ PartialRefund: {+ Configs: {+ POLL_BEFORE: true,+ },+ Request: {+ amount: 2000,+ },+ Response: {+ status: 200,+ body: {+ status: "pending",+ amount: 2000,+ },+ },+ },+ manualPaymentRefund: {+ Configs: {+ POLL_BEFORE: true,+ },+ Request: {+ amount: 6000,+ },+ Response: {+ status: 200,+ body: {+ status: "pending",+ amount: 6000,+ },+ },+ },+ manualPaymentPartialRefund: {+ Configs: {+ POLL_BEFORE: true,+ },+ Request: {+ amount: 2000,+ },+ Response: {+ status: 200,+ body: {+ status: "pending",+ amount: 2000,+ },+ },+ },+ SyncRefund: {+ Response: {+ status: 200,+ body: {+ status: "pending",+ },+ },+ },+ MandateSingleUseNo3DSAutoCapture: {+ Configs: {+ POLL_AFTER: true,+ },+ Request: {+ payment_method: "card",+ payment_method_type: "credit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ mandate_data: singleUseMandateData,+ email: generateGivepaymentsEmail(),+ billing: billingWithEmail(generateGivepaymentsEmail()),+ },+ Response: {+ status: 200,+ body: {+ amount: 6000,+ },+ },+ },+ MandateSingleUseNo3DSManualCapture: {+ Request: {+ payment_method: "card",+ payment_method_type: "credit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ mandate_data: singleUseMandateData,+ email: generateGivepaymentsEmail(),+ billing: billingWithEmail(generateGivepaymentsEmail()),+ },+ Response: {+ status: 501,+ body: captureMethodNotSupportedError,+ },+ },+ MandateMultiUseNo3DSAutoCapture: {+ Configs: {+ POLL_AFTER: true,+ },+ Request: {+ payment_method: "card",+ payment_method_type: "credit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ mandate_data: multiUseMandateData,+ email: generateGivepaymentsEmail(),+ billing: billingWithEmail(generateGivepaymentsEmail()),+ },+ Response: {+ status: 200,+ body: {+ amount: 6000,+ },+ },+ },+ MandateMultiUseNo3DSManualCapture: {+ Request: {+ payment_method: "card",+ payment_method_type: "credit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ mandate_data: multiUseMandateData,+ email: generateGivepaymentsEmail(),+ billing: billingWithEmail(generateGivepaymentsEmail()),+ },+ Response: {+ status: 501,+ body: captureMethodNotSupportedError,+ },+ },+ MITAutoCapture: {+ Configs: {+ POLL_BEFORE: true,+ },+ Request: {},+ Response: {+ status: 200,+ body: {+ status: "succeeded",+ amount: 6000,+ net_amount: 6000,+ },+ },+ },+ MITWithoutBillingAddress: {+ Configs: {+ POLL_BEFORE: true,+ },+ Request: { billing: null },+ Response: {+ status: 200,+ body: {+ status: "succeeded",+ amount: 6000,+ net_amount: 6000,+ },+ },+ },+ MITManualCapture: {+ Request: {},+ Response: {+ status: 501,+ body: captureMethodNotSupportedError,+ },+ },+ PaymentMethodIdMandateNo3DSAutoCapture: {+ Configs: {+ POLL_AFTER: true,+ },+ Request: {+ payment_method: "card",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ mandate_data: null,+ customer_acceptance: customerAcceptance,+ email: generateGivepaymentsEmail(),+ billing: billingWithEmail(generateGivepaymentsEmail()),+ },+ Response: {+ status: 200,+ body: {+ amount: 6000,+ },+ },+ },+ PaymentMethodIdMandateNo3DSManualCapture: {+ Request: {+ payment_method: "card",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ mandate_data: null,+ customer_acceptance: customerAcceptance,+ email: generateGivepaymentsEmail(),+ billing: billingWithEmail(generateGivepaymentsEmail()),+ },+ Response: {+ status: 501,+ body: captureMethodNotSupportedError,+ },+ },+ PaymentMethodIdMandate3DSAutoCapture: {+ Configs: {+ TRIGGER_SKIP: true,+ },+ Request: {+ payment_method: "card",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ mandate_data: null,+ customer_acceptance: customerAcceptance,+ email: generateGivepaymentsEmail(),+ billing: billingWithEmail(generateGivepaymentsEmail()),+ },+ Response: {+ status: 200,+ body: {+ status: "succeeded",+ },+ },+ },+ PaymentMethodIdMandate3DSManualCapture: {+ Configs: {+ TRIGGER_SKIP: true,+ },+ Request: {+ payment_method: "card",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ mandate_data: null,+ customer_acceptance: customerAcceptance,+ email: generateGivepaymentsEmail(),+ billing: billingWithEmail(generateGivepaymentsEmail()),+ },+ Response: {+ status: 200,+ body: {+ status: "requires_capture",+ },+ },+ },+ SaveCardUseNo3DSAutoCapture: {+ Request: {+ payment_method: "card",+ payment_method_type: "credit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ setup_future_usage: "on_session",+ customer_acceptance: customerAcceptance,+ email: generateGivepaymentsEmail(),+ billing: billingWithEmail(generateGivepaymentsEmail()),+ },+ Response: {+ status: 200,+ body: {+ status: "processing",+ },+ },+ },+ SaveCardUseNo3DSAutoCaptureOffSession: {+ Request: {+ payment_method: "card",+ payment_method_type: "credit",+ payment_method_data: {+ card: successfulNo3DSCardDetails,+ },+ currency: "USD",+ setup_future_usage: "off_session",+ customer_acceptance: customerAcceptance,+ email: generateGivepaymentsEmail(),+ billing: billingWithEmail(generateGivepaymentsEmail()),+ },+ Response: {+ status: 200,+ body: {+ status: "processing",+ },+ },+ },+ },+};diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.jsindex 99af6aa336..2dd70e5d03 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js@@ -39,6 +39,7 @@ import { connectorDetails as fiservcommercehubConnectorDetails } from "./Fiservcimport { connectorDetails as fiuuConnectorDetails } from "./Fiuu.js";import { connectorDetails as forteConnectorDetails } from "./Forte.js";import { connectorDetails as getnetConnectorDetails } from "./Getnet.js";+import { connectorDetails as givepaymentsConnectorDetails } from "./Givepayments.js";import { connectorDetails as gigadatConnectorDetails } from "./Gigadat.js";import { connectorDetails as globalpayConnectorDetails } from "./Globalpay.js";import { connectorDetails as globepayConnectorDetails } from "./Globepay.js";@@ -131,6 +132,7 @@ const connectorDetails = {finix: finixConnectorDetails,forte: forteConnectorDetails,getnet: getnetConnectorDetails,+ givepayments: givepaymentsConnectorDetails,gigadat: gigadatConnectorDetails,globalpay: globalpayConnectorDetails,globepay: globepayConnectorDetails,@@ -601,7 +603,7 @@ export const CONNECTOR_LISTS = {DDC_RACE_CONDITION: ["worldpay"],CONNECTOR_TESTING_DATA: ["adyen", "airwallex", "braintree", "noon"],// ucs connectors- UCS_CONNECTORS: ["authorizedotnet", "fiservcommercehub"],+ UCS_CONNECTORS: ["authorizedotnet", "fiservcommercehub", "givepayments"],OVERCAPTURE: ["adyen"],IFRAME_REDIRECTION: ["adyen",diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 44a50e8bcc..4ce23334b3 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -4563,6 +4563,56 @@ Cypress.Commands.add(});+/**+ * Repeatedly psyncs (GET .../payments/{id}?force_sync=true) a payment every+ * `intervalMs` until its status is in `terminalStatuses` or `maxAttempts` is+ * reached, whichever comes first. Does not assert on the final value itself+ * — stores it in globalState under "polledPaymentStatus" so the caller can+ * run its own explicit assertion afterward (e.g. require "succeeded" and+ * fail with a clear message if it actually settled to "failed", vs. never+ * reaching a terminal state at all within maxAttempts).+ */+Cypress.Commands.add(+ "pollPaymentStatusCallTest",+ (+ globalState,+ terminalStatuses = ["succeeded", "failed"],+ maxAttempts = 12,+ intervalMs = 10000+ ) => {+ const payment_id = globalState.get("paymentID");+ const headers = {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ };++ const poll = (attempt) => {+ cy.request({+ method: "GET",+ url: `${globalState.get("baseUrl")}/payments/${payment_id}?force_sync=true&expand_attempts=true`,+ headers,+ failOnStatusCode: false,+ }).then((response) => {+ const status = response.body?.status;+ cy.task(+ "cli_log",+ `pollPaymentStatusCallTest: attempt ${attempt}/${maxAttempts}, status=${status}`+ );+ globalState.set("polledPaymentStatus", status);++ if (terminalStatuses.includes(status) || attempt >= maxAttempts) {+ return;+ }++ cy.wait(intervalMs);+ poll(attempt + 1);+ });+ };++ poll(1);+ }+);+Cypress.Commands.add("retrievePaymentCallTest",({@@ -4897,6 +4947,15 @@ Cypress.Commands.add(return;}+ if (validatedConfigs?.POLL_BEFORE) {+ cy.pollPaymentStatusCallTest(globalState).then(() => {+ expect(+ globalState.get("polledPaymentStatus"),+ "payment status before refund"+ ).to.equal("succeeded");+ });+ }+const payment_id = globalState.get("paymentID");// we only need this to set the delay. We don't need the return value@@ -5283,6 +5342,15 @@ Cypress.Commands.add(defaultErrorHandler(response, resData);}});++ if (validatedConfigs?.POLL_AFTER && response.status === 200) {+ cy.pollPaymentStatusCallTest(globalState).then(() => {+ expect(+ globalState.get("polledPaymentStatus"),+ "CIT payment status after polling"+ ).to.equal("succeeded");+ });+ }});});@@ -5537,6 +5605,15 @@ Cypress.Commands.add(return;}+ if (validatedConfigs?.POLL_BEFORE) {+ cy.pollPaymentStatusCallTest(globalState).then(() => {+ expect(+ globalState.get("polledPaymentStatus"),+ "CIT payment status before MIT"+ ).to.equal("succeeded");+ });+ }+// Skip if the connector was downgraded to on_session (set by// citForMandatesCallTest) — no real recurring capability to test.if (globalState.get("mandateSetupFutureUsage") !== "off_session") {@@ -5560,13 +5637,12 @@ Cypress.Commands.add(}requestBody.amount = amount;+ globalState.set("paymentAmount", requestBody.amount);requestBody.capture_method = capture_method;requestBody.confirm = confirm;requestBody.customer_id = customerId;requestBody.profile_id = profileId;requestBody.recurring_details.data = paymentMethodId;-- globalState.set("paymentAmount", requestBody.amount);cy.request({method: "POST",url: url,diff --git a/cypress-tests/cypress/utils/featureFlags.js b/cypress-tests/cypress/utils/featureFlags.jsindex d82f532a24..d219313994 100644--- a/cypress-tests/cypress/utils/featureFlags.js+++ b/cypress-tests/cypress/utils/featureFlags.js@@ -5,6 +5,8 @@ const config_fields = ["TRIGGER_SKIP","LOCAL_VAULT_REQUIRED","skipPaymentMethodStatusAssertion",+ "POLL_BEFORE",+ "POLL_AFTER",];const DEFAULT_CONNECTOR = "connector_1";@@ -84,6 +86,8 @@ function validateConfigValue(key, value) {case "LOCAL_VAULT_REQUIRED":case "DELAY.STATUS":case "skipPaymentMethodStatusAssertion":+ case "POLL_BEFORE":+ case "POLL_AFTER":if (!validateType(value, "boolean")) return false;break;diff --git a/cypress-tests/cypress/utils/specSelection/config.js b/cypress-tests/cypress/utils/specSelection/config.jsindex 323da8be61..85fbfceaea 100644--- a/cypress-tests/cypress/utils/specSelection/config.js+++ b/cypress-tests/cypress/utils/specSelection/config.js@@ -47,6 +47,7 @@ export const CONNECTOR_PAYMENT_METHODS = Object.freeze({facilitapay: ["bank_transfer"],fiservcommercehub: ["card"],gigadat: ["bank_redirect"],+ givepayments: ["card"],globepay: ["wallet"],iatapay: ["bank_redirect", "real_time_payment", "upi"],inespay: ["bank_debit"],