Adding payment method when creating account via api


#1

In the API, what is the best way to add a payment method to an account you are creating via the API?


#2

There isn’t a best way, the available options are at https://sonar.software/apidoc/#api-Account_Payment_Methods


#3

I’m aware of the the method but where I’m stumped is in providing an account ID to create payment for an account that isn’t yet created?!

E.g.
When a new customer fills out a form to create their account (https://sonar.software/apidoc/#api-Accounts-PostAccount), how would they add their CC to their account without having the account ID?


#4

You can’t. There needs to be an account. It’d be two API requests.


#5

Thanks.
How would the page know what the newly created account’s ID is?


#6

You’d get it from the API response when you create an account. The response JSON contains the account ID.


#7

Awesome. Thanks!