#bruuh_api

1 messages ¡ Page 1 of 1 (latest)

lethal patrolBOT
#

👋 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.

bleak adderBOT
humble oar
#

One-off payments don't generate invoices by default, so you should listen to payment_intent.succeeded events

shy bane
#

and payment_intent.succeeded are triggered all the time on one offs? what about 'checkout.session.completed' ?

humble oar
#

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

shy bane
#

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?

humble oar
shy bane
#

ok, let me know how to differentiate then on the payment_intent succeeeded event

humble oar
#

Sorry linked wrong param

shy bane
#

ok, and otherwise is a one-off

humble oar
#

yep

shy bane
#

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?

humble oar
#

Payment intents don't have products, just an amount

#

You'd need to get that from the checkout session object w/ one time payments

shy bane
#

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?

humble oar
#

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

shy bane
#

ok, what from the 'payment_intent.succeeded' offers me info about the checkout session so I can retrieve it?

humble oar
#

It doesn't

#

You need to add the product id manually to the payment intent's metadata when creating the session (above link)

shy bane
#

ah ok

humble oar
#

Then it will be in the metadata param of the payment intent

shy bane
#

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

humble oar
#

Can you share the payment intent id where this happened?

shy bane
#

"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...

humble oar
#

Yeah it's a different object

#

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

shy bane
#

ok