Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to pass email address from checkout form to charge page with Stripe

I am using Stripe's custom checkout button and I can create charges successfully. What I want to do now is pass the e-mail address on the form and create a new customer. However, the email address doesn't get passed to my server rather it goes directly to Stripe.

I was hoping I could do something like this:

//pass value from input field on previous page
$email = $_POST['email'];

// Create a Customer
$customer = Stripe_Customer::create(array(
  "card" => $token,
  "description" => "$email")
);

But I don't want to ask the user for his email address twice, since Stripe's form already asks for it.

How can I capture the email address to create a new customer?

like image 457
Josan Iracheta Avatar asked Apr 04 '14 04:04

Josan Iracheta


People also ask

Does Stripe send a confirmation email?

Stripe only sends email receipts for payments that are made with your live API key or through your live Dashboard. If you are expecting an email for a test transaction, one will not be sent. Resend email verification confirmation.

How do you customize a Stripe checkout form?

Apply branding You can customize the look and feel of Checkout in the Stripe Dashboard. Go to Branding Settings where you can: Upload a logo or icon. Customize the Checkout page's background color, button color, font, and shapes.


2 Answers

The email is posted along with the token.

It's passed into a post variable: $_POST['stripeEmail'].

like image 165
beech Avatar answered Oct 29 '22 03:10

beech


Ok then...while I didn't know the rules here, here's the answer:

Using the Stripe checkout.js

In your token callback, you can access res.email the same way you access res.id which will give you the email that the user submitted. Here's the code:

  var token = function(res){
      var $theToken = $('<input type=hidden name=stripeToken />').val(res.id);
      var $theEmail = $('<input type=hidden name=stripeEmail />').val(res.email);
      $('form').append($theToken);
      $('form').append($theEmail).submit();
  };

You could also put them in an array and then use a

$.each(

But that would be as an exercise for you to use. Cheers, -Colin

like image 26
MediaBlinkk Avatar answered Oct 29 '22 03:10

MediaBlinkk