當前位置: 首頁>>代碼示例>>PHP>>正文


PHP payment::getInstance方法代碼示例

本文整理匯總了PHP中payment::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP payment::getInstance方法的具體用法?PHP payment::getInstance怎麽用?PHP payment::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在payment的用法示例。


在下文中一共展示了payment::getInstance方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: saveOrder

 public function saveOrder()
 {
     if ($this->user) {
         $billing_id = $_GET['billing_id'];
         $recipient_id = $_GET['recipient_id'];
         $comments = $_GET['comments'];
         $the_date = date("Y-m-d H:i:s");
         if (!verify::vIsNNUll($billing_id)) {
             alert("賬單ID不能為空");
         }
         if (!verify::vIsNumber($billing_id)) {
             alert("賬單ID格式錯誤");
         }
         if (!verify::vIsNNUll($recipient_id)) {
             alert("收件人ID不能為空");
         }
         if (!verify::vIsNumber($recipient_id)) {
             alert("收件人ID格式錯誤");
         }
         //保存訂單
         $this->CT_Api->api = "en.order.save";
         $this->CT_Api->setParams(array('user_id' => $this->user['id'], 'the_date' => $the_date, 'pay_date' => "0000-00-00 00:00:00", 'billing_id' => $billing_id, 'recipient_id' => $recipient_id, 'status' => "錄入", 'comments' => $comments, 'ship_fee' => 0.0, 'logistic' => "Fedex", 'payerid' => "", 'token' => "", 'goods_qty' => $this->shopcart->getQtyScr()));
         $orderResponse = $this->CT_Api->post();
         $order = $orderResponse['response'];
         if (strtolower(substr($order['msg'], 0, 7)) != "success") {
             alert("訂單提交失敗:" . $order['msg']);
         } else {
             $this->shopcart->flush();
         }
         // save to paylog table (with discount already)
         $order_code = $order['order_code'];
         $the_amount = $order['the_amount'];
         $payment = payment::getInstance();
         $result = $payment->GetToken($the_amount, $order_code, $this->shopcart->getList());
         //記錄操作日誌
         $user_id = $this->user['id'];
         $this->CT_Api->api = 'en.ucenter.getByUID';
         $this->CT_Api->id = $user_id;
         $dataPromo = $this->CT_Api->get();
         $this->assign('dataPromo', $dataPromo['response']);
         if ($dataPromo['response']['promo'] != '') {
             $percentage = 10;
         } else {
             $percentage = 0;
         }
         $percentage10 = $percentage / 100;
         $amount_before = $the_amount;
         $ammount_percentage = $percentage10 * $amount_before;
         $new_sum = $amount_before - $ammount_percentage;
         $new_sum = round($new_sum, 2);
         $this->CT_Api->api = "en.paylog.save";
         $this->CT_Api->setParams(array('api_name' => 'SetExpressCheckout', 'order_code' => $order_code, 'the_time' => time(), 'response' => http_build_query($result), 'amount' => $new_sum, 'token' => $result['TOKEN'], 'ack' => $result['ACK'], 'ip' => getIP()));
         $this->CT_Api->post();
         if ($result['ACK'] != "Success") {
             alert("An error occurred while pay PayPal");
         }
         $url = $payment->buildPayPaiUrl($result['TOKEN']);
         //print_r($url); die();
         redirect($url);
     } else {
         redirect("/index.php?m=user&c=index&a=login&ReturnUrl=" . getRequest());
     }
 }
開發者ID:joindennis,項目名稱:yidejia,代碼行數:63,代碼來源:order.php


注:本文中的payment::getInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。