Skip to content

H5预签约

该方式适用于手机、平板电脑等使用H5浏览器的设备场景使用微信签约扣款。商户在网站前端通过微信支付H5纯签约接口与用户签订委托扣款协议,再通过后台接口申请扣款来完成代扣交易。

请求参数类型描述
base_uristring声明接入点https://apihk.mch.weixin.qq.com/(香港接入)
jsonobject声明请求的JSON数据结构
appidstring机构APPID
sub_mchidstring子商户号
sp_appidstring机构appid
sp_mchidstring机构商户号
sub_appidstring子商户应用ID
plan_idinteger模板ID
out_contract_codestring商户侧签约协议号
user_display_namestring用户账户展示名称
success_notify_urlstring签约成功通知url
return_appidstring回调应用AppID
user_client_ipstring用户客户端IP
expired_timestring过期时间
return_urlstring签约完成跳转URL
php
$instance->v3->global->papay->contracts->h5PreEntrustSign->postAsync([
  'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
  'json' => [
    'appid' => 'wxd678efh567hg6787',
    'sub_mchid' => '1230000109',
    'sp_appid' => 'wx8888888888888888',
    'sp_mchid' => '3200000001',
    'sub_appid' => 'wxcbda96de0b165484',
    'plan_id' => 123,
    'out_contract_code' => '100001256',
    'user_display_name' => '张三',
    'success_notify_url' => 'https://pay.weixin.qq.com',
    'return_appid' => 'wxcbda96de0b165484',
    'user_client_ip' => '119.145.83.6',
    'expired_time' => '2021-11-20T13:29:35+08:00',
    'return_url' => 'https://pay.weixin.qq.com',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/global/papay/contracts/h5-pre-entrust-sign')->postAsync([
  'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
  'json' => [
    'appid' => 'wxd678efh567hg6787',
    'sub_mchid' => '1230000109',
    'sp_appid' => 'wx8888888888888888',
    'sp_mchid' => '3200000001',
    'sub_appid' => 'wxcbda96de0b165484',
    'plan_id' => 123,
    'out_contract_code' => '100001256',
    'user_display_name' => '张三',
    'success_notify_url' => 'https://pay.weixin.qq.com',
    'return_appid' => 'wxcbda96de0b165484',
    'user_client_ip' => '119.145.83.6',
    'expired_time' => '2021-11-20T13:29:35+08:00',
    'return_url' => 'https://pay.weixin.qq.com',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/global/papay/contracts/h5-pre-entrust-sign']->postAsync([
  'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
  'json' => [
    'appid' => 'wxd678efh567hg6787',
    'sub_mchid' => '1230000109',
    'sp_appid' => 'wx8888888888888888',
    'sp_mchid' => '3200000001',
    'sub_appid' => 'wxcbda96de0b165484',
    'plan_id' => 123,
    'out_contract_code' => '100001256',
    'user_display_name' => '张三',
    'success_notify_url' => 'https://pay.weixin.qq.com',
    'return_appid' => 'wxcbda96de0b165484',
    'user_client_ip' => '119.145.83.6',
    'expired_time' => '2021-11-20T13:29:35+08:00',
    'return_url' => 'https://pay.weixin.qq.com',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->global->papay->contracts->h5PreEntrustSign->post([
  'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
  'json' => [
    'appid' => 'wxd678efh567hg6787',
    'sub_mchid' => '1230000109',
    'sp_appid' => 'wx8888888888888888',
    'sp_mchid' => '3200000001',
    'sub_appid' => 'wxcbda96de0b165484',
    'plan_id' => 123,
    'out_contract_code' => '100001256',
    'user_display_name' => '张三',
    'success_notify_url' => 'https://pay.weixin.qq.com',
    'return_appid' => 'wxcbda96de0b165484',
    'user_client_ip' => '119.145.83.6',
    'expired_time' => '2021-11-20T13:29:35+08:00',
    'return_url' => 'https://pay.weixin.qq.com',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/global/papay/contracts/h5-pre-entrust-sign')->post([
  'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
  'json' => [
    'appid' => 'wxd678efh567hg6787',
    'sub_mchid' => '1230000109',
    'sp_appid' => 'wx8888888888888888',
    'sp_mchid' => '3200000001',
    'sub_appid' => 'wxcbda96de0b165484',
    'plan_id' => 123,
    'out_contract_code' => '100001256',
    'user_display_name' => '张三',
    'success_notify_url' => 'https://pay.weixin.qq.com',
    'return_appid' => 'wxcbda96de0b165484',
    'user_client_ip' => '119.145.83.6',
    'expired_time' => '2021-11-20T13:29:35+08:00',
    'return_url' => 'https://pay.weixin.qq.com',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/global/papay/contracts/h5-pre-entrust-sign']->post([
  'base_uri' => 'https://apihk.mch.weixin.qq.com/', // 接入点(香港接入)
  'json' => [
    'appid' => 'wxd678efh567hg6787',
    'sub_mchid' => '1230000109',
    'sp_appid' => 'wx8888888888888888',
    'sp_mchid' => '3200000001',
    'sub_appid' => 'wxcbda96de0b165484',
    'plan_id' => 123,
    'out_contract_code' => '100001256',
    'user_display_name' => '张三',
    'success_notify_url' => 'https://pay.weixin.qq.com',
    'return_appid' => 'wxcbda96de0b165484',
    'user_client_ip' => '119.145.83.6',
    'expired_time' => '2021-11-20T13:29:35+08:00',
    'return_url' => 'https://pay.weixin.qq.com',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
sign_urlstring签约跳转URL

参阅 官方文档

Published on the GitHub by TheNorthMemory