I have integrated Stripe checkout (the latest version) and need to send additional data so I can reconcile a later webhook.
Stripe rejects the metadata with the following error
Fatal error: Uncaught exception 'Stripe\Error\InvalidRequest' with message 'Received unknown parameter: metadata'
My partially redacted code looks like this
$object = \Stripe\Checkout\Session::create([
'success_url' => 'www/payment_processor.php?action=success',
'cancel_url' => 'www/payment_processor.php?action=cancel',
'payment_method_types' => ['card'],
'customer_email' => $email,
'metadata' => ['user_id' => $user_id],
'line_items' => [[
'amount' => $amount,
'currency' => $currency,
'name' => 'Purchase',
'description' => $description,
'quantity' => 1,
]]
]);
I expect the metadata to be accepted and returned with the webhook, as described in the Stripe documentation.
Metadata is useful for storing additional, structured information on an object. As an example, you could store your user's full name and corresponding unique identifier from your system on a Stripe Customer object.
Stripe will not be updating the Stripe Checkout modal to comply with Strong Customer Authentication (SCA) and as a result they no longer recommend using that integration.
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.
First sentence of the linked documentation states:
Updateable Stripe objects—including Account, Charge, Customer, PaymentIntent, Refund, Subscription, and Transfer —have a metadata parameter.
You are creating neither of those, you are creating a Session
Metadata must be nested in the Session creation object:
Stripe's docs incorrectly list metadata as a parent (https://stripe.com/docs/api/checkout/sessions/create) when in fact it's a child:
https://support.stripe.com/questions/using-metadata-with-checkout-sessions
client_reference_id is associated with the Session only, and does not get stored in Stripe as metadata.
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