Posting credit to a bank account uri

103 Views Asked by At

If I already have the bank account token (id returned by balanced.js), do I need to do a get to credit the account? The documentation at:

https://docs.balancedpayments.com/current/api.html?language=php#credit-an-existing-bank-account

says: To credit an existing bank account, you simply pass the amount to the nested credit endpoint of a bank account. The credits_uri is a convenient uri provided so that you can simply issue a POST with the amount and a credit shall be created.

But the example given below it, does a get on bank account first and then a credit. How do I post to the credits_uri with the amount and other parameters without first doing a get?

1

There are 1 best solutions below

0
On

If you don't want to get a GET first, you would need to store the credits_uri of the bank account in question and then POST directly to that. e.g.

$credit = new \Balanced\Credit(array(
  "uri" => "/v1/bank_accounts/BA123123/credits", // the credits_uri from the bank account
  "amount" => 100
))->save();