#Deviser

1 messages · Page 1 of 1 (latest)

heavy pumiceBOT
silver pebble
#

I am using the live code.

zealous siren
silver pebble
#

Sure!

#

But the point is if i am using the live code from the snippet. I am not able to pass the customer email into the above script.

zealous siren
#

Depends what you mean by 'pass the customer email'?

silver pebble
#

So, share any example then if you have any.

zealous siren
#

I'm trying to understand what it is you're trying doing

#

You said 'pass the customer email', but what does that mean

silver pebble
#

giving the example

#

<!-- Load Stripe.js on your website. -->
<script src="https://js.stripe.com/v3"></script>

<!-- Create a button that your customers click to complete their purchase. Customize the styling to suit your branding. -->
<button
style="background-color:#6772E5;color:#FFF;padding:8px 12px;border:0;border-radius:4px;font-size:1em;cursor:pointer"
id="checkout-button-price_1MwJ9ZSG6SKUi8yprXonvard"
role="link"
type="button"

Checkout
</button>

<div id="error-message"></div>

<script>
(function() {
var stripe = Stripe('pk_test_51L3Jb7SG6SKUi8ypMzeGlFRwVmW4KD2SwUFrOILAREIuTLpfs5Go4eKhlg9WTN3lkJvMZwCeg5M4lf7pOuqvEApi00V7fLyGNt');

var checkoutButton = document.getElementById('checkout-button-price_1MwJ9ZSG6SKUi8yprXonvard');
checkoutButton.addEventListener('click', function () {
/*
* When the customer clicks on the button, redirect
* them to Checkout.
/
stripe.redirectToCheckout({
customer_email: 'a.b@gmail.com',
lineItems: [{price: 'price_1MwJ9ZSG6SKUi8yprXonvard', quantity: 1}],
mode: 'payment',
/

* Do not rely on the redirect to the successUrl for fulfilling
* purchases, customers may not always reach the success_url after
* a successful payment.
* Instead use one of the strategies described in
* https://stripe.com/docs/payments/checkout/fulfill-orders
/
successUrl: 'https://example.com/success',
cancelUrl: 'https://example.com/canceled',
})
.then(function (result) {
if (result.error) {
/

* If redirectToCheckout fails due to a browser or network
* error, display the localized error message to your customer.
*/
var displayError = document.getElementById('error-message');
displayError.textContent = result.error.message;
}
});
});
})();
</script>

Learn how to fulfill orders after a customer pays with Stripe Checkout or Stripe Payment Links.

#

here i added the customer email

#

but it's not working

zealous siren
silver pebble
#

the purpose of the above code is
when we click on button . it's redirect to checkout page of the stripe.
But the email field of the checkout page is showing empty. I need that email field will auto filled by passing the passing any email from the code

#

thanks! I am trying the above parameter

#

Thanks @zealous siren
It's working

#

Thank you

zealous siren
#

Perfect