Skip to content

H5预签约自动还款协议

服务商调用本接口预先指定签约信息,进行预签约。在完成预签约后,服务商会得到对应的预签约码(presign_token)。服务商H5再携带预签约码参数拉起微信客户端的签约页面,让用户完成签约。签约完成后,将返回服务商H5。若用户同意本次流程,则微信支付会通过服务商指定的回调地址通知签约结果;若用户未同意或者流程执行失败,则不通知签约结果。在发起签约后,服务商签约协议号不能再重复使用,包括签约失败的协议、签约成功后解约的协议及签约成功生效中的协议。服务商可通过查询协议接口确认服务商签约协议号是否已经使用。注意:服务商获取到的预签约码有效期为10分钟。10分钟后,预签约码失效。此时,如果再携带预签约ID跳转到微信客户端进行签约,则将报错。

请求参数类型描述
jsonobject声明请求的JSON数据结构
appidstring商户AppID
plan_idstring模板ID
out_contract_codestring服务商签约协议号
display_namestring用户展示名称
contract_notify_urlstring签约结果通知地址
repayment_dayinteger还款日
repayment_amount_limitstring还款金额上限
sub_mchidstring子商户号
sub_appidstring子商户AppID
real_identityobject用户实名信息
identity_typestring实名验证类型
REAL_IDENTITY_TYPE_INVALID | REAL_IDENTITY_TYPE_ID_CARD 枚举值之一
identity_idstring自然人证件号码
real_namestring自然人姓名
trade_infoobject交易信息
out_trade_nostring商户侧交易单号
deduct_amountinteger还款金额
descriptionstring产品描述
attachstring商户数据包
notify_urlstring商户回调地址
jump_infoobject跳转控制信息
jump_appidstring签约完后要跳转到的应用AppID
headersobject声明请求的头参数
Wechatpay-Serialstring微信支付公钥ID/平台证书序列号
php
$instance->v3->creditRepayment->partner->contracts->h5Presign->postAsync([
  'json' => [
    'appid'                  => 'wxd678efh567hg6787',
    'plan_id'                => '123',
    'out_contract_code'      => '100001256',
    'display_name'           => '*明',
    'contract_notify_url'    => 'https://pay.weixin.qq.com',
    'repayment_day'          => 1,
    'repayment_amount_limit' => '10000',
    'sub_mchid'              => '1000000109',
    'sub_appid'              => 'example_sub_appid',
    'real_identity'          => [
      'identity_type' => 'REAL_IDENTITY_TYPE_INVALID',
      'identity_id'   => '1axtI9EZUr0343c89xQznxau+cRWPKP4YhVAoj==',
      'real_name'     => 'OEimkKuua8igpd+0YDgqF2Z61leeGD7x87j3Ph==',
    ],
    'trade_info'             => [
      'out_trade_no'  => '1217752501201407033233368018',
      'deduct_amount' => 10000,
      'description'   => '信贷还款',
      'attach'        => '备注信息',
      'notify_url'    => 'https://www.test.com',
    ],
    'jump_info'              => [
      'jump_appid' => 'example_jump_appid',
    ],
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/credit-repayment/partner/contracts/h5-presign')->postAsync([
  'json' => [
    'appid'                  => 'wxd678efh567hg6787',
    'plan_id'                => '123',
    'out_contract_code'      => '100001256',
    'display_name'           => '*明',
    'contract_notify_url'    => 'https://pay.weixin.qq.com',
    'repayment_day'          => 1,
    'repayment_amount_limit' => '10000',
    'sub_mchid'              => '1000000109',
    'sub_appid'              => 'example_sub_appid',
    'real_identity'          => [
      'identity_type' => 'REAL_IDENTITY_TYPE_INVALID',
      'identity_id'   => '1axtI9EZUr0343c89xQznxau+cRWPKP4YhVAoj==',
      'real_name'     => 'OEimkKuua8igpd+0YDgqF2Z61leeGD7x87j3Ph==',
    ],
    'trade_info'             => [
      'out_trade_no'  => '1217752501201407033233368018',
      'deduct_amount' => 10000,
      'description'   => '信贷还款',
      'attach'        => '备注信息',
      'notify_url'    => 'https://www.test.com',
    ],
    'jump_info'              => [
      'jump_appid' => 'example_jump_appid',
    ],
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/credit-repayment/partner/contracts/h5-presign']->postAsync([
  'json' => [
    'appid'                  => 'wxd678efh567hg6787',
    'plan_id'                => '123',
    'out_contract_code'      => '100001256',
    'display_name'           => '*明',
    'contract_notify_url'    => 'https://pay.weixin.qq.com',
    'repayment_day'          => 1,
    'repayment_amount_limit' => '10000',
    'sub_mchid'              => '1000000109',
    'sub_appid'              => 'example_sub_appid',
    'real_identity'          => [
      'identity_type' => 'REAL_IDENTITY_TYPE_INVALID',
      'identity_id'   => '1axtI9EZUr0343c89xQznxau+cRWPKP4YhVAoj==',
      'real_name'     => 'OEimkKuua8igpd+0YDgqF2Z61leeGD7x87j3Ph==',
    ],
    'trade_info'             => [
      'out_trade_no'  => '1217752501201407033233368018',
      'deduct_amount' => 10000,
      'description'   => '信贷还款',
      'attach'        => '备注信息',
      'notify_url'    => 'https://www.test.com',
    ],
    'jump_info'              => [
      'jump_appid' => 'example_jump_appid',
    ],
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->creditRepayment->partner->contracts->h5Presign->post([
  'json' => [
    'appid'                  => 'wxd678efh567hg6787',
    'plan_id'                => '123',
    'out_contract_code'      => '100001256',
    'display_name'           => '*明',
    'contract_notify_url'    => 'https://pay.weixin.qq.com',
    'repayment_day'          => 1,
    'repayment_amount_limit' => '10000',
    'sub_mchid'              => '1000000109',
    'sub_appid'              => 'example_sub_appid',
    'real_identity'          => [
      'identity_type' => 'REAL_IDENTITY_TYPE_INVALID',
      'identity_id'   => '1axtI9EZUr0343c89xQznxau+cRWPKP4YhVAoj==',
      'real_name'     => 'OEimkKuua8igpd+0YDgqF2Z61leeGD7x87j3Ph==',
    ],
    'trade_info'             => [
      'out_trade_no'  => '1217752501201407033233368018',
      'deduct_amount' => 10000,
      'description'   => '信贷还款',
      'attach'        => '备注信息',
      'notify_url'    => 'https://www.test.com',
    ],
    'jump_info'              => [
      'jump_appid' => 'example_jump_appid',
    ],
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/credit-repayment/partner/contracts/h5-presign')->post([
  'json' => [
    'appid'                  => 'wxd678efh567hg6787',
    'plan_id'                => '123',
    'out_contract_code'      => '100001256',
    'display_name'           => '*明',
    'contract_notify_url'    => 'https://pay.weixin.qq.com',
    'repayment_day'          => 1,
    'repayment_amount_limit' => '10000',
    'sub_mchid'              => '1000000109',
    'sub_appid'              => 'example_sub_appid',
    'real_identity'          => [
      'identity_type' => 'REAL_IDENTITY_TYPE_INVALID',
      'identity_id'   => '1axtI9EZUr0343c89xQznxau+cRWPKP4YhVAoj==',
      'real_name'     => 'OEimkKuua8igpd+0YDgqF2Z61leeGD7x87j3Ph==',
    ],
    'trade_info'             => [
      'out_trade_no'  => '1217752501201407033233368018',
      'deduct_amount' => 10000,
      'description'   => '信贷还款',
      'attach'        => '备注信息',
      'notify_url'    => 'https://www.test.com',
    ],
    'jump_info'              => [
      'jump_appid' => 'example_jump_appid',
    ],
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/credit-repayment/partner/contracts/h5-presign']->post([
  'json' => [
    'appid'                  => 'wxd678efh567hg6787',
    'plan_id'                => '123',
    'out_contract_code'      => '100001256',
    'display_name'           => '*明',
    'contract_notify_url'    => 'https://pay.weixin.qq.com',
    'repayment_day'          => 1,
    'repayment_amount_limit' => '10000',
    'sub_mchid'              => '1000000109',
    'sub_appid'              => 'example_sub_appid',
    'real_identity'          => [
      'identity_type' => 'REAL_IDENTITY_TYPE_INVALID',
      'identity_id'   => '1axtI9EZUr0343c89xQznxau+cRWPKP4YhVAoj==',
      'real_name'     => 'OEimkKuua8igpd+0YDgqF2Z61leeGD7x87j3Ph==',
    ],
    'trade_info'             => [
      'out_trade_no'  => '1217752501201407033233368018',
      'deduct_amount' => 10000,
      'description'   => '信贷还款',
      'attach'        => '备注信息',
      'notify_url'    => 'https://www.test.com',
    ],
    'jump_info'              => [
      'jump_appid' => 'example_jump_appid',
    ],
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
redirect_urlstring拉起微信支付签约页的URL

参阅 官方文档

Published on the GitHub by TheNorthMemory