支付中签约
支付的同时完成代扣协议的签约。用户完成支付,微信通过支付中签约接口中商户上传的通知回调地址(对应参数:notify_url),将支付结果返回给商户,同时将签约结果通过contract_notify_url通知给商户,两次通知皆为异步通知。
| 请求参数 | 类型 | 描述 |
|---|---|---|
| xml | object | 声明请求的XML数据结构 |
| appid | string | 请求appid |
| mch_id | string | 商户号 |
| contract_mchid | string | 签约商户号 |
| contract_appid | string | 签约appid |
| out_trade_no | string | 商户订单号 |
| device_info | string | 设备号 |
| body | string | 商品描述 |
| detail | string | 商品详情 |
| attach | string | 附加数据 |
| notify_url | string | 回调通知url |
| total_fee | integer | 总金额 |
| spbill_create_ip | string | 终端IP |
| time_start | string | 交易起始时间 |
| time_expire | string | 交易结束时间 |
| goods_tag | string | 商品标记 |
| trade_type | string | 交易类型JSAPI | NATIVE | APP | MWEB 枚举值之一 |
| product_id | string | 商品ID |
| limit_pay | string | 指定支付方式 |
| openid | string | 用户标识 |
| plan_id | integer | 模板id |
| contract_code | string | 签约协议号 |
| request_serial | integer | 请求序列号 |
| contract_display_account | string | 用户账户展示名称 |
| contract_notify_url | string | 签约信息通知url |
php
$instance->v2->pay->contractorder->postAsync([
'xml' => [
'appid' => 'wxcbda96de0b165486',
'mch_id' => '1200009811',
'contract_mchid' => '1200009811',
'contract_appid' => 'wxcbda96de0b165486',
'out_trade_no' => '123456',
'device_info' => '013467007045764',
'body' => 'Ipadmini16G白色',
'detail' => 'Ipadmini16G白色',
'attach' => '深圳分店',
'notify_url' => 'http://yoursite.com',
'total_fee' => '888',
'spbill_create_ip' => '123.12.12.123',
'time_start' => '20091225091010',
'time_expire' => '20091227091010',
'goods_tag' => 'WXG',
'trade_type' => 'JSAPI',
'product_id' => '12235413214070356458058',
'limit_pay' => 'no_credit',
'openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
'plan_id' => '123',
'contract_code' => '100001256',
'request_serial' => '1695',
'contract_display_account' => '123',
'contract_notify_url' => 'http://yoursite.com',
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();php
$instance->chain('v2/pay/contractorder')->postAsync([
'xml' => [
'appid' => 'wxcbda96de0b165486',
'mch_id' => '1200009811',
'contract_mchid' => '1200009811',
'contract_appid' => 'wxcbda96de0b165486',
'out_trade_no' => '123456',
'device_info' => '013467007045764',
'body' => 'Ipadmini16G白色',
'detail' => 'Ipadmini16G白色',
'attach' => '深圳分店',
'notify_url' => 'http://yoursite.com',
'total_fee' => '888',
'spbill_create_ip' => '123.12.12.123',
'time_start' => '20091225091010',
'time_expire' => '20091227091010',
'goods_tag' => 'WXG',
'trade_type' => 'JSAPI',
'product_id' => '12235413214070356458058',
'limit_pay' => 'no_credit',
'openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
'plan_id' => '123',
'contract_code' => '100001256',
'request_serial' => '1695',
'contract_display_account' => '123',
'contract_notify_url' => 'http://yoursite.com',
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();php
$instance['v2/pay/contractorder']->postAsync([
'xml' => [
'appid' => 'wxcbda96de0b165486',
'mch_id' => '1200009811',
'contract_mchid' => '1200009811',
'contract_appid' => 'wxcbda96de0b165486',
'out_trade_no' => '123456',
'device_info' => '013467007045764',
'body' => 'Ipadmini16G白色',
'detail' => 'Ipadmini16G白色',
'attach' => '深圳分店',
'notify_url' => 'http://yoursite.com',
'total_fee' => '888',
'spbill_create_ip' => '123.12.12.123',
'time_start' => '20091225091010',
'time_expire' => '20091227091010',
'goods_tag' => 'WXG',
'trade_type' => 'JSAPI',
'product_id' => '12235413214070356458058',
'limit_pay' => 'no_credit',
'openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
'plan_id' => '123',
'contract_code' => '100001256',
'request_serial' => '1695',
'contract_display_account' => '123',
'contract_notify_url' => 'http://yoursite.com',
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();php
$response = $instance->v2->pay->contractorder->post([
'xml' => [
'appid' => 'wxcbda96de0b165486',
'mch_id' => '1200009811',
'contract_mchid' => '1200009811',
'contract_appid' => 'wxcbda96de0b165486',
'out_trade_no' => '123456',
'device_info' => '013467007045764',
'body' => 'Ipadmini16G白色',
'detail' => 'Ipadmini16G白色',
'attach' => '深圳分店',
'notify_url' => 'http://yoursite.com',
'total_fee' => '888',
'spbill_create_ip' => '123.12.12.123',
'time_start' => '20091225091010',
'time_expire' => '20091227091010',
'goods_tag' => 'WXG',
'trade_type' => 'JSAPI',
'product_id' => '12235413214070356458058',
'limit_pay' => 'no_credit',
'openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
'plan_id' => '123',
'contract_code' => '100001256',
'request_serial' => '1695',
'contract_display_account' => '123',
'contract_notify_url' => 'http://yoursite.com',
],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));php
$response = $instance->chain('v2/pay/contractorder')->post([
'xml' => [
'appid' => 'wxcbda96de0b165486',
'mch_id' => '1200009811',
'contract_mchid' => '1200009811',
'contract_appid' => 'wxcbda96de0b165486',
'out_trade_no' => '123456',
'device_info' => '013467007045764',
'body' => 'Ipadmini16G白色',
'detail' => 'Ipadmini16G白色',
'attach' => '深圳分店',
'notify_url' => 'http://yoursite.com',
'total_fee' => '888',
'spbill_create_ip' => '123.12.12.123',
'time_start' => '20091225091010',
'time_expire' => '20091227091010',
'goods_tag' => 'WXG',
'trade_type' => 'JSAPI',
'product_id' => '12235413214070356458058',
'limit_pay' => 'no_credit',
'openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
'plan_id' => '123',
'contract_code' => '100001256',
'request_serial' => '1695',
'contract_display_account' => '123',
'contract_notify_url' => 'http://yoursite.com',
],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));php
$response = $instance['v2/pay/contractorder']->post([
'xml' => [
'appid' => 'wxcbda96de0b165486',
'mch_id' => '1200009811',
'contract_mchid' => '1200009811',
'contract_appid' => 'wxcbda96de0b165486',
'out_trade_no' => '123456',
'device_info' => '013467007045764',
'body' => 'Ipadmini16G白色',
'detail' => 'Ipadmini16G白色',
'attach' => '深圳分店',
'notify_url' => 'http://yoursite.com',
'total_fee' => '888',
'spbill_create_ip' => '123.12.12.123',
'time_start' => '20091225091010',
'time_expire' => '20091227091010',
'goods_tag' => 'WXG',
'trade_type' => 'JSAPI',
'product_id' => '12235413214070356458058',
'limit_pay' => 'no_credit',
'openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
'plan_id' => '123',
'contract_code' => '100001256',
'request_serial' => '1695',
'contract_display_account' => '123',
'contract_notify_url' => 'http://yoursite.com',
],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));| 返回字典 | 类型 | 描述 |
|---|---|---|
| return_code | string | 返回状态码SUCCESS | FAIL 枚举值之一 |
| return_msg | string | 返回信息 |
| result_code | string | 业务结果SUCCESS | FAIL 枚举值之一 |
| appid | string | 公众账号id |
| mch_id | string | 商户号 |
| nonce_str | string | 随机字符串 |
| sign | string | 签名 |
| err_code | string | 错误代码 |
| err_code_des | string | 错误代码描述 |
| contract_result_code | string | 预签约结果 |
| contract_err_code | string | 预签约错误代码 |
| contract_err_code_des | string | 预签约错误描述 |
| prepay_id | string | 预支付交易会话标识 |
| trade_type | string | 交易类型 |
| code_url | string | 二维码链接 |
| plan_id | integer | 模板id |
| request_serial | string | 请求序列号 |
| contract_code | string | 签约协议号 |
| contract_display_account | string | 用户账户展示名称 |
| mweb_url | string | 支付跳转链接 |
| out_trade_no | string | 商户订单号 |
参阅 官方文档