#emrys_best-practices

1 messages ยท Page 1 of 1 (latest)

nimble finchBOT
#

๐Ÿ‘‹ 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/1255456423081545739

๐Ÿ“ Have more to share? Add details, code, screenshots, videos, etc. below.

sacred vault
#

๐Ÿ‘‹ happy to help

#

would you mind elaborating?

stiff grotto
#

when i create a subscription i give it metadata

#

so that i can lookup my records when i need to

sacred vault
#

in subscriptions you don't need to look at PaymentIntents

#

instead it's recommended to look at the invoices and the invoice items

stiff grotto
#

i tried that too

#

but invoice.created isn't complete and is missing the metadata

#

but invoice.paid has the data i need - however the paymentintent success is fired the same time

#

so my system cant determin that the payment was succesful as the invoice.paid hook hasn't updated the metadata on the payment intent yet

sacred vault
#

you need to ignore the PaymentIntents that have the invoice property not null

stiff grotto
#

and cannot check my db with the required metadata

sacred vault
#

and move that logic to invoice.paid

stiff grotto
#

ah.. i see

#

so paymentintnet.invoice == null means that its a one off payment?

#

and has no subscription associated

stiff grotto
#

i need to handle the one off payments with payment intents succeeded and subscription payments with invoice.paid

sacred vault
#

more specifically a one-off payment that wasn't created by a one-off invoice

stiff grotto
#

they cannot be handled by the same one..

stiff grotto
#

tarzan!! you are a legend!

#

thanks

sacred vault
#

that's the better approach

stiff grotto
#

i will try that

sacred vault
#

let me know if you need any more help

stiff grotto
#

๐Ÿ‘