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
import * as fixtures from "../../../fixtures/imports";
import State from "../../../utils/State";
import getConnectorDetails, {
CONNECTOR_LISTS,
shouldIncludeConnector,
should_continue_further,
} from "../../configs/Payment/Utils";
let globalState;
// Stripe now returns a payment_account_reference (PAR) for Amex cards as well
// (a Stripe-side behaviour change), so for Stripe this is a second positive
// scenario. Connectors whose card returns no PAR keep the genuine negative
// scenario.
const parVariantContext =
Cypress.env("CONNECTOR") === "stripe"
? "PAR positive - Amex card returning payment_account_reference"
: "PAR negative - card without payment_account_reference";
describe("Card - Payment Account Reference and auth_code validation", () => {
before("seed global state", function () {
let skip = false;
cy.task("getGlobalState")
.then((state) => {
globalState = new State(state);
if (
shouldIncludeConnector(
globalState.get("connectorId"),
CONNECTOR_LISTS.INCLUDE.PAYMENT_ACCOUNT_REFERENCE
) &&
shouldIncludeConnector(
globalState.get("connectorId"),
CONNECTOR_LISTS.INCLUDE.AUTH_CODE
)
) {
skip = true;
}
})
.then(() => {
if (skip) {
this.skip();
}
});
});
afterEach("flush global state", () => {
cy.task("setGlobalState", globalState.data);
});
context("PAR positive - card returning payment_account_reference", () => {
before(function () {
if (
shouldIncludeConnector(
globalState.get("connectorId"),
CONNECTOR_LISTS.INCLUDE.PAYMENT_ACCOUNT_REFERENCE
)
) {
this.skip();
}
});
it("Create Payment Intent -> Confirm Payment -> Retrieve 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 (!should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Confirm Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PARPositiveNo3DSAutoCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Retrieve Payment");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PARPositiveNo3DSAutoCapture"];
cy.retrievePaymentCallTest({ globalState, data: confirmData });
});
});
});
context(parVariantContext, () => {
before(function () {
if (
shouldIncludeConnector(
globalState.get("connectorId"),
CONNECTOR_LISTS.INCLUDE.PAYMENT_ACCOUNT_REFERENCE
)
) {
this.skip();
}
});
it("Create Payment Intent -> Confirm Payment -> Retrieve 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 (!should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Confirm Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PARNegativeNo3DSAutoCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Retrieve Payment");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["PARNegativeNo3DSAutoCapture"];
cy.retrievePaymentCallTest({ globalState, data: confirmData });
});
});
});
context("auth_code - card returning auth_code", () => {
before(function () {
if (
shouldIncludeConnector(
globalState.get("connectorId"),
CONNECTOR_LISTS.INCLUDE.AUTH_CODE
)
) {
this.skip();
}
});
it("Create Payment Intent -> Confirm Payment -> Retrieve 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 (!should_continue_further(data)) {
shouldContinue = false;
}
});
cy.step("Confirm Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Confirm Payment");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["AuthCodeNo3DSAutoCapture"];
cy.confirmCallTest(
fixtures.confirmBody,
confirmData,
true,
globalState
);
if (!should_continue_further(confirmData)) {
shouldContinue = false;
}
});
cy.step("Retrieve Payment", () => {
if (!shouldContinue) {
cy.task("cli_log", "Skipping step: Retrieve Payment");
return;
}
const confirmData = getConnectorDetails(globalState.get("connectorId"))[
"card_pm"
]["AuthCodeNo3DSAutoCapture"];
cy.retrievePaymentCallTest({ globalState, data: confirmData });
});
});
});
});