|
@@ -38,7 +38,10 @@ class Wechat extends Core
|
|
|
$trade_type = $this->getType($type);
|
|
|
$order_id = $this->createOrder($uid, $username, $account_id, $project_id, $product_id, $name, $cash, $this->config->GetType(), $order_id);
|
|
|
$tools = new \JsApiPay($this->config);
|
|
|
- $openid = $openid ? $openid : $tools->GetOpenid();
|
|
|
+
|
|
|
+ if ($openid != -1) {
|
|
|
+ $openid = $openid ? $openid : $tools->GetOpenid();
|
|
|
+ }
|
|
|
$input = new \WxPayUnifiedOrder();
|
|
|
$input->SetBody($name);
|
|
|
$input->SetAttach($name);
|
|
@@ -50,7 +53,10 @@ class Wechat extends Core
|
|
|
$input->SetNotify_url($this->config->GetNotifyUrl());
|
|
|
$input->SetTrade_type($trade_type);
|
|
|
$input->SetProduct_id($product_id);
|
|
|
- $input->SetOpenid($openid);
|
|
|
+ if ($openid != -1) {
|
|
|
+ $input->SetOpenid($openid);
|
|
|
+ }
|
|
|
+
|
|
|
if ($type == 1) {
|
|
|
$order = \WxPayApi::unifiedOrder($this->config, $input);
|
|
|
# 下单信息
|
|
@@ -97,6 +103,27 @@ class Wechat extends Core
|
|
|
return $order;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取app支付
|
|
|
+ */
|
|
|
+ public function app($order)
|
|
|
+ {
|
|
|
+ if (isset($order['prepay_id'])) {
|
|
|
+ $order['partnerid'] = $this->config->GetMerchantId();
|
|
|
+ $order['package'] = 'Sign=WXPay';
|
|
|
+
|
|
|
+ $string = 'appid='.$this->config->GetAppId().'&partnerid='.$order['partnerid'].'&prepayid='.$order['prepay_id'].'&package='.$order['package'].'&noncestr='.$order['nonce_str'].'×tamp='.$order['time'];
|
|
|
+ if($order['sign_type'] == "MD5"){
|
|
|
+ $string = md5($string);
|
|
|
+ } else {
|
|
|
+ $string = hash_hmac("sha256", $string, $this->config->GetKey());
|
|
|
+ }
|
|
|
+
|
|
|
+ $order['sign'] = $string;
|
|
|
+ }
|
|
|
+ return $order;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 获取页面支付
|
|
@@ -154,6 +181,10 @@ class Wechat extends Core
|
|
|
case 2:
|
|
|
$type = 'NATIVE';
|
|
|
break;
|
|
|
+
|
|
|
+ case 3:
|
|
|
+ $type = 'APP';
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
return $type;
|