|
@@ -23,7 +23,6 @@ class Official implements PayMerchantInterface
|
|
private $key;
|
|
private $key;
|
|
private $cert_path;
|
|
private $cert_path;
|
|
private $key_path;
|
|
private $key_path;
|
|
- private $trade_type;
|
|
|
|
private $app;
|
|
private $app;
|
|
|
|
|
|
public function __construct($config)
|
|
public function __construct($config)
|
|
@@ -35,7 +34,6 @@ class Official implements PayMerchantInterface
|
|
$this->token = isset($config['token']) ? $config['token'] : '';
|
|
$this->token = isset($config['token']) ? $config['token'] : '';
|
|
$this->key_path = isset($config['key_path']) ? $config['key_path'] : '';
|
|
$this->key_path = isset($config['key_path']) ? $config['key_path'] : '';
|
|
$this->cert_path = isset($config['cert_path']) ? $config['cert_path'] : '';
|
|
$this->cert_path = isset($config['cert_path']) ? $config['cert_path'] : '';
|
|
- $this->trade_type = isset($config['trade_type']) ? $config['trade_type'] : 'JSAPI';
|
|
|
|
$options = [
|
|
$options = [
|
|
'app_id' => $this->appid,
|
|
'app_id' => $this->appid,
|
|
'secret' => $this->secret,
|
|
'secret' => $this->secret,
|
|
@@ -54,8 +52,9 @@ class Official implements PayMerchantInterface
|
|
{
|
|
{
|
|
$app = $this->app;
|
|
$app = $this->app;
|
|
$payment = $app->payment;
|
|
$payment = $app->payment;
|
|
|
|
+ $trade_type = isset($data['trade_type']) ? $data['trade_type'] : 'JSAPI';
|
|
$attributes = [
|
|
$attributes = [
|
|
- 'trade_type' => $this->trade_type,
|
|
|
|
|
|
+ 'trade_type' => $trade_type,
|
|
'body' => $data['body'],
|
|
'body' => $data['body'],
|
|
'detail' => isset($data['detail']) ? $data['detail'] : '',
|
|
'detail' => isset($data['detail']) ? $data['detail'] : '',
|
|
'out_trade_no' => $data['trade_no'],
|
|
'out_trade_no' => $data['trade_no'],
|
|
@@ -64,11 +63,11 @@ class Official implements PayMerchantInterface
|
|
'openid' => isset($data['openid']) ? $data['openid'] : '',
|
|
'openid' => isset($data['openid']) ? $data['openid'] : '',
|
|
'spbill_create_ip' => $data['create_ip'],
|
|
'spbill_create_ip' => $data['create_ip'],
|
|
'attach' => $data['remark']
|
|
'attach' => $data['remark']
|
|
- ];
|
|
|
|
|
|
+ ];
|
|
$order = new Wxorder($attributes);
|
|
$order = new Wxorder($attributes);
|
|
$result = $payment->prepare($order);
|
|
$result = $payment->prepare($order);
|
|
if ($result->return_code == 'SUCCESS' && $result->result_code == 'SUCCESS') {
|
|
if ($result->return_code == 'SUCCESS' && $result->result_code == 'SUCCESS') {
|
|
- switch ($this->trade_type) {
|
|
|
|
|
|
+ switch ($trade_type) {
|
|
case 'JSAPI':
|
|
case 'JSAPI':
|
|
$data = [
|
|
$data = [
|
|
'appId' => $result->appid,
|
|
'appId' => $result->appid,
|