Skip to content

Commit

Permalink
Removed collection notice and added country in header
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaydev Waghela committed May 21, 2024
1 parent e0f5636 commit f1472a3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
28 changes: 12 additions & 16 deletions checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ let stripe;
// nativeAPI: true,
// showWebComponents: false,
// stripe: {
// publishableKey:
// "pk_test_51OoobQIhoMYCIMJxfjMZbjAVCicWGVevZPZpVVgdj0mzPkoJdRjL4gwizPOgpyflDPk78YNBuevOUZSS3egQy5AM00fluM6aqb",
// publishableKey: "",
// options: {
// betas: ["elements_saved_payment_methods_beta_1"],
// locale: "en",
Expand All @@ -34,8 +33,7 @@ let stripe;
// },
// },
// },
// customerSessionClientSecret:
// "cuss_secret_Q7tBuCiENjNApfNli76eXgJxWP0koCxw7Fcq2W7YI4M33Kq",
// customerSessionClientSecret: "",
// amount: 2500,
// currency: "nzd",
// },
Expand All @@ -58,6 +56,7 @@ async function callAPI({ url, method, body }) {
const headers = {
"Content-Type": "application/json",
Authorization: window.authorization,
country: window.country,
};

return await fetch(`https://apim-na.dev.mypepsico.com/cgf/gpg/v1/${url}`, {
Expand All @@ -70,8 +69,16 @@ async function callAPI({ url, method, body }) {
}

// Fetches a payment intent and captures the client secret
async function initialize({ token, customerKey, locale, amount, currency }) {
async function initialize({
token,
country,
customerKey,
locale,
amount,
currency,
}) {
window.authorization = token;
window.country = country;
window.amount = amount;

reactNativePostMessage({
Expand Down Expand Up @@ -221,9 +228,6 @@ function initStripe({
},
});
if (showWebComponents) {
document
.querySelector("#payment-collection-notice")
.classList.remove("hidden");
document.querySelector("#submit").classList.remove("hidden");
}
setLoading(false);
Expand Down Expand Up @@ -359,7 +363,6 @@ async function handleSubmit(e) {

setLoading(false);
document.querySelector("#payment-element").classList.add("hidden");
document.querySelector("#payment-collection-notice").classList.add("hidden");
document.querySelector("#submit").classList.add("hidden");
document.querySelector("#confirm").classList.remove("hidden");
}
Expand Down Expand Up @@ -473,13 +476,6 @@ function setLoading(isLoading) {
}
}

function onClickCollectionNotice() {
reactNativePostMessage({
eventName: "stripe.collectionNotice",
eventData: {},
});
}

function reactNativePostMessage(postData) {
/* Storing user's device details in a variable*/
let details = navigator.userAgent;
Expand Down
5 changes: 0 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@
<!--Stripe.js injects the Payment Element-->
</div>

<div id="payment-collection-notice" class="hidden">I have read and accept <a
onclick="onClickCollectionNotice()">
Collection
Notice</a>
</div>
<button id="submit">
<div class="spinner hidden" id="spinner"></div>
<span id="button-text">Continue</span>
Expand Down

0 comments on commit f1472a3

Please sign in to comment.