Often the case, when you wanted to show different email address than the one associated with the paypal then Express Checkout does not help much. In case of personnel account, it shows the primary email address associated with paypal. When you are running multiple business and had multiple sites, each requiring different email address to be shown in the checkout page then you might be running out of ideas to achieve so.
Fortunately, Paypal provides ButtonManager API (Paypal Payments Standard) which lets you create the Paypal Button on the fly taking email address that you provide and returns you the button code. Obviously, that email address has to be linked to the paypal but doesn’t require to be the primary email address. This way, you could link multiple email addresses to one single paypal account and use those across your multiple sites.
When you create a button, PayPal responds by generating code that you can use to proceed further.
The generated code includes:
- HTML code for including the button in web pages
- URL link code for adding buttons to email and documents that support links
require_once('PPBootStrap.php');
function paypalPPS($buttonVar) {
$createButtonRequest = new BMCreateButtonRequestType();
$createButtonRequest->ButtonCode = 'HOSTED';
$createButtonRequest->ButtonType = 'BUYNOW';
$createButtonRequest->ButtonVar = $buttonVar;
$createButtonReq = new BMCreateButtonReq();
$createButtonReq->BMCreateButtonRequest = $createButtonRequest;
$paypalService = new PayPalAPIInterfaceServiceService();
try {
$createButtonResponse = $paypalService->BMCreateButton($createButtonReq);
} catch (Exception $ex) {
}
if(isset($createButtonResponse)) {
$form = $createButtonResponse -> Website;
$form = str_replace("\n",'',$form);
$form = str_replace("",'',$form);
return "'" . $form . "'";
}else {
return 'error';
}
}
/* Initiate Create Button Manager API */
$buttonVar = array("item_name=" . $paypalName,
"return=" . $PayPalReturnURL,
"business=" . $businessMail,
"amount=" . $totalAmount,
"quantity=1");
$paypalResponse = paypalPPS($buttonVar);
The response that you receive from the code snippet is the paypal button (html), on click of which you will be taken to the paypal page with your submitted email address shown.
