Skip to content

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

test(cypress): cover offer eligibility by saved payment_token in offer engine spec (#15136)

venkatakarthikm-makerc10afced975e
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
index 94b2e713be..fb0ebd0290 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js
@@ -103,7 +103,7 @@ export const successfulNo3DSCardDetails = {
card_cvc: "999",
};
-// Card the Offer Engine saved-card flow (54-OfferEngine.cy.js) saves and
+// Card the Offer Engine saved-card flow (53-OfferEngine.cy.js) saves and
// quotes. Kept apart from successfulNo3DSCardDetails, which the plain-card
// offer flow already uses.
export const offerEngineSavedCardDetails = {
diff --git a/cypress-tests/cypress/e2e/spec/Payment/54-OfferEngine.cy.js b/cypress-tests/cypress/e2e/spec/Payment/53-OfferEngine.cy.js
similarity index 83%
rename from cypress-tests/cypress/e2e/spec/Payment/54-OfferEngine.cy.js
rename to cypress-tests/cypress/e2e/spec/Payment/53-OfferEngine.cy.js
index 8dd4fc536d..e5a0a3b3ad 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/54-OfferEngine.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/53-OfferEngine.cy.js
@@ -148,7 +148,7 @@ describe("Offer Engine", () => {
// list response should signal the SDK to run eligibility before confirm
// (sdk_next_action.next_action: eligibility_check,
// should_block_confirm: true) rather than going straight to confirm. This
- // is the actual gating mechanism the SDK relies on — 54-OfferEngine.cy.js's
+ // is the actual gating mechanism the SDK relies on — 53-OfferEngine.cy.js's
// other contexts call /eligibility directly and never exercise this signal.
context(
"Payment method list signals eligibility check when offers are enabled",
@@ -267,6 +267,71 @@ describe("Offer Engine", () => {
});
});
+ // PR #13850: eligibility by saved payment_token (no PAN); /apply must
+ // resolve the same card or confirm fails with IR_16.
+ context(
+ "Offer quoted by saved payment_token applies on a saved-card confirm",
+ () => {
+ let offerEngineDetails;
+
+ before(() => {
+ globalState.set("offerQuoteId", undefined);
+ offerEngineDetails = getConnectorDetails(
+ globalState.get("connectorId")
+ ).offer_engine;
+ });
+
+ it("list customer payment methods", () => {
+ cy.listCustomerPMCallTest(globalState);
+ });
+
+ it("payment intent create call", () => {
+ cy.createPaymentIntentTest(
+ fixtures.createPaymentBody,
+ connectorDetails.offer_engine.PaymentIntentForOffer,
+ "no_three_ds",
+ "automatic",
+ globalState
+ );
+ });
+
+ it("payment eligibility check by payment_token surfaces an eligible offer", () => {
+ const eligibilityBody = Cypress._.cloneDeep(
+ fixtures.eligibilityCheckBody
+ );
+ delete eligibilityBody.payment_method_data;
+ eligibilityBody.payment_token = globalState.get("paymentToken");
+ const eligibilityData = Cypress._.cloneDeep(
+ offerEngineDetails.OfferEligibilityCheck
+ );
+ delete eligibilityData.Request.payment_method_data;
+ cy.paymentsOfferEligibilityCheck(
+ eligibilityBody,
+ eligibilityData,
+ globalState
+ );
+ });
+
+ it("saved-card confirm call applies the offer quoted by token", () => {
+ cy.saveCardConfirmCallTest(
+ Cypress._.cloneDeep(fixtures.saveCardConfirmBody),
+ offerEngineDetails.ConfirmWithOfferAppliedSavedCard,
+ globalState
+ );
+ });
+
+ it("applied_offer is reflected on payment retrieve", () => {
+ const savedCardRetrieve =
+ offerEngineDetails.AppliedOfferOnRetrieveSavedCard;
+ cy.retrievePaymentCallTest({
+ globalState,
+ data: savedCardRetrieve,
+ expectedIntentStatus: savedCardRetrieve.Response.body.status,
+ });
+ });
+ }
+ );
+
// PR #13766: once a card has availed an offer, Offer Engine blocks that
// exact card (via a PAN-free card_alias fingerprint) from availing it
// again, independent of which customer/payment uses it.
diff --git a/cypress-tests/cypress/e2e/spec/Payment/54-OfferEngineBrowse.cy.js b/cypress-tests/cypress/e2e/spec/Payment/53-OfferEngineBrowse.cy.js
similarity index 96%
rename from cypress-tests/cypress/e2e/spec/Payment/54-OfferEngineBrowse.cy.js
rename to cypress-tests/cypress/e2e/spec/Payment/53-OfferEngineBrowse.cy.js
index 24d0662ad0..f7b21b4b5e 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/54-OfferEngineBrowse.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/53-OfferEngineBrowse.cy.js
@@ -4,7 +4,7 @@ let globalState;
// PR #13999: POST /offer_engine/offers/list — a merchant-dashboard browse
// endpoint, separate from the payment-flow eligibility endpoint covered by
-// 54-OfferEngine.cy.js. No payment intent is involved; it just surfaces
+// 53-OfferEngine.cy.js. No payment intent is involved; it just surfaces
// whatever offers this merchant currently has configured and eligible.
describe("Offer Engine - Browse Offers", () => {
before("seed global state and verify Offer Engine connectivity", function () {
diff --git a/cypress-tests/cypress/utils/specSelection/config.js b/cypress-tests/cypress/utils/specSelection/config.js
index 9407b43837..f74ab522c4 100644
--- a/cypress-tests/cypress/utils/specSelection/config.js
+++ b/cypress-tests/cypress/utils/specSelection/config.js
@@ -177,7 +177,7 @@ const PAYMENT_SPEC_METHODS = Object.freeze({
"54-RefundType.cy.js": ["card"],
"55-DynamicFields.cy.js": ["card"],
"56-VaultTokenizationDisable.cy.js": ["card"],
- "54-OfferEngine.cy.js": ["card"],
+ "53-OfferEngine.cy.js": ["card"],
"54-ConnectorAgnosticMandates.cy.js": ["card"],
"54-CardHolderNameBillingFallback.cy.js": ["card"],
});