#kqtipow-custom-metadata
1 messages · Page 1 of 1 (latest)
You cannot set metadata on a redirectToCheckout() action, but you can when you actually create the Checkout session: https://stripe.com/docs/api/checkout/sessions/create?lang=php#create_checkout_session-metadata
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
As for creating a Price, you would need to do that separate from any of the Checkout Session API calls.
hmm
maybe I should try to fetch data
trying to run php file, make session and include metadata then?
That should work
I mean something like ```const createCheckoutSession = function (stripe) {
return fetch("payment_init.php", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
createCheckoutSession: 1,
}),
}).then(function (result) {
return result.json();
});
};
If you're fetching the file that runs
$stripe->checkout->sessions->create([ 'success_url' => 'https://example.com/success', 'cancel_url' => 'https://example.com/cancel', 'line_items' => [ [ 'price' => 'price_abc123', 'quantity' => 1, ], ], 'mode' => 'payment', 'metadata' => [ 'some_key' => 'some value' ] ]);
nad how will be define $stripe variable?
Can you explain what you're asking?