Skip to content

Commit

Permalink
fix: miniprogram pay
Browse files Browse the repository at this point in the history
  • Loading branch information
Player626 committed Nov 19, 2020
1 parent 2d12206 commit 6e6c59d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/WeChat/WeChatPay/MiniProgram.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use EasySwoole\Pay\Exceptions\GatewayException;
use EasySwoole\Pay\Exceptions\InvalidArgumentException;
use EasySwoole\Pay\Exceptions\InvalidConfigException;
use EasySwoole\Pay\Exceptions\InvalidSignException;
use EasySwoole\Pay\WeChat\RequestBean\Base;
use EasySwoole\Pay\WeChat\RequestBean\PayBase;
Expand All @@ -28,6 +29,11 @@ class MiniProgram extends AbstractPayBase
*/
public function pay(Base $bean): MiniProgramResponse
{
$appId = $bean->getSubAppid() ? $this->config->getMiniAppId() : null;
if ($appId === null) {
throw new InvalidConfigException('appId not exist');
}

$utility = new Utility($this->config);

// 如果没有定义回调 使用全局回调
Expand All @@ -37,7 +43,7 @@ public function pay(Base $bean): MiniProgramResponse

$result = $utility->requestApi($this->requestPath(), $bean);
$result = [
'appId' => $this->config->getMiniAppId(),
'appId' => $appId,
'package' => 'prepay_id=' . $result['prepay_id'],
'signType' => empty($bean->getSignType()) ? 'MD5' : $bean->getSignType()
];
Expand Down

0 comments on commit 6e6c59d

Please sign in to comment.