作者 Cool
1 个管道 的构建 通过 耗费 0 秒

支付调试

@@ -166,34 +166,28 @@ class Store extends Api @@ -166,34 +166,28 @@ class Store extends Api
166 } 166 }
167 } 167 }
168 $order_sn = $param['order_sn'] = get_order_sn(); 168 $order_sn = $param['order_sn'] = get_order_sn();
169 - $pay_data = [];  
170 -// if($this->auth->end_time > time()) {  
171 -// $param['status'] = 2;  
172 -// } else {  
173 - $param['status'] = 1;  
174 -// // 获取小程序配置  
175 -// $options = \config('miniprogram.basic');  
176 -// $app = new Application($options);  
177 -// $payment = $app->payment;  
178 -// // 获取支付参数  
179 -// $attributes = [  
180 -// 'body' => '发布招募合伙人',  
181 -// 'out_trade_no' => $order_sn,  
182 -// 'total_fee' => 1, // $param['money'] * 100  
183 -// 'spbill_create_ip' => request()->ip(), // 可选,如不传该参数,SDK 将会自动获取相应 IP 地址  
184 -// 'notify_url' => url('index/ajax/notify',[],true,true), // 支付结果通知网址,如果不设置则会使用配置里的默认地址  
185 -// 'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型  
186 -// 'openid' => Db::name('third')->where('user_id',$this->auth->id)->value('openid'),  
187 -// ];  
188 -// $order = new Order($attributes);  
189 -// $order_result = $payment->pay($order);  
190 -// if($order_result['return_code'] == 'SUCCESS' && $order_result['result_code'] == 'SUCCESS') {  
191 -// $prepayId = $order_result->prepay_id;  
192 -// $pay_data = $payment->configForJSSDKPayment($prepayId);  
193 -// } else {  
194 -// $this->error($order_result['return_msg']);  
195 -// }  
196 -// } 169 + // 获取配置
  170 + $options = \config('miniprogram.basic');
  171 + $app = new Application($options);
  172 + $payment = $app->payment;
  173 + // 获取支付参数
  174 + $attributes = [
  175 + 'body' => '发布招募合伙人',
  176 + 'out_trade_no' => $order_sn,
  177 + 'total_fee' => 1, // $param['money'] * 100
  178 + 'spbill_create_ip' => request()->ip(), // 可选,如不传该参数,SDK 将会自动获取相应 IP 地址
  179 + 'notify_url' => url('index/ajax/notify',[],true,true), // 支付结果通知网址,如果不设置则会使用配置里的默认地址
  180 + 'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型
  181 + 'openid' => Db::name('third')->where('user_id',$this->auth->id)->value('openid'),
  182 + ];
  183 + $order = new Order($attributes);
  184 + $order_result = $payment->pay($order);
  185 + if($order_result['return_code'] == 'SUCCESS' && $order_result['result_code'] == 'SUCCESS') {
  186 + $prepayId = $order_result->prepay_id;
  187 + $pay_data = $payment->configForJSSDKPayment($prepayId);
  188 + } else {
  189 + $this->error($order_result['return_msg']);
  190 + }
197 Db::startTrans(); 191 Db::startTrans();
198 $result = false; 192 $result = false;
199 $result_invite = true; 193 $result_invite = true;
@@ -462,32 +456,27 @@ class Store extends Api @@ -462,32 +456,27 @@ class Store extends Api
462 $param = (new StoreValidate())->goCheck('store_new'); 456 $param = (new StoreValidate())->goCheck('store_new');
463 $store = $this->get_store(); 457 $store = $this->get_store();
464 $order_sn = $param['order_sn'] = get_order_sn(); 458 $order_sn = $param['order_sn'] = get_order_sn();
465 - $pay_data = [];  
466 - if($this->auth->end_time > time()) {  
467 - $param['status'] = 2; 459 + // 获取配置
  460 + $options = \config('miniprogram.basic');
  461 + $app = new Application($options);
  462 + $payment = $app->payment;
  463 + // 获取支付参数
  464 + $attributes = [
  465 + 'body' => '发布招募合伙人',
  466 + 'out_trade_no' => $order_sn,
  467 + 'total_fee' => 1, // $param['money'] * 100
  468 + 'spbill_create_ip' => request()->ip(), // 可选,如不传该参数,SDK 将会自动获取相应 IP 地址
  469 + 'notify_url' => url('index/ajax/notify',[],true,true), // 支付结果通知网址,如果不设置则会使用配置里的默认地址
  470 + 'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型
  471 + 'openid' => Db::name('third')->where('user_id',$this->auth->id)->value('openid'),
  472 + ];
  473 + $order = new Order($attributes);
  474 + $order_result = $payment->pay($order);
  475 + if($order_result['return_code'] == 'SUCCESS' && $order_result['result_code'] == 'SUCCESS') {
  476 + $prepayId = $order_result->prepay_id;
  477 + $pay_data = $payment->configForJSSDKPayment($prepayId);
468 } else { 478 } else {
469 - $param['status'] = 1;  
470 - // 获取小程序配置  
471 - $options = \config('miniprogram.basic');  
472 - $app = new Application($options);  
473 - $payment = $app->payment;  
474 - // 获取支付参数  
475 - $attributes = [  
476 - 'body' => '发布招募合伙人',  
477 - 'out_trade_no' => $order_sn,  
478 - 'total_fee' => 1, // $param['money'] * 100  
479 - 'spbill_create_ip' => request()->ip(), // 可选,如不传该参数,SDK 将会自动获取相应 IP 地址  
480 - 'notify_url' => url('index/ajax/notify',[],true,true), // 支付结果通知网址,如果不设置则会使用配置里的默认地址  
481 - 'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型  
482 - 'openid' => Db::name('third')->where('user_id',$this->auth->id)->value('openid'),  
483 - ];  
484 - $order = new Order($attributes);  
485 - $order_result = $payment->pay($order);  
486 - if($order_result['return_code'] == 'SUCCESS' && $order_result['result_code'] == 'SUCCESS') {  
487 - $prepayId = $order_result->prepay_id;  
488 - } else {  
489 - $this->error($order_result['return_msg']);  
490 - } 479 + $this->error($order_result['return_msg']);
491 } 480 }
492 $model = new StoreOrder(); 481 $model = new StoreOrder();
493 Db::startTrans(); 482 Db::startTrans();