H5纯签约
该方式适用于手机、平板电脑等使用H5浏览器的设备场景使用微信签约扣款。商户在网站前端通过微信支付H5纯签约接口与用户签订委托扣款协议,再通过后台接口申请扣款来完成代扣交易。
请求参数 | 类型 | 描述 |
---|---|---|
query | object | 声明请求的查询参数 |
appid | string | 应用ID |
mch_id | string | 商户号 |
sub_appid | string | 子商户应用ID |
sub_mch_id | string | 子商户号 |
plan_id | string | 模板id |
contract_code | string | 签约协议号 |
request_serial | integer | 请求序列号 |
contract_display_account | string | 用户账户展示名称 |
notify_url | string | 回调通知url |
version | string | 版本号1.0 枚举值 |
sign | string | 签名 |
sign_type | string | 签名类型MD5 | HMAC-SHA256 枚举值之一 |
timestamp | string | 时间戳 |
clientip | string | 客户端 IP |
deviceid | string | 设备ID |
mobile | string | 手机号 |
string | 邮箱地址 | |
string | QQ号 | |
openid | string | 微信openID |
creid | string | 身份证号 |
outerid | string | 商户侧用户标识 |
return_appid | string | 回调应用appid |
php
use WeChatPay\Hash;
use WeChatPay\Formatter;
$params = [
'appid' => 'wxcbda96de0b165486',
'mch_id' => '1200009811',
'sub_appid' => 'wxcbda96de0b165489',
'sub_mch_id' => '1900000109',
'plan_id' => '12535',
'contract_code' => '100000',
'request_serial' => '1000',
'contract_display_account' => '微信代扣',
'notify_url' => 'https://weixin.qq.com',
'version' => '1.0',
'timestamp' => Formatter::timestamp(),
'clientip' => '119.145.83.6',
'deviceid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'mobile' => '18933432355',
'email' => 'aobama@whitehouse.com',
'qq' => '100243',
'openid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'creid' => '110102199701011000',
'outerid' => 'user123',
'return_appid' => 'wxcbda96de0b165486',
];
$params['sign'] = Hash::sign(
Hash::ALGO_HMAC_SHA256,
Formatter::queryStringLike(
Formatter::ksort($params)
),
$apiv2Key
);
$instance->v2->papay->partner->h5entrustweb->getAsync([
'query' => $params
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
use WeChatPay\Hash;
use WeChatPay\Formatter;
$params = [
'appid' => 'wxcbda96de0b165486',
'mch_id' => '1200009811',
'sub_appid' => 'wxcbda96de0b165489',
'sub_mch_id' => '1900000109',
'plan_id' => '12535',
'contract_code' => '100000',
'request_serial' => '1000',
'contract_display_account' => '微信代扣',
'notify_url' => 'https://weixin.qq.com',
'version' => '1.0',
'timestamp' => Formatter::timestamp(),
'clientip' => '119.145.83.6',
'deviceid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'mobile' => '18933432355',
'email' => 'aobama@whitehouse.com',
'qq' => '100243',
'openid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'creid' => '110102199701011000',
'outerid' => 'user123',
'return_appid' => 'wxcbda96de0b165486',
];
$params['sign'] = Hash::sign(
Hash::ALGO_HMAC_SHA256,
Formatter::queryStringLike(
Formatter::ksort($params)
),
$apiv2Key
);
$instance->chain('v2/papay/partner/h5entrustweb')->getAsync([
'query' => $params
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
use WeChatPay\Hash;
use WeChatPay\Formatter;
$params = [
'appid' => 'wxcbda96de0b165486',
'mch_id' => '1200009811',
'sub_appid' => 'wxcbda96de0b165489',
'sub_mch_id' => '1900000109',
'plan_id' => '12535',
'contract_code' => '100000',
'request_serial' => '1000',
'contract_display_account' => '微信代扣',
'notify_url' => 'https://weixin.qq.com',
'version' => '1.0',
'timestamp' => Formatter::timestamp(),
'clientip' => '119.145.83.6',
'deviceid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'mobile' => '18933432355',
'email' => 'aobama@whitehouse.com',
'qq' => '100243',
'openid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'creid' => '110102199701011000',
'outerid' => 'user123',
'return_appid' => 'wxcbda96de0b165486',
];
$params['sign'] = Hash::sign(
Hash::ALGO_HMAC_SHA256,
Formatter::queryStringLike(
Formatter::ksort($params)
),
$apiv2Key
);
$instance['v2/papay/partner/h5entrustweb']->getAsync([
'query' => $params
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
use WeChatPay\Hash;
use WeChatPay\Formatter;
$params = [
'appid' => 'wxcbda96de0b165486',
'mch_id' => '1200009811',
'sub_appid' => 'wxcbda96de0b165489',
'sub_mch_id' => '1900000109',
'plan_id' => '12535',
'contract_code' => '100000',
'request_serial' => '1000',
'contract_display_account' => '微信代扣',
'notify_url' => 'https://weixin.qq.com',
'version' => '1.0',
'timestamp' => Formatter::timestamp(),
'clientip' => '119.145.83.6',
'deviceid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'mobile' => '18933432355',
'email' => 'aobama@whitehouse.com',
'qq' => '100243',
'openid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'creid' => '110102199701011000',
'outerid' => 'user123',
'return_appid' => 'wxcbda96de0b165486',
];
$params['sign'] = Hash::sign(
Hash::ALGO_HMAC_SHA256,
Formatter::queryStringLike(
Formatter::ksort($params)
),
$apiv2Key
);
$response = $instance->v2->papay->partner->h5entrustweb->get([
'query' => $params
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
use WeChatPay\Hash;
use WeChatPay\Formatter;
$params = [
'appid' => 'wxcbda96de0b165486',
'mch_id' => '1200009811',
'sub_appid' => 'wxcbda96de0b165489',
'sub_mch_id' => '1900000109',
'plan_id' => '12535',
'contract_code' => '100000',
'request_serial' => '1000',
'contract_display_account' => '微信代扣',
'notify_url' => 'https://weixin.qq.com',
'version' => '1.0',
'timestamp' => Formatter::timestamp(),
'clientip' => '119.145.83.6',
'deviceid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'mobile' => '18933432355',
'email' => 'aobama@whitehouse.com',
'qq' => '100243',
'openid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'creid' => '110102199701011000',
'outerid' => 'user123',
'return_appid' => 'wxcbda96de0b165486',
];
$params['sign'] = Hash::sign(
Hash::ALGO_HMAC_SHA256,
Formatter::queryStringLike(
Formatter::ksort($params)
),
$apiv2Key
);
$response = $instance->chain('v2/papay/partner/h5entrustweb')->get([
'query' => $params
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
use WeChatPay\Hash;
use WeChatPay\Formatter;
$params = [
'appid' => 'wxcbda96de0b165486',
'mch_id' => '1200009811',
'sub_appid' => 'wxcbda96de0b165489',
'sub_mch_id' => '1900000109',
'plan_id' => '12535',
'contract_code' => '100000',
'request_serial' => '1000',
'contract_display_account' => '微信代扣',
'notify_url' => 'https://weixin.qq.com',
'version' => '1.0',
'timestamp' => Formatter::timestamp(),
'clientip' => '119.145.83.6',
'deviceid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'mobile' => '18933432355',
'email' => 'aobama@whitehouse.com',
'qq' => '100243',
'openid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'creid' => '110102199701011000',
'outerid' => 'user123',
'return_appid' => 'wxcbda96de0b165486',
];
$params['sign'] = Hash::sign(
Hash::ALGO_HMAC_SHA256,
Formatter::queryStringLike(
Formatter::ksort($params)
),
$apiv2Key
);
$response = $instance['v2/papay/partner/h5entrustweb']->get([
'query' => $params
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
返回字典 | 类型 | 描述 |
---|---|---|
return_code | string | 返回状态码SUCCESS | FAIL 枚举值之一 |
return_msg | string | 返回信息 |
result_code | string | 业务结果SUCCESS | FAIL 枚举值之一 |
result_msg | string | 业务结果描述 |
redirect_url | string | 跳转URL,有效期为10分钟 |
参阅 官方文档