Passing an email to Checkout using JS
Description
Is there a way to pass an email to Checkout so that it's automatically pre-filled, using the front-end? If I dig in the files, it looks like the hidden input enupalStripe[stripeData] gets parsed then emptied; is there a way for me to send the customer_email through?
Additional info
- Craft version: 3.5.14
- PHP version: 7.4
- Database driver & version: mysql 8
- Plugin version: 3.1.5
- Is SCA and Stripe Checkout enabled?: yes
Hi @bleepsandblops Yes please follow the next example:
{% set options = {
email: '[email protected]'
} %}
{{ craft.enupalstripe.paymentForm('handle', options) }}
Here you can see all the other options that you can pass to the paymentForm method: https://docs.enupal.com/stripe-payments/templating/paymentform.html
We'll add this to the docs soon
@andrelopez thank you, but that's through twig though, not client-side; is there a way to do it client-side?
@bleepsandblops I see, from JS you need to set the value to the hidden email input, in this example 1009 is the form Id
$("#enupal-stripe-1009 input[name='enupalStripe[email]']").val('[email protected]');
@andrelopez ah great thanks!
@andrelopez it's not working actually, and I think I can see why.
https://github.com/enupal/stripe/blob/master/src/services/Checkout.php#L106
the $data object is taken from
https://github.com/enupal/stripe/blob/master/src/services/Checkout.php#L59
$publicData['stripe'] which is actually enupalStripe[stripeData] JSON input, the one that gets emptied.
@bleepsandblops I am trying to do the same thing - did you perhaps find a solution to this?
@lucasdaniels I did not unfortunately, sorry!