#lord-aurelion_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/1283748286766780419
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Sure, they're set on the Payment Method object: https://docs.stripe.com/api/payment_methods/object#payment_method_object-card-last4
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Okay how do I retrieve the payment object, via webhooks?
It depends on what it is you're trying to do exactly? It isn't clear
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)
Then yes you can do that in your webhook. Which event(s) are you listening for?
I'm currently listening
checkout.session.completed
customer.subscription.updated
invoice.finalized
invoice.paid
invoice.payment_failed
OK, then you can get the pm_xxx ID from one of those events and use that ID to look up the full Payment Method object via https://docs.stripe.com/api/payment_methods/customer
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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
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
invoice.paid returns me "payment_intent": "pi_..." but to retrieve a customer's payment method, I need an id with "pm_..." ?
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
https://docs.stripe.com/api/payment_intents/retrieve this API, passing expand: ['payment_method']
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
$stripe->paymentIntents->retrieve('pi_3MtwBwLkdIwHu7ix28a3tqPa', ['expand' => ['payment_method']]);
hi! I'm taking over this thread. You just shared your secret key on a public forum. Please make sure to roll your keys here: https://dashboard.stripe.com/test/apikeys
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
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?
If the customer updates their banking information on the Stripe portal, how to retrieve the new banking data (last 4 digits)?
Okay thank you
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
$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