#bruuh_api
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always 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/1228338342127472660
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
One-off payments don't generate invoices by default, so you should listen to payment_intent.succeeded events
and payment_intent.succeeded are triggered all the time on one offs? what about 'checkout.session.completed' ?
and payment_intent.succeeded are triggered all the time on one offs?
As long as the amount charged is greater than 0
what about 'checkout.session.completed' ?
That's generated as well
ok, but I need one that's 100% triggered only after payment is succesfully completed. both are fine?
and also, payment_intent.succeeded are generated for both subscriptions and one-offs? if I want to differentiate them, how can I do that? Like - knowing that it was for a subscription or a one-off?
No. checkout_session.completed is triggered once checkout session is done. Some async payment methods might not have been charged yet when you get that event, so you should do payment_intent.succeeded instead
yeah they're both generated
ok, let me know how to differentiate then on the payment_intent succeeeded event
If a payment intent has an invoice, you know it's from a subscription: https://docs.stripe.com/api/payment_intents/object#payment_intent_object-livemode
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Sorry linked wrong param
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ok, and otherwise is a one-off
yep
Ok and can I retrieve the products somehow?
I need to have access to the customer and products - can payment intent provide me ids for this so I can fetch them?
Payment intents don't have products, just an amount
You'd need to get that from the checkout session object w/ one time payments
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Ok so I have to write some subscription information in the moment when the payment success (for one-offs /subscriptions) are happening.
for those subscription info, i need the product info.
It's fine if I can fetch somehow the products out of one of the ids provided by the events (does not have to be the product id, has to just be an id that in the end gives me the product ids post-fetching)
ideally all of these info should be under a webhook event.
for subscriptions, 'invoice.payment_succeeded' provided me everything i have needed.
any equivalent for the one-offs?
No you'd need to retrieve the checkout session associated with the payment intent to get it. Alternatively, you can add the product id to the payment intent's metadata when creating the checkout session, so that you get it in payment_intent.succeeded
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ok, what from the 'payment_intent.succeeded' offers me info about the checkout session so I can retrieve it?
It doesn't
You need to add the product id manually to the payment intent's metadata when creating the session (above link)
ah ok
Then it will be in the metadata param of the payment intent
and one last thing
the invoice one provides me with customer_phone which is valid and works.
the payment intent has shipping info, but the "phone" udner there is null, even if I sent a phone number on checkout.
how to make sure phone number is there?
the 'invoice.payment_succeeded' was having customer_shipping and customer_phone
Can you share the payment intent id where this happened?
"id": "pi_3P4kgeIVliRP2SHy25SEdDp8",
so?
an example from the invoice payment success. where phone is still null there, but exists in the customer_phone section. but the intent has nothing on customer_phine...
Yeah it's a different object
You can read more here: https://docs.stripe.com/api/invoices/object#invoice_object-customer_phone
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
It's pulled from the customer object and copied to invoice
The payment intent doesn't have an equivalent
So you'd need to retrieve the checkout session object to get phone
ok