Skip to content

Instantly share code, notes, and snippets.

@agarhy
Created December 6, 2012 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agarhy/4226858 to your computer and use it in GitHub Desktop.
Save agarhy/4226858 to your computer and use it in GitHub Desktop.
function create_buyer($name,$email_address,$card_uri){
//$marketplace = Balanced\Marketplace::mine();
global $marketplace;
$res=array();
try {
$buyer = $marketplace->createBuyer(
$email_address,
$card_uri);
$buyer->name = $name;
$buyer->save();
$res['res']="$name New Account created";
}
catch (Balanced\Exceptions\HTTPError $e) {
if ($e->category_code == 'duplicate-email-address') {
$buyer = $marketplace
->accounts
->query()
->filter(Balanced\Account::$f->email_address->eq($email_address))
->one();
$name1=$buyer->name;
$res['res']="$name1 Account existed";
}else{
throw $e;
}
}
$res['buyer']=$buyer;
return $res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment