当前位置: 首页>>代码示例>>PHP>>正文


PHP PayPalAPIInterfaceServiceService::MassPay方法代码示例

本文整理汇总了PHP中PayPalAPIInterfaceServiceService::MassPay方法的典型用法代码示例。如果您正苦于以下问题:PHP PayPalAPIInterfaceServiceService::MassPay方法的具体用法?PHP PayPalAPIInterfaceServiceService::MassPay怎么用?PHP PayPalAPIInterfaceServiceService::MassPay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PayPalAPIInterfaceServiceService的用法示例。


在下文中一共展示了PayPalAPIInterfaceServiceService::MassPay方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pay_vendors

 private function pay_vendors($vendors)
 {
     if (empty($vendors)) {
         $return = array('status' => 'error', 'msg' => __('No vendors found to pay. Maybe they haven\'t set a PayPal address?', 'eddc'));
         $this->mail_results($return);
         return $return;
     }
     $this->include_paypal_sdk();
     $logger = new PPLoggingManager('MassPay');
     $massPayRequest = new MassPayRequestType();
     $massPayRequest->MassPayItem = array();
     $total_pay = 0;
     foreach ($vendors as $user_paypal => $user) {
         // Don't attempt to process payments for users that owe the admin money
         if ($user['total_due'] <= 0) {
             continue;
         }
         $total_pay += $user['total_due'];
         $masspayItem = new MassPayRequestItemType();
         $masspayItem->Amount = new BasicAmountType(edd_get_currency(), $user['total_due']);
         $masspayItem->ReceiverEmail = $user_paypal;
         $massPayRequest->MassPayItem[] = $masspayItem;
     }
     $massPayReq = new MassPayReq();
     $massPayReq->MassPayRequest = $massPayRequest;
     $paypalService = new PayPalAPIInterfaceServiceService();
     // Wrap API method calls on the service object with a try catch
     try {
         $massPayResponse = $paypalService->MassPay($massPayReq);
     } catch (Exception $ex) {
         $return = array('status' => 'error', 'msg' => sprintf(__('Error: %s', 'eddc'), $ex->getMessage()), 'total' => $total_pay);
         return $return;
     }
     $return = array();
     if (isset($massPayResponse)) {
         if ($massPayResponse->Ack === 'Success') {
             if ($this->purge_user_meta($vendors)) {
                 $return = array('status' => 'updated', 'msg' => __('All due commission has been paid for.', 'eddc'), 'total' => $total_pay);
             } else {
                 $return = array('status' => 'error', 'msg' => __('All due commission has been paid for, but I could not clear it from their profiles due to an internal error. Commission will still be listed as due. Please manually mark the commission as paid from the Commissions page.', 'eddc'), 'total' => $total_pay);
             }
         } else {
             $return = array('status' => 'error', 'msg' => sprintf('%s. %s (%s): %s.', $massPayResponse->Ack, $massPayResponse->Errors->ShortMessage, $massPayResponse->Errors->ErrorCode, $massPayResponse->Errors->LongMessage), 'total' => $total_pay);
         }
     }
     $this->mail_results($return);
     return $return;
 }
开发者ID:SelaInc,项目名称:eassignment,代码行数:48,代码来源:class-paypal-masspay.php

示例2: processWithdrawalRequests

 function processWithdrawalRequests($ids = array())
 {
     global $database;
     require_once 'PPBootStrap.php';
     // The MassPay API lets you send payments to up to 250 recipients with a single API call.
     $ids = array_slice($ids, 0, 250);
     $requests = $database->getWithdrawalRequestsById($ids);
     $massPayItems = array();
     $processed_ids = array();
     foreach ($requests as $request) {
         $masspayItem = new MassPayRequestItemType();
         $masspayItem->Amount = new BasicAmountType('USD', round($request['amount'], 2));
         $masspayItem->ReceiverEmail = $request['paypalemail'];
         $massPayItems[] = $masspayItem;
         $processed_ids[] = $request['id'];
     }
     $massPayReq = new MassPayReq();
     $massPayReq->MassPayRequest = new MassPayRequestType($massPayItems);
     $service = new PayPalAPIInterfaceServiceService(array('mode' => PAYPAL_MODE, 'acct1.UserName' => PAYPAL_USERNAME, 'acct1.Password' => PAYPAL_PASSWORD, 'acct1.Signature' => PAYPAL_SIGNATURE));
     try {
         $response = $service->MassPay($massPayReq);
     } catch (Exception $e) {
         $error = 'Mass Pay Service Error Message: ' . $e->getMessage();
         $_SESSION['process_withdrawal_requests_message'] = array('type' => 'error', 'message' => $error);
         return false;
     }
     if (strtoupper($response->Ack) == 'SUCCESS') {
         $database->updateWithdrawalRequests($processed_ids);
         $_SESSION['process_withdrawal_requests_message'] = array('type' => 'success', 'message' => 'Successfully processed ' . count($processed_ids) . ' withdrawal requests');
         return true;
     } else {
         $error = 'Mass Pay Error Message:<br/>';
         foreach ($response->Errors as $e) {
             $error .= $e->LongMessage . '<br/>';
         }
         $_SESSION['process_withdrawal_requests_message'] = array('type' => 'error', 'message' => $error);
         return false;
     }
 }
开发者ID:narvee,项目名称:nripl.org,代码行数:39,代码来源:session.php

示例3: PayPalAPIInterfaceServiceService

$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(USERNAME, PASSWORD, SIGNATURE);
    $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>";
}
开发者ID:brooklyntri,项目名称:btc-plugins,代码行数:31,代码来源:MassPay.php

示例4: payMass

 public function payMass()
 {
     $logger = new PPLoggingManager('MassPay');
     // ## MassPayReq
     // Details of each payment.
     // `Note:
     // A single MassPayRequest can include up to 250 MassPayItems.`
     $massPayReq = new MassPayReq();
     $massPayItemArray = array();
     // `Amount` for the payment which contains
     //
     // * `Currency Code`
     // * `Amount`
     $amount1 = new BasicAmountType("USD", "4.00");
     $massPayRequestItem1 = new MassPayRequestItemType($amount1);
     // Email Address of receiver
     $massPayRequestItem1->ReceiverEmail = "abc@paypal.com";
     // `Amount` for the payment which contains
     //
     // * `Currency Code`
     // * `Amount`
     $amount2 = new BasicAmountType("USD", "3.00");
     $massPayRequestItem2 = new MassPayRequestItemType($amount2);
     // Email Address of receiver
     $massPayRequestItem2->ReceiverEmail = "xyz@paypal.com";
     // `Amount` for the payment which contains
     //
     // * `Currency Code`
     // * `Amount`
     $amount3 = new BasicAmountType("USD", "7.00");
     $massPayRequestItem3 = new MassPayRequestItemType($amount3);
     // Email Address of receiver
     $massPayRequestItem3->ReceiverEmail = "def@paypal.com";
     $massPayItemArray[0] = $massPayRequestItem2;
     $massPayItemArray[1] = $massPayRequestItem1;
     $massPayItemArray[2] = $massPayRequestItem3;
     $massPayRequest = new MassPayRequestType($massPayItemArray);
     $massPayReq->MassPayRequest = $massPayRequest;
     // ## Creating service wrapper object
     // Creating service wrapper object to make API call and loading
     // configuration file for your credentials and endpoint
     $service = new PayPalAPIInterfaceServiceService();
     try {
         // ## Making API call
         // Invoke the appropriate method corresponding to API in service
         // wrapper object
         $response = $service->MassPay($massPayReq);
     } catch (Exception $ex) {
         $logger->error("Error Message : " + $ex->getMessage());
     }
     // ## Accessing response parameters
     // You can access the response parameters using getter methods in
     // response object as shown below
     // ### Success values
     if ($response->Ack == "Success") {
         $logger->log("Mass Pay successful");
     } else {
         $logger->error("API Error Message : " . $response->Errors[0]->LongMessage);
     }
     return $response;
 }
开发者ID:andrewwakeling,项目名称:codesamples-php,代码行数:61,代码来源:MassPay.php


注:本文中的PayPalAPIInterfaceServiceService::MassPay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。