Reputation: 433
I'm using balanced-php and want to know:
How to send the cardholder's name with request ?
How to add account user name in $marketplace->createBuyer()?
How to retrieve a stored card information when processing new payment, and how to prevent duplicating card information in the buyer's account ?
I use following to check if email is created
$buyer = $marketplace
->accounts
->query()
->filter(Balanced\Account::$f->email_address->eq($buyer_email))
->one();
if(!$buyer){
$buyer = $marketplace->createBuyer(
$email_address,
$card_uri);
echo 'created ';
$the_hold = $buyer->hold(1500);
$debit = $the_hold->capture();
echo 'charged';
}else{ .... }
Upvotes: 1
Views: 486
Reputation: 10092
How to send cardholder name with the request:
The card name needs to be sent when the card is created, e.g. when you tokenize the card using balanced.js or when you create a card object via the balanced-php library or when using the createCard
method.
The balanced-php library does not currently accept a name parameter, I've created an issue for you on the Github repo that you can subscribe to if you want to know when Balanced adds that functionality. For now you can take the resulting account object, add the name and then call the save method to update it.
The code would look something like this:
$account = $marketplace->createBuyer(...);
$account->name = "Desired name here";
$account->save();
You can view all cards for an account by using the account->cards
method which should return a collection of all cards associated with the account. In order to prevent duplicates you should iterate through this list looking for the duplicate by matching on name
, expiration
and last_four
properties. Let us know if you need a code sample for this.
Upvotes: 3