#sergixel04
1 messages · Page 1 of 1 (latest)
Hello sergixel04, we'll be with you shortly! Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
• sergixel04, 0 days ago, 78 messages
• sergixel04, 3 days ago, 62 messages
• sergixel04, 4 days ago, 11 messages
Hi there 👋 you'll want to use the function shown in the sample here to retrieve the Customer object:
https://stripe.com/docs/api/customers/retrieve?lang=php
Then check the invoice_settings.default_payment_method or default_source field on the Customer object (depending on where you're setting that value) to get the ID of their default 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.
Thank you toby, then I need to catch default_payment_method up and use it to get the last4?
Yes, you can either retrieve the Payment Method using that ID:
https://stripe.com/docs/api/payment_methods/retrieve?lang=php
Or you can use expand when retrieving the Customer to expand the Payment Method inline and get all of the information in one request:
https://stripe.com/docs/api/expanding_objects?lang=php
You would want to expand invoice_settings.default_payment_method
Which customer id?
is it safe to send this data?
alright thank you! cus_OprBn6o8zKJ6RP
$stripe = new \Stripe\StripeClient(config('app.stripe_secret'));
$stripe->customers->retrieve(
'cus_OprBn6o8zKJ6RP',
['expand' => ['invoice_settings.default_payment_method']]
);
return [$stripe];
Yeah that's expected. That customer doesn't have invoice_settings.default_payment_method set
So that's why it was empty
When I subscribed at the checkout and used 424242424242, doesn't automatically grab that card number as default payment method?
No that's something you need to set
Is there some setting or something in the dashboard? I am using Stripe Checkout
No you need to make an update customer call and pass the payment method id: https://stripe.com/docs/api/customers/update?lang=php#update_customer-invoice_settings-default_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.
I have to handle this with webhooks?
If i go to user stripe dashboard billing I can see I have a payment method
Yeah doing it through webhooks would be best
Are you accepting subscriptions or 1-time payments?
I am accepting subscriptions
Got it working, thank you so much @hollow sandal
No problem
Is there a way to associate a subscription item with some token or value?
I am thinking on how to handle when a subscriptor cancels one seat of the subscription (decrements the quantity by 1) how to identify that specific seat with my ddbb and got their other seats working, but the cancelled one down
Couldn't you store subscription item id's in your database?
Or is it just 1 item?
With multiple quantities?
Yep, exact is one item with multiple quantities
For example one item with 3 at quantity column
This is something you'd need to keep track of in your db then