MiniappGateway.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
<?php
namespace Yansongda\Pay\Gateways\Wechat;
use Yansongda\Pay\Exceptions\InvalidArgumentException;
class MiniappGateway extends Wechat
{
/**
* get trade type config.
*
* @author yansongda <me@yansongda.cn>
*
* @return string [description]
*/
protected function getTradeType()
{
return 'JSAPI';
}
/**
* 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('miniapp_id'))) {
throw new InvalidArgumentException('Missing Config -- [miniapp_id]');
}
$this->config['appid'] = $this->user_config->get('miniapp_id');
$payRequest = [
'appId' => $this->user_config->get('miniapp_id'),
'timeStamp' => strval(time()),
'nonceStr' => $this->createNonceStr(),
'package' => 'prepay_id='.$this->preOrder($config_biz)['prepay_id'],
'signType' => 'MD5',
];
$payRequest['paySign'] = $this->getSign($payRequest);
return $payRequest;
}
}