I need to implement an input option for entering coupons in the Stripe payment gateway when the handler is open on the front end. I currently have a Stripe window open and would like to provide users with a way to enter coupon codes.
// Function to Load Stripe on Init :
loadStripe() {
if(!window.document.getElementById('stripe-script')) {
var s = window.document.createElement("script");
s.id = "stripe-script";
s.type = "text/javascript";
s.src = "https://checkout.stripe.com/checkout.js";
window.document.body.appendChild(s);
}
}
var handler = (<any>window).StripeCheckout.configure({
key : <STRIPE KEY>
locale: 'auto',
token: async (token: any)=> {
const url = '';
const data = {id : token.id , amount : amount*100 };
await fetch(url ,{ ... })
.then((response) => response.json())
.then( async (data) => {}
});
}
});
handler.open({});