Skip to content

Commit

Permalink
Merge pull request #36 from gaobinzhan/master
Browse files Browse the repository at this point in the history
fix: miniprogram pay
  • Loading branch information
kiss291323003 authored Nov 20, 2020
2 parents 2d12206 + 6e6c59d commit 7c56c07
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 7c56c07

Please sign in to comment.