#lord-aurelion_api

1 messages ¡ Page 1 of 1 (latest)

coarse locustBOT
#

👋 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/1283748286766780419

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

amber hamlet
zenith hawk
#

Okay how do I retrieve the payment object, via webhooks?

amber hamlet
#

It depends on what it is you're trying to do exactly? It isn't clear

zenith hawk
#

I would like, once the customer has paid and the payment has been successful, to retrieve the last 4 digits of the bank card used for payments and display them on their user account (simply as information)

amber hamlet
#

Then yes you can do that in your webhook. Which event(s) are you listening for?

zenith hawk
#

I'm currently listening

checkout.session.completed
customer.subscription.updated
invoice.finalized
invoice.paid
invoice.payment_failed
amber hamlet
zenith hawk
#

I just looked at a payment made recently, I can't find this information on the data sent by currently webhooks, only customer.subscription.updated but If this is the case of a payment without subscription, it would not work

amber hamlet
#

Yeah you might need to use invoice.paid and make an API call to lookup that invoice and expand the payment_intent field

#

There's multiple ways to do it really, all depends on your use case, what kind of payments you're processing, etc

zenith hawk
#

invoice.paid returns me "payment_intent": "pi_..." but to retrieve a customer's payment method, I need an id with "pm_..." ?

amber hamlet
#

Yes, you'll need to retrieve the pi_xxx object from the API which has a payment_method field you can expand to get the card details

coarse locustBOT
amber hamlet
#
$stripe->paymentIntents->retrieve('pi_3MtwBwLkdIwHu7ix28a3tqPa', ['expand' => ['payment_method']]);
ancient horizon
zenith hawk
#

Thank you, it seems to work, so I need to combine paymentIntents API & retrievePaymentMethod API?

#

How does it work if the customer updates to change his credit cards?

#

Sorry for response delay, I'm testing at the same time

ancient horizon
#

Thank you, it seems to work, so I need to combine paymentIntents API & retrievePaymentMethod API?
yes, PaymentIntent and PaymentMethod are closely related.

#

How does it work if the customer updates to change his credit cards?
I'm not sure I understand. whare are you trying to do?

zenith hawk
#

If the customer updates their banking information on the Stripe portal, how to retrieve the new banking data (last 4 digits)?

ancient horizon
#

I recommend doing some tests on your end. when that happens you should get a webhook notification (maybe customer.subscription.updated), and from there with the API you can get back the new PaymentMethod

zenith hawk
#
$session = $user->createBillingPortal([
            'flow_data' => ['type' => 'payment_method_update']
        ]);

I'm currently using it if the user would like to update his payment method.
You are right I think, I will try on my end, in any case, I thank you for your answers to my questions