Created
December 6, 2012 18:33
-
-
Save agarhy/4226858 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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