12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?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;
- }
- }
|