|
@@ -17,6 +17,8 @@ require_once(MINIPAY_PATHEX . '/lib/WxPay.Exception.php');
|
|
|
require_once(MINIPAY_PATHEX . '/lib/WxPay.Notify.php');
|
|
|
|
|
|
|
|
|
+use Log;
|
|
|
+
|
|
|
class webpay implements IPay
|
|
|
{
|
|
|
const wx_notifyurl = BASE_SITE_URL . '/mobile/web_wxnotify.php';
|
|
@@ -31,6 +33,7 @@ class webpay implements IPay
|
|
|
|
|
|
public function gen_pay($pay_sn,$fee,$order_sn,$subject)
|
|
|
{
|
|
|
+ Log::record("gen_pay 0",Log::DEBUG);
|
|
|
$input = new \MiniPay\WxPayUnifiedOrder();
|
|
|
$input->SetBody($subject); //商品或支付单简要描述
|
|
|
$input->SetAttach($pay_sn); //附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据
|
|
@@ -43,7 +46,11 @@ class webpay implements IPay
|
|
|
$input->SetNotify_url(self::wx_notifyurl);
|
|
|
$input->SetTrade_type("MWEB");
|
|
|
$input->SetOpenid($this->mOpenId);
|
|
|
+ Log::record("gen_pay 1",Log::DEBUG);
|
|
|
+
|
|
|
$order = \MiniPay\WxPayApi::unifiedOrder($input);
|
|
|
+ Log::record("gen_pay 2",Log::DEBUG);
|
|
|
+
|
|
|
|
|
|
if(!array_key_exists("appid", $order)
|
|
|
|| !array_key_exists("prepay_id", $order)
|
|
@@ -51,16 +58,22 @@ class webpay implements IPay
|
|
|
{
|
|
|
throw new \MiniPay\WxPayException("参数错误");
|
|
|
}
|
|
|
+ Log::record("gen_pay 3",Log::DEBUG);
|
|
|
+
|
|
|
|
|
|
$jsapi = new \MiniPay\WxPayJsApiPay();
|
|
|
$jsapi->SetAppid($order["appid"]);
|
|
|
$timeStamp = time();
|
|
|
$jsapi->SetTimeStamp("$timeStamp");
|
|
|
+ Log::record("gen_pay 4",Log::DEBUG);
|
|
|
+
|
|
|
$jsapi->SetNonceStr(\MiniPay\WxPayApi::getNonceStr());
|
|
|
$jsapi->SetPackage("prepay_id=" . $order['prepay_id']);
|
|
|
$jsapi->SetSignType("MD5");
|
|
|
$jsapi->SetPaySign($jsapi->MakeSign());
|
|
|
|
|
|
+ Log::record("gen_pay 5",Log::DEBUG);
|
|
|
+
|
|
|
$datas = $jsapi->GetValues();
|
|
|
$datas['mweb_url'] = $order['mweb_url'];
|
|
|
|