当前位置: 首页>>代码示例>>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;未经允许,请勿转载。