#dario2082
1 messages · Page 1 of 1 (latest)
How are you creating the Subscription ?
the subscription's default_payment_method is set when creating the Subscription
the subscription is created by Stripe when the user pay on our website. We use Stripe checkout
Before adding the second payment method on Customer portal I got the payment method. Then Iin the customer portal I added a new payment method and updated the plan from monthly to annual. Since this moment I didn't get the payement method anymore
ok so you are using Stripe Checkout for creating Subscription
What you can do is to set the list the customer's payment methods:
https://stripe.com/docs/api/payment_methods/customer_list
And then set one of theier payment methods (last one for example ) as a default payment method for the susbcription:
https://stripe.com/docs/api/subscriptions/update#update_subscription-default_payment_method
Why I have to set the payment methods via the API if the user do it himself when paying the subscription ? And he added a new method in the Stripe customer poartal. I just want to retrieve his default payment method
Why I have to set the payment methods via the API if the user do it himself when paying the subscription ?
They are setting the payment method to use for the purchase but not as default one for the subscripiton and the upcoming invoices
Could you please share the Subscription Id ?
and when I get subscription with Subscription.retrieve the object DefaultPaymentMethod is null
it's in test mode
sub_1Nqbe2ICe6O7NPDIQ4mtAjiM
before adding the new payment method everything worked fine
The default payment method of the subscription was removed after this action on the customer portal req_48y4WEXlRlKQF3
The screenshot you are referring to is the default customer's payment method and not the subscirption's default payment
as you can see in the Customer portal
In your java code you are referring to this field :
https://stripe.com/docs/api/subscriptions/object#subscription_object-default_payment_method
However the screenshot you are sharing is displaying the customer's object
OK so How can I get the default payment method of the user ?
Check this
Customer customer = Customer.retrieve("cus_OdtQzgH9UafuTA");
PaymentMethodCollection paymentMethods = customer.listPaymentMethods();
If I do this, I get two payment methods, but I don't know which is the default one
You need to check this field instead:
https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method
OK thank you. Do you know if I can expand this field when I get the customer ? to avoid to make 2 api calls
yes you can expand the customerfield when retreiving the subscription
yes but how can I expand the defaultPaymentMethod in invoiceSettings.defaultPaymentMethod ? because I'm getting only the ID
you pass the expand property invoice_settings.default_payment_method when fetching the customer
ok thank you very much