AppGateway.php
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace Yansongda\Pay\Gateways\Wechat;
use Yansongda\Pay\Exceptions\InvalidArgumentException;
class AppGateway extends Wechat
{
/**
* get trade type config.
*
* @author yansongda <me@yansongda.cn>
*
* @return string
*/
protected function getTradeType()
{
return 'APP';
}
/**
* pay a order.
*
* @author yansongda <me@yansongda.cn>
*
* @param array $config_biz
*
* @return array
*/
public function pay(array $config_biz = [])
{
if (is_null($this->user_config->get('appid'))) {
throw new InvalidArgumentException('Missing Config -- [appid]');
}
$this->config['appid'] = $this->user_config->get('appid');
$payRequest = [
'appid' => $this->user_config->get('appid'),
'partnerid' => $this->user_config->get('mch_id'),
'prepayid' => $this->preOrder($config_biz)['prepay_id'],
'timestamp' => strval(time()),
'noncestr' => $this->createNonceStr(),
'package' => 'Sign=WXPay',
];
$payRequest['sign'] = $this->getSign($payRequest);
return $payRequest;
}
}