#Macros == Cheating
1 messages ยท Page 1 of 1 (latest)
I see the request goes to the customer endpoint but it has this weird annotation, not sure if this is possible using the official API
POST customers/<cus id>
default_source=<card id>&invoice_settings%5Bdefault_payment_method%5D=&expand%5B%5D=sources
Hello! Can you tell me a bit more about why you want to set the default? I want to make sure I provide you with the correct guidance.
If you're using Payment Methods you can set invoice_settings.default_payment_method on the Customer to specify the Payment Method which should be used by default for Invoices and Subscriptions: https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
๐๏ธ ๐๏ธ
The Dashboard is also setting the default_source on the Customer for legacy/compatibility reasons, but the default_source is deprecated and we do not recommend using it.
i see
ahh yeah, well we have a small platform that allows users to save multiple payment methods to pay a subscription fee
so we need to allow users to choose one of the payment methods as the default for automatic changes
let me take a look at this, i think this is what i was looking for, thank you ๐
so how that request goes?
i mean the payload?
like just
{"invoice_settings.default_payment_method": "source"} ?
No. Are you using Node for this?
python
we went with a wrapper long ago https://pinax-stripe.readthedocs.io/en/latest/ but is doesn't fully support all the api calls so we had to fork it
None
we've been adding new stuff since then, but i haven't had the chance to make a PR to the original project
you know how this is
Ah. Using our Python library it would be like this:
stripe.Customer.create(invoice_settings={"default_payment_method": "pm_123"})
guess update would be the same?
You would also need to specify the Customer ID, but yep.
ahh did not work
Request req_kYWbtILFMVaGr5: Received unknown parameter: default_payment_method
You need to nest default_payment_method inside invoice_settings.
like this?
{"invoice_settings.default_payment_method": "card_1GaqlmHc53YL1FGYRSy6k128"}
No, it needs to be nested.
I don't know the exact Python syntax, but in JSON it would look like this:
"invoice_settings": {
"default_payment_method": "pm_123"
}
lemme see
๐ค not sure what i am doing wrong here
been a while since the last time i worked with stripe, been working smoothly for years now
Hi there ๐ taking over for @upbeat raft
Can you copy/past the request ID from that screenshot? Looks like req_abc123
hey
alright let me see, we are using the python wrapper so
not much room to maneuver here
let me see
You can't copy/paste from the terminal where you took the screenshot?
oh wait!
url='/v1/customers/cus_H993pEVwBFDho0'
method='post'
params={'invoice_settings': {'default_payment_method': 'card_1GaqlmHc53YL1FGYRSy6k128', 'custom_fields': '', 'rendering_options': '', 'footer': ''}}
made a small correction and it went through this time ๐
thank you
tell @upbeat raft thank for me!
Will do!