Reputation: 815
I am using PHP to add Cards to a Customer
I have related questions so I have posted them together as (1)(2)(3)
I can use the balanced marketplace to verify that the customer has had each of the cards added to their account. I have no problem adding each card.
(1) When I use the following to get the customer object
$customer = \Balanced\Customer::get("/v1/customers/CU34xY6f9bKZzb0kjBxWTUjC");
var_dump($customer);
It only shows the second card added, however balanced marketplace lists both cards associated with the customer. Why is only one showing up in $customer?
(2) The var_dump($customer) gives "Balanced\Card" ["uri"]=> string(68) "/v1/customers/CU34xY6f9bKZzb0kjBxWTUjC/cards/CCyO8fJPHpaVzypm7L1TFbw" however the card uri is /v1/marketplaces/TEST-MP9COksoYlU4rwuakSzwYH6/cards/CCyO8fJPHpaVzypm7L1TFbw
Won't this lead to problems retrieving card info/charging cards?
(3) If I try to add either card again there is no change to $customer or the balanced marketplace. Should I be able to see some sort of error response, if so how? The documentation "https://docs.balancedpayments.com/1.0/api/customers/#adding-a-card-to-a-customer" gives an Example Response, I am assuming this is changes made to $customer as it does not say how you would view this response.
Upvotes: 0
Views: 94
Reputation: 1937
Both the URIs you posted go to the same Card resource, they just use different API endpoints.
Adding the same card multiple times won't result in an error. When you tokenize (add) a card, a new Card instance is created for the information supplied and you get back a unique URI. Each instance of Card can only be associated with one Customer. Tokenization doesn't check in this manner for "duplicate" Cards because, for example, say a person added their card and then their significant other added it to another service that uses Balanced. You can have multiple tokenized representations of the credit card that can be added to only once Customer each but represent the same credit card.
If you tokenize a card and add it to a Customer, the Customer instance should reflect the new Card URI in its attributes. You might need to reload the Customer instance first. If you're seeing odd behavior, I suggest you swing by #balanced on Freenode IRC where the developers can help you look into what's going on.
Upvotes: 1