Reputation: 967
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
];
Upvotes: 4
Views: 4119
Reputation: 7676
This answer is helpful but stripe has updated its APIs where payment_intent_data used to be placed directly at the top level of the create method has now been moved into a nested object, thus the correct answer is now:
$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_settings' => [ //changed these lines
'payment_intent_data' => ['receipt_email' => $email],
],
];
This is the error I was receiving:
Received unknown parameter: payment_intent_data. Did you mean payment_settings?
Upvotes: 0
Reputation: 3331
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
Upvotes: 3