#Dan Judge
1 messages ยท Page 1 of 1 (latest)
๐ happy to help
what exactly can I check to make sure the customer has absolutely no payment methods?
first thing I would highly recommend using theinvoice.createdevent instead of theinvoice.payment_failedevent, in order to check if the customer has a valid Payment Method
Isn't it just an invoice object that's sent either way?
catching up on your question....
the point of using invoice.created is that you can check if the customer has a payment method before the attempt is actually made(we create the invoice, and then we wait an hour before charging). Seems like it might be more useful then only reacting to the failure, but you're right that either works really
to answer the question, you use https://stripe.com/docs/api/payment_methods/customer_list to check if the Customer has any payment methods.
If they do , then you also want to check if either of https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method or https://stripe.com/docs/api/subscriptions/object#subscription_object-default_payment_method have set values and are not null.
(thread unlocked)
That payment method list for customers is perfect, thank you.
Is there a way to access this via Classes in PHP?
For example, I'm getting customers like this:
\Stripe\Customer::receive();
Hi there ๐ catching up as my teammate needed to step away.
$stripe = new \Stripe\StripeClient('sk_test_NZbNA0pwnqC2cKBuewhhgQMf00B2NO28bR');
$stripe->customers->allPaymentMethods(
'cus_NpISbxuPXM2sn5',
['type' => 'card']
);
That's from the docs, but I'm using the other way in PHP
Thanks Toby
I'm not too familiar with writing PHP using that approach, does \Stripe\Customer::allPaymentMethods work?
That's where I was heading if I didn't get a reply, so I'll give that a go, ha, cheers Toby
Worked perfectly, thread can be closed, thanks guys
Glad to hear that worked, we're happy to have been able to assist. Best of luck with the rest of the project!