dimanche 3 juillet 2016

Stripe: Retrieving a customers email address during a charge (Laravel 5.2)

I wish to retrieve the customers email address after they have purchased a product, so I can send them a download link.

Here is my processing of the charge.

 public function charge()
{
    \Stripe\Stripe::setApiKey("sk_test_key");

    $token = $_POST['stripeToken'];

    dd(\Stripe\Customer::retrieve($token));

    try {
      $charge = \Stripe\Charge::create(array(
        "amount" => 10000, // amount in cents, again
        "currency" => "usd",
        "source" => $token,
        "description" => "Example charge"
        ));
    } catch(\Stripe\Error\Card $e) {
        flashWarning('An error occured');
        return back();
    }

    $data = [];

    Mail::send('emails.download',$data, function($message)
    {
        $message->to(CUSTOMER EMAIL)->subject('thank you for purchasing...');
    });  

}

In the bottom half of the method I would like to somehow find the customers email address so I can send them an email.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire