Skip to content

Conversation

@kanghuli
Copy link
Contributor

@kanghuli kanghuli commented Sep 2, 2021

本次优化服务商模式小程序支付,考虑3种场景

交易场景1:
  • 发生在服务商小程序内,则以服务商小程序app_id-做服务端JS下单,
  • 此时JS下单 sub_appid可为空,返回给小程序端的参数配置,使用mini_app_id计算签名。
交易场景2:
  • 发生在商户小程序内,服务商已经绑定了自有小程序,即mini_app_id有值,则以mini_app_id+sub_mchid做服务端JS下单,
  • 此时JS下单sub_appid需要传参且有值,返回给小程序端的参数配置,使用sub_appid计算签名。
交易场景3:
  • 发生在商户小程序内,服务商没小程序,仅绑定公众号,即mp_app_id有值,则以mp_app_id+sub_mchid做服务端JS下单,
  • 此时JS下单 sub_appid需要传参且有值,返回给小程序端的参数配置,使用sub_appid计算签名。

$config = get_wechat_config($rocket->getParams());

if (Pay::MODE_SERVICE == $config->get('mode')) {
return $rocket->getPayload()->get('sub_appid') ?? $config->get('mini_app_id');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return $rocket->getPayload()->get('sub_appid') ?? $config->get('mini_app_id');
return $rocket->getPayload()->get('sub_appid', $config->get('mini_app_id'));

if (Pay::MODE_SERVICE == $config->get('mode')) {
return [
'sp_appid' => $config->get('app_id', ''),
'sp_appid' => $config->get('mini_app_id', '') ?: $config->get('mp_app_id', ''),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

self::assertArrayHasKey('paySign', $contents->all());
}

public function testPartner()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最好也覆盖一下 从 config 获取数据的情况

self::assertEquals('1600314070', $payload->get('sub_mchid'));
}

public function testWechatIdPartnerDirect2()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

覆盖下 mini_app_id 的情况

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

优化了下,可以看看

@yansongda yansongda merged commit 2824b7c into yansongda:master Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants