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


PHP Paypal::payout方法代码示例

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


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

示例1: actionProcessPayout

 public function actionProcessPayout()
 {
     $db_ext = new DbExt();
     $paypal_client_id = yii::app()->functions->getOptionAdmin('wd_paypal_client_id');
     $paypal_client_secret = yii::app()->functions->getOptionAdmin('wd_paypal_client_secret');
     $paypal_config = Yii::app()->functions->getPaypalConnectionWithdrawal();
     dump($paypal_config);
     $Paypal = new Paypal($paypal_config);
     $Paypal->debug = true;
     $website_title = yii::app()->functions->getOptionAdmin('website_title');
     $cron = new CronFunctions();
     if ($res = $cron->getPayoutToProcess()) {
         if (is_array($res) && count($res) >= 1) {
             foreach ($res as $val) {
                 $withdrawal_id = $val['withdrawal_id'];
                 $api_raw_response = '';
                 $status_msg = '';
                 dump($val);
                 switch ($val['payment_method']) {
                     case "paypal":
                         dump("Process paypal");
                         //if (!empty($paypal_client_id) && !empty($paypal_client_secret)){
                         if (is_array($paypal_config) && count($paypal_config) >= 1) {
                             if ($val['account'] != "") {
                                 $Paypal->params['RECEIVERTYPE'] = "EmailAddress";
                                 $Paypal->params['CURRENCYCODE'] = "USD";
                                 $Paypal->params['EMAILSUBJECT'] = "=You have a payment from " . $website_title;
                                 $Paypal->params['L_EMAIL0'] = $val['account'];
                                 $Paypal->params['L_AMT0'] = normalPrettyPrice($val['amount']);
                                 $Paypal->params['L_UNIQUEID0'] = str_pad($val['withdrawal_id'], 10, "0");
                                 if ($pay_resp = $Paypal->payout()) {
                                     dump($pay_resp);
                                     if ($pay_resp['ACK'] == "Success") {
                                         $status_msg = 'paid';
                                         $api_raw_response = json_encode($pay_resp);
                                     } else {
                                         $api_raw_response = json_encode($pay_resp);
                                         $status_msg = $pay_resp['L_LONGMESSAGE0'];
                                     }
                                 } else {
                                     $status_msg = $Paypal->getError();
                                 }
                             } else {
                                 $status_msg = t("Paypal account is empty");
                             }
                         } else {
                             $status_msg = t("Payout settings for paypal not yet set");
                         }
                         break;
                     case "bank":
                         $status_msg = 'paid';
                         break;
                 }
                 echo "<h3>Update status</h3>";
                 dump($api_raw_response);
                 dump($status_msg);
                 $params_update = array('date_process' => date('c'), 'api_raw_response' => $api_raw_response, 'status' => $status_msg);
                 dump($params_update);
                 if ($db_ext->updateData("{{withdrawal}}", $params_update, 'withdrawal_id', $withdrawal_id)) {
                     echo "<h2>Update ok</h2>";
                 } else {
                     echo "<h2>Update Failed</h2>";
                 }
                 if ($status_msg == "paid") {
                     // send email
                     $subject = yii::app()->functions->getOptionAdmin('wd_template_process_subject');
                     if (empty($subject)) {
                         $subject = t("Your Request for Withdrawal has been Processed");
                     }
                     if ($merchant_info = Yii::app()->functions->getMerchant($val['merchant_id'])) {
                         $merchant_email = $merchant_info['contact_email'];
                         $tpl = yii::app()->functions->getOptionAdmin('wd_template_process');
                         $tpl = smarty("merchant-name", $merchant_info['restaurant_name'], $tpl);
                         $tpl = smarty("payout-amount", standardPrettyFormat($val['amount']), $tpl);
                         $tpl = smarty("payment-method", $val['payment_method'], $tpl);
                         $tpl = smarty("acoount", $val['account'], $tpl);
                         dump($tpl);
                         if (!empty($tpl)) {
                             sendEmail($merchant_email, '', $subject, $tpl);
                         }
                     }
                 }
             }
         }
     } else {
         dump("No record to process");
     }
 }
开发者ID:ashishvazirani,项目名称:food,代码行数:88,代码来源:CronController.php


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