How to pre-populate email in the Stripe payments dialog popup

Le Garden Fox picture Le Garden Fox · Nov 8, 2015 · Viewed 11.3k times · Source

I cannot seem to find a way to pre-populate the email address in the stripe payment popup. However this weekend I signed up for two accounts on websites that use stripe payments and I realized those websites had my email pre-populated in the stripe dialog iframe box. So I know there must be a way but I am unsure of how to do that. The docs don't define that property. Can someone explain how this is done using the javascript API and the basic Stripe dialog?

Answer

koopajah picture koopajah · Nov 8, 2015

If you're using Simple Checkout you pass the email in data-email like this:

<form action="/charge" method="POST">
  <script
    src="https://checkout.stripe.com/checkout.js" class="stripe-button"
    data-key="pk_test_6pRNASCoBOKtIshFeQd4XMUh"
    data-image="/img/documentation/checkout/marketplace.png"
    data-name="Stripe.com"
    data-description="2 widgets"
    data-amount="2000"
    data-email="[email protected]"
    data-locale="auto">
  </script>
</form>

If you're using Custom Checkout you pass the email in the email parameter to handler.open():

handler.open({
  name: 'Stripe.com',
  description: '2 widgets',
  amount: 2000,
  email: "[email protected]"
});