Skip to content

服务商模式支付后场景预签约

服务商下单成功并获取`prepay_id`后,需先调用该预签约接口完成预签约。预签约成功后,若用户支付成功、且操作未超时(预签约会话在2小时的有效期内)、且无其他特殊原因,将提示用户可以开通免密支付签约;预签约失败时,将不会提示用户开通免密支付。 注意 用户在微信的页面中完成免密支付签约后,微信会同时将签约信息通过异步通知的方式通知给商户后台。 如果用户放弃签约或签约失败则不通知。

请求参数类型描述
jsonobject声明请求的JSON数据结构
sp_appidstring商户AppID
sp_openidstring用户标识
sub_mchidstring子商户号
sub_appidstring子商户AppID
sub_openidstring用户子标识
service_idnumber免密支付服务ID
out_contract_codestring商户签约协议号
notify_urlstring回调通知地址
contract_display_accountstring用户账户展示名称
prepay_idstring预支付交易会话标识
php
$instance->v3->passwordExemptContract->contracts->serviceProvider->preEntrustSign->payRedirectSign->postAsync([
  'json' => [
    'sp_appid' => 'wxd678efh567hg6787',
    'sp_openid' => 'oYobu0MVnQfWpSMOYJz2AHPG_gQw',
    'sub_mchid' => '1900000109',
    'sub_appid' => 'wxd678efh567hg6787',
    'sub_openid' => 'wxd678efh567hg6787',
    'service_id' => 12535,
    'out_contract_code' => 'wxwtdk20200910100000',
    'notify_url' => 'https://yourapp.com/notify',
    'contract_display_account' => '微信代扣用户A',
    'prepay_id' => 'wx201410272009395522657a690389285100',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/password-exempt-contract/contracts/service-provider/pre-entrust-sign/pay-redirect-sign')->postAsync([
  'json' => [
    'sp_appid' => 'wxd678efh567hg6787',
    'sp_openid' => 'oYobu0MVnQfWpSMOYJz2AHPG_gQw',
    'sub_mchid' => '1900000109',
    'sub_appid' => 'wxd678efh567hg6787',
    'sub_openid' => 'wxd678efh567hg6787',
    'service_id' => 12535,
    'out_contract_code' => 'wxwtdk20200910100000',
    'notify_url' => 'https://yourapp.com/notify',
    'contract_display_account' => '微信代扣用户A',
    'prepay_id' => 'wx201410272009395522657a690389285100',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/password-exempt-contract/contracts/service-provider/pre-entrust-sign/pay-redirect-sign']->postAsync([
  'json' => [
    'sp_appid' => 'wxd678efh567hg6787',
    'sp_openid' => 'oYobu0MVnQfWpSMOYJz2AHPG_gQw',
    'sub_mchid' => '1900000109',
    'sub_appid' => 'wxd678efh567hg6787',
    'sub_openid' => 'wxd678efh567hg6787',
    'service_id' => 12535,
    'out_contract_code' => 'wxwtdk20200910100000',
    'notify_url' => 'https://yourapp.com/notify',
    'contract_display_account' => '微信代扣用户A',
    'prepay_id' => 'wx201410272009395522657a690389285100',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->passwordExemptContract->contracts->serviceProvider->preEntrustSign->payRedirectSign->post([
  'json' => [
    'sp_appid' => 'wxd678efh567hg6787',
    'sp_openid' => 'oYobu0MVnQfWpSMOYJz2AHPG_gQw',
    'sub_mchid' => '1900000109',
    'sub_appid' => 'wxd678efh567hg6787',
    'sub_openid' => 'wxd678efh567hg6787',
    'service_id' => 12535,
    'out_contract_code' => 'wxwtdk20200910100000',
    'notify_url' => 'https://yourapp.com/notify',
    'contract_display_account' => '微信代扣用户A',
    'prepay_id' => 'wx201410272009395522657a690389285100',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/password-exempt-contract/contracts/service-provider/pre-entrust-sign/pay-redirect-sign')->post([
  'json' => [
    'sp_appid' => 'wxd678efh567hg6787',
    'sp_openid' => 'oYobu0MVnQfWpSMOYJz2AHPG_gQw',
    'sub_mchid' => '1900000109',
    'sub_appid' => 'wxd678efh567hg6787',
    'sub_openid' => 'wxd678efh567hg6787',
    'service_id' => 12535,
    'out_contract_code' => 'wxwtdk20200910100000',
    'notify_url' => 'https://yourapp.com/notify',
    'contract_display_account' => '微信代扣用户A',
    'prepay_id' => 'wx201410272009395522657a690389285100',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/password-exempt-contract/contracts/service-provider/pre-entrust-sign/pay-redirect-sign']->post([
  'json' => [
    'sp_appid' => 'wxd678efh567hg6787',
    'sp_openid' => 'oYobu0MVnQfWpSMOYJz2AHPG_gQw',
    'sub_mchid' => '1900000109',
    'sub_appid' => 'wxd678efh567hg6787',
    'sub_openid' => 'wxd678efh567hg6787',
    'service_id' => 12535,
    'out_contract_code' => 'wxwtdk20200910100000',
    'notify_url' => 'https://yourapp.com/notify',
    'contract_display_account' => '微信代扣用户A',
    'prepay_id' => 'wx201410272009395522657a690389285100',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
mchidstring商户号
sub_mchidstring子商户号
service_idnumber免密支付服务ID
out_contract_codestring商户签约协议号

参阅 官方文档

Published on the GitHub by TheNorthMemory