#Macros == Cheating

1 messages ยท Page 1 of 1 (latest)

frosty thistleBOT
upbeat raft
#

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.

urban orbit
#

๐Ÿ‘๏ธ ๐Ÿ‘๏ธ

upbeat raft
#

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.

urban orbit
#

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

urban orbit
#

so how that request goes?

#

i mean the payload?

#

like just

#

{"invoice_settings.default_payment_method": "source"} ?

upbeat raft
#

No. Are you using Node for this?

urban orbit
#

python

#

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

upbeat raft
#

Ah. Using our Python library it would be like this:

stripe.Customer.create(invoice_settings={"default_payment_method": "pm_123"})
urban orbit
#

guess update would be the same?

upbeat raft
#

You would also need to specify the Customer ID, but yep.

urban orbit
#

ahh did not work

#
 Request req_kYWbtILFMVaGr5: Received unknown parameter: default_payment_method
upbeat raft
#

You need to nest default_payment_method inside invoice_settings.

urban orbit
#

like this?

#
{"invoice_settings.default_payment_method": "card_1GaqlmHc53YL1FGYRSy6k128"}
upbeat raft
#

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"
}
urban orbit
#

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

pine surge
#

Hi there ๐Ÿ‘‹ taking over for @upbeat raft

Can you copy/past the request ID from that screenshot? Looks like req_abc123

urban orbit
#

hey

#

alright let me see, we are using the python wrapper so

#

not much room to maneuver here

#

let me see

pine surge
#

You can't copy/paste from the terminal where you took the screenshot?

urban orbit
#

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!

pine surge
#

Will do!