修复小程序支付报错

This commit is contained in:
sugar1569 2019-01-26 11:46:06 +08:00
parent f0e88b4434
commit c1f23f3a78

View File

@ -2,7 +2,7 @@
namespace service; namespace service;
use think\Url; use think\Url;
use service\HttpService; use service\HttpService;
use think\Request;
/** /**
* 小程序支付 * 小程序支付
@ -19,6 +19,7 @@ class RoutineService{
* @param $body $body 提示 * @param $body $body 提示
* @return mixed * @return mixed
*/ */
//TODO 小程序支付
public static function payRoutine($openid,$out_trade_no,$fee,$attach,$body){ public static function payRoutine($openid,$out_trade_no,$fee,$attach,$body){
$payment = SystemConfigService::more(['site_url','routine_appId','routine_appsecret','pay_routine_mchid','pay_routine_client_cert','pay_routine_client_key','pay_routine_key','pay_weixin_open']); $payment = SystemConfigService::more(['site_url','routine_appId','routine_appsecret','pay_routine_mchid','pay_routine_client_cert','pay_routine_client_key','pay_routine_key','pay_weixin_open']);
$config = array( $config = array(
@ -32,10 +33,11 @@ class RoutineService{
'body' => $body, 'body' => $body,
'mch_id' => $config['mch_id'], 'mch_id' => $config['mch_id'],
'nonce_str' => self::nonce_str(),//随机字符串 'nonce_str' => self::nonce_str(),//随机字符串
'notify_url' => $payment['site_url'].Url::build('routine/Routine/notify'), // 'notify_url' => $payment['site_url'].Url::build('routine/Routine/notify'),
'notify_url' => Request::instance()->domain().Url::build('/routine/Routine/notify'),
'openid' => $openid, 'openid' => $openid,
'out_trade_no' => $out_trade_no, 'out_trade_no' => $out_trade_no,
'spbill_create_ip' => self::get_server_ip()?:'127.0.0.1',//终端的ip 'spbill_create_ip' => Request::instance()->ip()?:'127.0.0.1',//终端的ip
'total_fee' => $fee*100, //单位 转为分 'total_fee' => $fee*100, //单位 转为分
'trade_type' => 'JSAPI'//交易类型 默认 'trade_type' => 'JSAPI'//交易类型 默认
); );