12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- require_once "WxPay.Api.php";
- class NativePay
- {
- public function __construct($config)
- {
- $this->config = $config;
- }
-
- public function GetPrePayUrl($productId)
- {
- $biz = new WxPayBizPayUrl();
- $biz->SetProduct_id($productId);
- try{
- $values = WxpayApi::bizpayurl($this->config, $biz);
- } catch(Exception $e) {
- Log::ERROR(json_encode($e));
- }
- $url = "weixin://wxpay/bizpayurl?" . $this->ToUrlParams($values);
- return $url;
- }
-
-
- private function ToUrlParams($urlObj)
- {
- $buff = "";
- foreach ($urlObj as $k => $v)
- {
- $buff .= $k . "=" . $v . "&";
- }
-
- $buff = trim($buff, "&");
- return $buff;
- }
-
-
- public function GetPayUrl($input)
- {
- if($input->GetTrade_type() == "NATIVE")
- {
- try{
- $result = WxPayApi::unifiedOrder($this->config, $input);
- return $result;
- } catch(Exception $e) {
- Log::ERROR(json_encode($e));
- }
- }
- return false;
- }
- }
|