Search code examples
restbalanced-payments

How do I list cards for a specified customer using Balanced API?


I am using PHP to try to get the card from Balanced.

I can get all the cards using

$marketplace = Balanced\Marketplace::mine();
$cards = $marketplace->cards->query()->all();

I can look though the $cards array and in each card object I find a values like this
uri : /v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards/CC5N3HHUDrAyvhNwQOoUd3UX this appears to be formatted as
"/v1/marketplaces/MARKETPLACE ID/cards/CARD ID"

However I only want the cards for a specific customer so I tried

$customer = Balanced\Customer::get("/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS");
$cards = $customer->cards->query()->all();

Now when I look thought the card object the format of the uri has changed
uri : /v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC5N3HHUDrAyvhNwQOoUd3UX
So it gives the uri as
"/v1/customers/CUSTOMER ID/cards/CARD ID"

Question, can I use this customer based uri for all card functions such as charging and deleting?
Or, if I have to use the marketplaces format do I rebuild the URI (which balanced warns against) or is there some why I can get the uri in it's proper format?


Solution

  • You can use either of those uri's. They are just using different endpoints, but will result in the same successful transactions.