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
fix(cypress): fix stale offer quote id and saved-card card in offer engine spec (#14760)
HS-QUALIBOT3c7b399582d4
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.jsindex b3ed784749..aade4c9cd1 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js@@ -103,6 +103,14 @@ export const successfulNo3DSCardDetails = {card_cvc: "999",};+// Card the Offer Engine saved-card flow (54-OfferEngine.cy.js) saves and+// quotes. Kept apart from successfulNo3DSCardDetails, which the plain-card+// offer flow already uses.+export const offerEngineSavedCardDetails = {+ ...successfulNo3DSCardDetails,+ card_number: "4242424242424242",+};+const blocklistedCardDetails = {card_number: "4242424242424242",card_exp_month: "01",@@ -6026,3 +6034,4 @@ connectorDetails.offer_engine.ConfirmWithOfferAppliedSavedCard =connectorDetails.offer_engine.ConfirmWithOfferApplied;connectorDetails.offer_engine.AppliedOfferOnRetrieveSavedCard =connectorDetails.offer_engine.AppliedOfferOnRetrieve;+connectorDetails.offer_engine.SavedCardDetails = offerEngineSavedCardDetails;diff --git a/cypress-tests/cypress/e2e/spec/Payment/54-OfferEngine.cy.js b/cypress-tests/cypress/e2e/spec/Payment/54-OfferEngine.cy.jsindex 9f7d25d82f..8dd4fc536d 100644--- a/cypress-tests/cypress/e2e/spec/Payment/54-OfferEngine.cy.js+++ b/cypress-tests/cypress/e2e/spec/Payment/54-OfferEngine.cy.js@@ -180,6 +180,16 @@ describe("Offer Engine", () => {// second payment confirmed via payment_token (not raw PAN) with an offer// applied.context("Offer applies correctly on a saved-card confirm", () => {+ // Use a different card from the plain-card context above so the saved-card+ // flow is evaluated on its own card (BIN / card_alias).+ const withSavedCard = (data) => {+ const cloned = Cypress._.cloneDeep(data);+ cloned.Request.payment_method_data.card.card_number = getConnectorDetails(+ globalState.get("connectorId")+ ).offer_engine.SavedCardDetails.card_number;+ return cloned;+ };+it("create customer", () => {cy.createCustomerCallTest(fixtures.customerCreateBody, globalState);});@@ -187,9 +197,11 @@ describe("Offer Engine", () => {it("save a card via a plain create+confirm payment", () => {cy.createConfirmPaymentTest(fixtures.createConfirmPaymentBody,- getConnectorDetails(globalState.get("connectorId"))["card_pm"][- "SaveCardUseNo3DSAutoCapture"- ],+ withSavedCard(+ getConnectorDetails(globalState.get("connectorId"))["card_pm"][+ "SaveCardUseNo3DSAutoCapture"+ ]+ ),"no_three_ds","automatic",globalState@@ -217,8 +229,10 @@ describe("Offer Engine", () => {globalState.set("offerQuoteId", undefined);cy.paymentsOfferEligibilityCheck(fixtures.eligibilityCheckBody,- getConnectorDetails(globalState.get("connectorId")).offer_engine- .OfferEligibilityCheck,+ withSavedCard(+ getConnectorDetails(globalState.get("connectorId")).offer_engine+ .OfferEligibilityCheck+ ),globalState);});diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex bbf3dd3d30..b954d1a32f 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -3521,7 +3521,13 @@ Cypress.Commands.add(const offerQuoteId = globalState.get("offerQuoteId");expect(offerQuoteId, "offerQuoteId").to.not.be.undefined;- confirmBody.offer_details.offer_quote_ids = [offerQuoteId];+ // Replace rather than mutate: offer_details is shared by reference with+ // the connector config, so mutating it would bake this payment's quote id+ // into the config and later payments would resend a stale id.+ confirmBody.offer_details = {+ ...confirmBody.offer_details,+ offer_quote_ids: [offerQuoteId],+ };}if (reqData?.split_payments && supportsSplitPayments(globalState)) {@@ -4740,7 +4746,13 @@ Cypress.Commands.add(const offerQuoteId = globalState.get("offerQuoteId");expect(offerQuoteId, "offerQuoteId").to.not.be.undefined;- saveCardConfirmBody.offer_details.offer_quote_ids = [offerQuoteId];+ // Replace rather than mutate: offer_details is shared by reference with+ // the connector config, so mutating it would bake this payment's quote id+ // into the config and later payments would resend a stale id.+ saveCardConfirmBody.offer_details = {+ ...saveCardConfirmBody.offer_details,+ offer_quote_ids: [offerQuoteId],+ };}cy.request({