diff --git a/WeChat/Pay.php b/WeChat/Pay.php index b063a43..062afdb 100644 --- a/WeChat/Pay.php +++ b/WeChat/Pay.php @@ -55,6 +55,17 @@ class Pay extends BasicWePay return $pay->jsapiParams($prepay_id); } + /** + * 获取APP支付参数 + * @param string $prepay_id 统一下单预支付码 + * @return array + */ + public function createParamsForApp($prepay_id) + { + $pay = new Order($this->config->get()); + return $pay->appParams($prepay_id); + } + /** * 获取支付规则二维码 * @param string $product_id 商户定义的商品id 或者订单号 @@ -65,7 +76,7 @@ class Pay extends BasicWePay $pay = new Order($this->config->get()); return $pay->qrcParams($product_id); } - + /** * 查询订单 * @param array $options diff --git a/WePay/Order.php b/WePay/Order.php index 1b9de10..d20a318 100644 --- a/WePay/Order.php +++ b/WePay/Order.php @@ -100,6 +100,25 @@ class Order extends BasicWePay return "weixin://wxpay/bizpayurl?" . http_build_query($data); } + /** + * 获取微信App支付秘需参数 + * @param string $prepayId 统一下单预支付码 + * @return array + */ + public function appParams($prepayId) + { + $data = [ + 'appid' => $this->config->get('appid'), + 'partnerid' => $this->config->get('mch_id'), + 'prepayid' => (string)$prepayId, + 'package' => 'Sign=WXPay', + 'time_stamp' => (string)time(), + 'nonce_str' => Tools::createNoncestr(), + ]; + $data['sign'] = $this->getPaySign($data, 'MD5'); + return $data; + } + /** * 刷卡支付 撤销订单 * @param array $options