Skip to main content

Hi,


I’m trying to link a button to #checkoutID and when a user clicks the button I need to execute the stripe checkout script.


stripe.redirectToCheckout({
lineItems: :{
price: '{{checkoutID}}',
quantity: 1,
}],
mode: 'payment',
successUrl: 'https://example.com/success',
cancelUrl: 'https://example.com/cancel',
}).then(function (result) {
});

Due to certain features on my page, this is the simplest solution I have found so far.


Does anyone know of a code that would read anything after the # , save it into a variable and if it contains “checkout” the above script would be executed?


For example if the user clicks button A, which points to #checkoutID, the script will execute, and take the user to checkout.

Be the first to reply!

Reply