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?
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.
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.
The email is posted along with the token.
It's passed into a post variable: $_POST['stripeEmail'].
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With