public function bill() { $data = ['app_id' => $this->app_id, 'timestamp' => $this->timestamp, 'app_sign' => $this->app_sign, 'channel' => $this->channel, 'total_fee' => $this->total_fee, 'bill_no' => $this->bill_no, 'title' => $this->title, 'return_url' => $this->return_url]; try { $result = api::bill($data); if ($result->result_code != 0) { echo $result->err_detail; exit; } $htmlContent = $result->html; $url = $result->url; echo $htmlContent; } catch (\Exception $e) { echo $e->getMessage(); } }
$data = array(); $appSecret = "39a7a518-9ac8-4a9e-87bc-7885f33cf18c"; $data["app_id"] = "c5d1cba1-5e3f-4ba0-941d-9b0a371fe719"; $data["timestamp"] = time() * 1000; $data["app_sign"] = md5($data["app_id"] . $data["timestamp"] . $appSecret); $data["channel"] = "WX_NATIVE"; $data["total_fee"] = 1; $data["bill_no"] = "bcdemo" . $data["timestamp"]; //$data["bill_no"] = "bcdemo" . "static"; $data["title"] = "白开水"; //选填 optional $data["optional"] = json_decode(json_encode(array("tag" => "msgtoreturn"))); //选填 return_url //$data["return_url"] = "http://payservice.beecloud.cn"; try { $result = \beecloud\rest\api::bill($data); if ($result->result_code != 0) { echo json_encode($result); exit; } $code_url = $result->code_url; ?> <div align="center" id="qrcode" > </div> <div align="center"> <p>订单号:<?php echo $data["bill_no"]; ?> </p> <button id="query">查询订单状态</button> <p id="query-result"></p>
private function payCommonProcess($channel, $subChannel) { $orderNumber = I('orderNumber'); $orderLogic = D('Order', 'Logic'); $map['orderNumber'] = $orderNumber; $map['status'] = 'N'; $result = $orderLogic->queryOrder($map); if (count($result) == 0) { header("Content-type:text/html;charset=utf-8"); echo L('orderNotExist'); exit; } $order = $result[0]; $inadequateInventoryItems = $this->checkOrderItemsInventory($order['orderId']); if (count($inadequateInventoryItems) > 0) { $this->redirect('Cart/index', array('itemId' => $inadequateInventoryItems['itemId'], 'itemSize' => $inadequateInventoryItems['itemSize'])); } Vendor("beecloud.autoload"); $data = array(); $appSecret = C('PAYMENT_APP_SECRET'); $data["app_id"] = C('PAYMENT_APP_ID'); $data["timestamp"] = time() * 1000; $data["app_sign"] = md5($data["app_id"] . $data["timestamp"] . $appSecret); $data["channel"] = $subChannel; if ($data["channel"] == 'WX_JSAPI') { $data["openid"] = session('openid'); } //当channel参数为 ALI_WEB 或 ALI_QRCODE 或 UN_WEB时 return_url为必填 if ($data["channel"] == 'ALI_WEB') { $data["return_url"] = C('PAYMENT_RETURN_URL'); } $data["total_fee"] = intval($order['totalFee'] * 100); //商户订单号, 8到32位数字和/或字母组合,请自行确保在商户系统中唯一,同一订单号不可重复提交,否则会造成订单重复. //这里直接在订单号后面加上时间戳作为付款的订单号 $data["bill_no"] = $orderNumber . $data["timestamp"]; if (C('IS_DEV') == 'true') { $data["title"] = "Testing开发测试订单" . $orderNumber; } else { $data["title"] = "StarBall.Kids订单" . $orderNumber; } //微信支付页面显示所需要的内容 $this->assign('totalFee', $data["total_fee"] / 100); $this->assign('orderNumber', $orderNumber); $this->assign('bill_no', $data["bill_no"]); $this->assign('is_dev', C('IS_DEV')); $this->createOrderBill($data, $orderNumber, 'PAY', $channel, $subChannel); $result = \beecloud\rest\api::bill($data); if ($result->result_code != 0) { logInfo('PaymentError:' . json_encode($result)); exit; } return $result; }