#didi1982_api
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1253253353421537391
đ Have more to share? Add details, code, screenshots, videos, etc. below.
const stripe_request: stripe.Checkout.SessionCreateParams = {
line_items: [
{
price,
quantity: 1
}
],
mode,
saved_payment_method_options: {
payment_method_save: 'enabled'
},
success_url: `http://localhost:5173/v1/create`,
cancel_url: `http://localhost:5173/pricing?cancelled=true`,
metadata: {
userId,
price
},
consent_collection: {
terms_of_service: 'required',
payment_method_reuse_agreement: {
position: 'auto'
}
}
};
...
const session = await Stripe.checkout.sessions.create(stripe_request);
Hi there, from what I see in your limited code sample, you are attempting to set metadata on the payment method. As shown in my example code above, it should be on the root of the stripe.Checkout.SessionCreateParams object.
i want to set metadata on the payment method
not on the checkoutsession
right now we set it on the checkout session
and on the checkout.session.completed event we copy it over to the payment method
you can also do
const session = await stripe.checkout.sessions.create({
.... setup_intent_data: {
metadata: {
"someFlag": "true" //
},
},
and this metadata will end up in the setup intent created
but you cannot pass anything that will end up in the payment method
Hi, there is not a way to set the metadata on the PaymentMethod object when creating a CheckoutSession, https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-payment_method_data
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
const session = await stripe.checkout.sessions.create({
customer: cust.id,
success_url: "http://localhost:3012/success?session_id={CHECKOUT_SESSION_ID}",
cancel_url: "http://localhost:3012/cancel?session_id={CHECKOUT_SESSION_ID}",
payment_method_types: ['card'],
mode: 'setup',
setup_intent_data: {
metadata: {
"someFlag": "true" //works
},
},
payment_method_data: {
metadata: {
"someOtherFlag": "true" // does not work
}
},
metadata: {
"myFlag": "true" // works
}
})
You could need to get the payment method ID, and then update the object on a separate call.
yes
this is what we currently do
and my question was "can this be enhanced in a future version"
Yeah, I can share your feedback! Can you share what your specific use case is?
we have different processes on the same stripe account.
and there is events on the payment_method itself
specifically the auto update
we want to distingish if the event (that is not testable currently by the stripe test api)
was on a payment method initiated / belonging to our process (so we need to treat it)
or from another process
=> having metadata on the payment method without needing to call update on it would be nice
as the only place we need to specifiy metadata would be checkout.session.create
it also would spare us some extra requests
for the patching
I see, I will share this feedback with the team.
thx