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