MassPay() public method

Service Call: MassPay
public MassPay ( MassPayReq $massPayReq, mixed $apiCredential = null ) : PayPal\PayPalAPI\MassPayResponseType
$massPayReq PayPal\PayPalAPI\MassPayReq
$apiCredential mixed - Optional API credential - can either be a username configured in sdk_config.ini or a ICredential object created dynamically
return PayPal\PayPalAPI\MassPayResponseType
Exemplo n.º 1
0
 public function sendMoney(array $params = [])
 {
     if (!$params) {
         return false;
     }
     $massPayReq = new MassPayReq();
     $massPayItemArray = array();
     $amount = new BasicAmountType("USD", $params['balance']);
     $massPayRequestItem = new MassPayRequestItemType($amount);
     $massPayRequestItem->ReceiverEmail = $params['email'];
     $massPayRequest = new MassPayRequestType($massPayRequestItem);
     $massPayReq->MassPayRequest = $massPayRequest;
     $service = new PayPalAPIInterfaceServiceService($this->_credentials);
     try {
         $response = $service->MassPay($massPayReq);
     } catch (Exception $ex) {
         return false;
     }
     return $response;
 }
Exemplo n.º 2
0
$massPayReq->MassPayRequest = $massPayRequest;
/*
 * 	 ## Creating service wrapper object
Creating service wrapper object to make API call and loading
Configuration::getAcctAndConfig() returns array that contains credential and config parameters
*/
$paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
// required in third party permissioning
if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) {
    $cred = new PPSignatureCredential("jb-us-seller_api1.paypal.com", "WX4WTU3S8MY44S7F", "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy");
    $cred->setThirdPartyAuthorization(new PPTokenAuthorization($_POST['accessToken'], $_POST['tokenSecret']));
}
try {
    /* wrap API method calls on the service object with a try catch */
    if ($_POST['accessToken'] != null && $_POST['tokenSecret'] != null) {
        $massPayResponse = $paypalService->MassPay($massPayReq, $cred);
    } else {
        $massPayResponse = $paypalService->MassPay($massPayReq);
    }
} catch (Exception $ex) {
    include_once "../Error.php";
    exit;
}
if (isset($massPayResponse)) {
    echo "<table>";
    echo "<tr><td>Ack :</td><td><div id='Ack'>{$massPayResponse->Ack}</div> </td></tr>";
    echo "</table>";
    echo "<pre>";
    print_r($massPayResponse);
    echo "</pre>";
}