Skip to content

Commit

Permalink
Add support for ABORT flow (cards only at the moment)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Schneider-Swales committed Jul 31, 2024
1 parent 85db3d2 commit 10e5198
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,26 @@ function getCountry() {
: "US";
}

// Returns the payment outcome based on query parameter
function getPaymentOutcome() {
const params = new URLSearchParams(window.location.search);
const paymentOutcome = params.get("paymentOutcome")
? params.get("paymentOutcome")
: null;
return paymentOutcome;
}

// Returns the deferral based on payment outcome
function getDeferral() {
const paymentOutcome = getPaymentOutcome();
if(paymentOutcome === "abort") {
return "DEFERRED"
}
else {
return "NON_DEFERRED"
}
}

// Checks query params to see if error case was selected
function getError() {
const params = new URLSearchParams(window.location.search);
Expand Down Expand Up @@ -840,9 +860,7 @@ function getThemeSettings(theme, setting) {
function getAmount() {
const params = new URLSearchParams(window.location.search);

const paymentOutcome = params.get("paymentOutcome")
? params.get("paymentOutcome")
: null;
const paymentOutcome = getPaymentOutcome();

let amount;

Expand All @@ -854,7 +872,7 @@ function getAmount() {
amount = 15.0;
break;
case "abort":
amount = 15.0;
amount = 4.02;
break;
case "retry":
amount = 1.03;
Expand Down Expand Up @@ -953,6 +971,7 @@ function generateList(
preselection: {
direction: "CHARGE",
networkCodes: getPreselection(method),
deferral: getDeferral()
},
presetFirst: false,
style: {
Expand Down

0 comments on commit 10e5198

Please sign in to comment.