Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing an email to Checkout using JS #152

Open
bleepsandblops opened this issue Nov 22, 2020 · 7 comments
Open

Passing an email to Checkout using JS #152

bleepsandblops opened this issue Nov 22, 2020 · 7 comments
Assignees
Labels
docs question Further information is requested

Comments

@bleepsandblops
Copy link

bleepsandblops commented Nov 22, 2020

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
@andrelopez
Copy link
Member

Hi @bleepsandblops Yes please follow the next example:

{% set options = {
    email: 'customer-email@test.com'
} %}

{{ 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 andrelopez self-assigned this Nov 23, 2020
@andrelopez andrelopez added docs question Further information is requested labels Nov 23, 2020
@bleepsandblops
Copy link
Author

@andrelopez thank you, but that's through twig though, not client-side; is there a way to do it client-side?

@andrelopez
Copy link
Member

@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('test@test.com');

@bleepsandblops
Copy link
Author

bleepsandblops commented Nov 23, 2020

@andrelopez ah great thanks!

@bleepsandblops
Copy link
Author

@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.

@lucasdaniels
Copy link

@bleepsandblops I am trying to do the same thing - did you perhaps find a solution to this?

@bleepsandblops
Copy link
Author

@lucasdaniels I did not unfortunately, sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants