|
|
@ -256,6 +256,7 @@ class MiniProgramService |
|
|
|
public function paymentPrepare($openid, $out_trade_no, $total_fee, $attach, $body, $detail = '', $trade_type = 'JSAPI', $options = []) |
|
|
|
public function paymentPrepare($openid, $out_trade_no, $total_fee, $attach, $body, $detail = '', $trade_type = 'JSAPI', $options = []) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$order = $this->paymentOrder($openid, $out_trade_no, $total_fee, $attach, $body, $detail, $trade_type, $options); |
|
|
|
$order = $this->paymentOrder($openid, $out_trade_no, $total_fee, $attach, $body, $detail, $trade_type, $options); |
|
|
|
|
|
|
|
Log::info("MiniProgramService paymentPrepare order" ); |
|
|
|
// 获取配置 判断是否为新支付 |
|
|
|
// 获取配置 判断是否为新支付 |
|
|
|
if (isset($this->config['pay_routine_new_mchid']) && $this->config['pay_routine_new_mchid']) { |
|
|
|
if (isset($this->config['pay_routine_new_mchid']) && $this->config['pay_routine_new_mchid']) { |
|
|
|
$result = $this->service->minipay->createorder($order); |
|
|
|
$result = $this->service->minipay->createorder($order); |
|
|
@ -265,12 +266,17 @@ class MiniProgramService |
|
|
|
throw new ValidateException('微信支付错误返回:' . $result->return_msg); |
|
|
|
throw new ValidateException('微信支付错误返回:' . $result->return_msg); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if ($this->v3Pay()) { |
|
|
|
Log::info("MiniProgramService paymentPrepare order2".json_encode($this->v3Pay()) ); |
|
|
|
if ($trade_type == 'MWEB') $trade_type = 'H5'; |
|
|
|
|
|
|
|
$payFunction = 'pay'.ucfirst($trade_type); |
|
|
|
// if ($this->v3Pay()) { |
|
|
|
return $this->service->v3Pay->{$payFunction}($order); |
|
|
|
// Log::info("MiniProgramService paymentPrepare order4" ); |
|
|
|
} else { |
|
|
|
// if ($trade_type == 'MWEB') $trade_type = 'H5'; |
|
|
|
|
|
|
|
// $payFunction = 'pay'.ucfirst($trade_type); |
|
|
|
|
|
|
|
// return $this->service->v3Pay->{$payFunction}($order); |
|
|
|
|
|
|
|
// } else { |
|
|
|
|
|
|
|
Log::info("MiniProgramService paymentPrepare order3" ); |
|
|
|
$result = $this->paymentService()->prepare($order); |
|
|
|
$result = $this->paymentService()->prepare($order); |
|
|
|
|
|
|
|
Log::info("MiniProgramService paymentPrepare ".json_encode($result) ); |
|
|
|
if ($result->return_code == 'SUCCESS' && $result->result_code == 'SUCCESS') { |
|
|
|
if ($result->return_code == 'SUCCESS' && $result->result_code == 'SUCCESS') { |
|
|
|
return $result->prepay_id; |
|
|
|
return $result->prepay_id; |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -282,7 +288,7 @@ class MiniProgramService |
|
|
|
throw new ValidateException('没有获取微信支付的预支付ID,请重新发起支付!'); |
|
|
|
throw new ValidateException('没有获取微信支付的预支付ID,请重新发起支付!'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// } |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -300,7 +306,10 @@ class MiniProgramService |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function jsPay($openid, $out_trade_no, $total_fee, $attach, $body, $detail = '', $trade_type = 'JSAPI', $options = []) |
|
|
|
public function jsPay($openid, $out_trade_no, $total_fee, $attach, $body, $detail = '', $trade_type = 'JSAPI', $options = []) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
Log::info('小程序支付参数版本V3'); |
|
|
|
$paymentPrepare = $this->paymentPrepare($openid, $out_trade_no, $total_fee, $attach, $body, $detail, $trade_type, $options); |
|
|
|
$paymentPrepare = $this->paymentPrepare($openid, $out_trade_no, $total_fee, $attach, $body, $detail, $trade_type, $options); |
|
|
|
|
|
|
|
Log::info('小程序支付参数' . json_encode($paymentPrepare)); |
|
|
|
|
|
|
|
|
|
|
|
if ($this->isV3()) { |
|
|
|
if ($this->isV3()) { |
|
|
|
return $paymentPrepare; |
|
|
|
return $paymentPrepare; |
|
|
|
} |
|
|
|
} |
|
|
|