I am creating a new Session with stripe and attempting to pass in the receipt_email
property so that I can explicitely send a reciept to my buyer. The code below works fine without the receipt_email
property but adding it throws the error: Received unknown parameter: receipt_email
$session_data = [
'payment_method_types' => ['card'],
'mode'=>'payment',
'billing_address_collection'=> 'auto',
'line_items'=> [['price' => STRIPE_PRICE, 'quantity'=> 1]],
'success_url' => URL.'success',
'cancel_url' => URL.'error',
'receipt_email' => $email
];
$session = \Stripe\Checkout\Session::create($session_data);
I see that receipt_email
is actually a property of the payment_intent
. How/when should I set receipt_email
?
Here is the revised $session_data object based on advice from @hmunoz (the chosen answer):
$session_data = [
'payment_method_types' => ['card'],
'mode'=>'payment',
'billing_address_collection'=> 'auto',
'line_items'=> [['price' => STRIPE_PRICE, 'quantity'=> 1]],
'success_url' => URL.'success',
'cancel_url' => URL.'error',
'payment_intent_data' => ['receipt_email' => $email] //changed this line
];
You can set the underlying PaymentIntent's receipt_email
using payment_intent_data.receipt_email
field on the CheckoutSession: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-receipt_email