How can I send an email with Stripe Checkout?

Using Stripe, I want to save the customer's email address from the email they put in Checkout. Sorry, placing stripeEmail

in my file charge.php

returns null


How can I get an email back from verification so that I can use it to send a receipt?

Here's my form code:

<script src=""></script>
<script src=""></script>
<form action="charge.php" method="post">
  <input type="hidden" id="amount" name="chargeAmount"/>
  <button data-charge-amount="300000" data-charge-name="Name" data-charge-description="Description">Select Pledge Level</button>
  <button data-charge-amount="123123" data-charge-name="Name2" data-charge-description="Description2">Donate</button>
    var token = function(res){
      var $theToken = $('<input type=hidden name=stripeToken />').val(;
    var amount = $(this).data("chargeAmount");
    var name = $(this).data("chargeName");
    var description = $(this).data("chargeDescription");
      key:         'pk_test_xxxxxxxxxxxxxxxxxxxxxxxx',
      address:     true,
      amount:      amount,
      currency:    'usd',
      name:        name,
      description: description,
      panelLabel:  'Pledge',
      token:       token,
    return false;


Here is my code charge.php


$token  = $_POST['stripeToken'];
$amount = $_POST['chargeAmount'];
$customer = \Stripe\Customer::create(array(
    'email' => $email,
    'card'  => $token,
$charge = \Stripe\Charge::create(array(
  'customer' => $customer->id,
  'amount'   => $amount,
  'currency' => 'usd',


Here is my code config.php



$stripe = array(
  "secret_key"      => "sk_test_xxxxxxxxxxxxxxxxxxxxxxxx",
  "publishable_key" => "pk_test_xxxxxxxxxxxxxxxxxxxxxxxx"



Any help would be much appreciated.



source to share

3 answers

The problem is that you are using Custom Checkout , which means that Checkout will not post data to your server automatically, but instead give it in a callback token

. In your case, you only get the token ID, so you don't see it.

Update your code so the callback will token

also retrieve the email and send it to a parameter stripeEmail


var token = function(res){
  var $theToken = $('<input type="hidden" name="stripeToken" />').val(;
  var $theEmail = $('<input type="hidden" name="stripeEmail" />').val(;




I've been trying this problem all night! @Koopajah helped a ton, so here's my whole solution in case anyone else runs into this.

Here's the form:

    <form action="/charge.php" method="post">
            class="btn btn-default btn-lg btn-success"
            value="&nbsp;&nbsp; Pay &nbsp;&nbsp;"
            data-description="20 Whozits ($19.99)"
        <script src=""></script>
        <script src=""></script>
        $(document).ready(function() {
            $('#payMe').on('click', function(event) {

                var $button = $(this),
                    $form = $button.parents('form');

                var opts = $.extend({}, $, {
                    token: function(result) {

                        var $theToken = $('<input>').attr({ type: 'hidden', name: 'stripeToken', value: })
                        var $theEmail = $('<input>').attr({ type: 'hidden', name: 'stripeEmail', value: })



And here's charge.php:


$stripe = array(
  "secret_key"      => "xxxx",
  "publishable_key" => "xxxx"

$token = $_POST['stripeToken'];
$email = $_POST['stripeEmail'];

      "source"  => $token,
      "email" => $email,
      "description" => "It Worked!"

  try {
$charge = \Stripe\Charge::create(array(
  "amount" => 199, // amount in cents, again
  "currency" => "usd",
  "source" => $_POST['stripeToken'],
  "description" => "Cat Facts"));
} catch(\Stripe\Error\Card $e) {
  $error = $e->getMessage();




I had a very similar problem, but I'm using node.js. I modified koopajah's answer and put it in charge.js file

 const token = req.body.stripeToken;<br>
 const email = req.body.stripeEmail;


and then i used this email variable like so ...

return stripe.charges.create({
// ensures we send a number, and not a string
amount: parseInt(process.env.STRIPE_COST, 10),
currency: process.env.STRIPE_CCY,
source: token,
description: 'My product', // 👈 remember to change this!
receipt_email: email, // that line sends a receipt email to the customer, you can customise that email inside stripe
metadata: {},


Hope this is a helpful answer to someone.



All Articles