APP下单并签约
调用该接口在微信支付服务后台生成预支付交易单,返回正确的预支付交易会话标识后再按APP方式调起支付。后续调起支付会引导用户签约。
| 请求参数 | 类型 | 描述 |
|---|---|---|
| json | object | 声明请求的JSON数据结构 |
| appid | string | 公众号ID |
| mchid | string | 直连商户号 |
| description | string | 商品描述 |
| out_trade_no | string | 商户订单号 |
| time_expire | string | 交易结束时间 |
| attach | string | 附加数据 |
| notify_url | string | 通知地址 |
| goods_tag | string | 订单优惠标记 |
| support_fapiao | boolean | 电子发票入口开放标识 |
| amount | object | 订单金额 |
| total | number | 总金额 |
| currency | string | 货币类型 |
| detail | object | 优惠功能 |
| cost_price | number | 订单原价 |
| invoice_id | string | 商品小票ID |
| goods_detail | object[] | 单品列表 |
| merchant_goods_id | string | 商户侧商品编码 |
| wechatpay_goods_id | string | 微信支付商品编码 |
| goods_name | string | 商品名称 |
| quantity | number | 商品数量 |
| unit_price | number | 商品单价 |
| scene_info | object | 场景信息 |
| payer_client_ip | string | 用户终端IP |
| device_id | string | 商户端设备号 |
| store_info | object | 商户门店信息 |
| id | string | 门店编号 |
| name | string | 门店名称 |
| area_code | string | 地区编码 |
| address | string | 详细地址 |
| settle_info | object | 结算信息 |
| profit_sharing | boolean | 是否指定分账 |
| contract_info | object | 签约授权信息 |
| plan_id | string | 模板ID |
| contract_mchid | string | 签约商户号 |
| contract_appid | string | 签约AppID |
| contract_code | string | 签约协议号 |
| request_serial | string | 请求序列号 |
| contract_display_account | string | 用户账户展示名称 |
| contract_notify_url | string | 签约信息通知URL |
php
$instance->v3->pay->transactions->appWithContract->postAsync([
'json' => [
'appid' => 'wxd678efh567hg6787',
'mchid' => '1230000109',
'description' => 'Image形象店-深圳腾大-QQ公仔',
'out_trade_no' => '1217752501201407033233368018',
'time_expire' => '2018-06-08T10:34:56+08:00',
'attach' => '自定义数据说明',
'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
'goods_tag' => 'WXG',
'support_fapiao' => true,
'amount' => [
'total' => 100,
'currency' => 'CNY',
],
'detail' => [
'cost_price' => 608800,
'invoice_id' => '微信123',
'goods_detail' => [[
'merchant_goods_id' => '1246464644',
'wechatpay_goods_id' => '1001',
'goods_name' => 'iPhoneX 256G',
'quantity' => 1,
'unit_price' => 528800,
],],
],
'scene_info' => [
'payer_client_ip' => '14.23.150.211',
'device_id' => '013467007045764',
'store_info' => [
'id' => '0001',
'name' => '腾讯大厦分店',
'area_code' => '440305',
'address' => '广东省深圳市南山区科技中一道10000号',
],
],
'settle_info' => [
'profit_sharing' => true,
],
'contract_info' => [
'plan_id' => '3484306348',
'contract_mchid' => '1200009811',
'contract_appid' => 'wxcbda96de0b165486',
'contract_code' => '100001256',
'request_serial' => '1695',
'contract_display_account' => '123456',
'contract_notify_url' => 'https://yoursite.com',
],
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(json_decode((string) $response->getBody(), true));
})
->wait();php
$instance->chain('v3/pay/transactions/app-with-contract')->postAsync([
'json' => [
'appid' => 'wxd678efh567hg6787',
'mchid' => '1230000109',
'description' => 'Image形象店-深圳腾大-QQ公仔',
'out_trade_no' => '1217752501201407033233368018',
'time_expire' => '2018-06-08T10:34:56+08:00',
'attach' => '自定义数据说明',
'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
'goods_tag' => 'WXG',
'support_fapiao' => true,
'amount' => [
'total' => 100,
'currency' => 'CNY',
],
'detail' => [
'cost_price' => 608800,
'invoice_id' => '微信123',
'goods_detail' => [[
'merchant_goods_id' => '1246464644',
'wechatpay_goods_id' => '1001',
'goods_name' => 'iPhoneX 256G',
'quantity' => 1,
'unit_price' => 528800,
],],
],
'scene_info' => [
'payer_client_ip' => '14.23.150.211',
'device_id' => '013467007045764',
'store_info' => [
'id' => '0001',
'name' => '腾讯大厦分店',
'area_code' => '440305',
'address' => '广东省深圳市南山区科技中一道10000号',
],
],
'settle_info' => [
'profit_sharing' => true,
],
'contract_info' => [
'plan_id' => '3484306348',
'contract_mchid' => '1200009811',
'contract_appid' => 'wxcbda96de0b165486',
'contract_code' => '100001256',
'request_serial' => '1695',
'contract_display_account' => '123456',
'contract_notify_url' => 'https://yoursite.com',
],
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(json_decode((string) $response->getBody(), true));
})
->wait();php
$instance['v3/pay/transactions/app-with-contract']->postAsync([
'json' => [
'appid' => 'wxd678efh567hg6787',
'mchid' => '1230000109',
'description' => 'Image形象店-深圳腾大-QQ公仔',
'out_trade_no' => '1217752501201407033233368018',
'time_expire' => '2018-06-08T10:34:56+08:00',
'attach' => '自定义数据说明',
'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
'goods_tag' => 'WXG',
'support_fapiao' => true,
'amount' => [
'total' => 100,
'currency' => 'CNY',
],
'detail' => [
'cost_price' => 608800,
'invoice_id' => '微信123',
'goods_detail' => [[
'merchant_goods_id' => '1246464644',
'wechatpay_goods_id' => '1001',
'goods_name' => 'iPhoneX 256G',
'quantity' => 1,
'unit_price' => 528800,
],],
],
'scene_info' => [
'payer_client_ip' => '14.23.150.211',
'device_id' => '013467007045764',
'store_info' => [
'id' => '0001',
'name' => '腾讯大厦分店',
'area_code' => '440305',
'address' => '广东省深圳市南山区科技中一道10000号',
],
],
'settle_info' => [
'profit_sharing' => true,
],
'contract_info' => [
'plan_id' => '3484306348',
'contract_mchid' => '1200009811',
'contract_appid' => 'wxcbda96de0b165486',
'contract_code' => '100001256',
'request_serial' => '1695',
'contract_display_account' => '123456',
'contract_notify_url' => 'https://yoursite.com',
],
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(json_decode((string) $response->getBody(), true));
})
->wait();php
$response = $instance->v3->pay->transactions->appWithContract->post([
'json' => [
'appid' => 'wxd678efh567hg6787',
'mchid' => '1230000109',
'description' => 'Image形象店-深圳腾大-QQ公仔',
'out_trade_no' => '1217752501201407033233368018',
'time_expire' => '2018-06-08T10:34:56+08:00',
'attach' => '自定义数据说明',
'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
'goods_tag' => 'WXG',
'support_fapiao' => true,
'amount' => [
'total' => 100,
'currency' => 'CNY',
],
'detail' => [
'cost_price' => 608800,
'invoice_id' => '微信123',
'goods_detail' => [[
'merchant_goods_id' => '1246464644',
'wechatpay_goods_id' => '1001',
'goods_name' => 'iPhoneX 256G',
'quantity' => 1,
'unit_price' => 528800,
],],
],
'scene_info' => [
'payer_client_ip' => '14.23.150.211',
'device_id' => '013467007045764',
'store_info' => [
'id' => '0001',
'name' => '腾讯大厦分店',
'area_code' => '440305',
'address' => '广东省深圳市南山区科技中一道10000号',
],
],
'settle_info' => [
'profit_sharing' => true,
],
'contract_info' => [
'plan_id' => '3484306348',
'contract_mchid' => '1200009811',
'contract_appid' => 'wxcbda96de0b165486',
'contract_code' => '100001256',
'request_serial' => '1695',
'contract_display_account' => '123456',
'contract_notify_url' => 'https://yoursite.com',
],
],
]);
print_r(json_decode((string) $response->getBody(), true));php
$response = $instance->chain('v3/pay/transactions/app-with-contract')->post([
'json' => [
'appid' => 'wxd678efh567hg6787',
'mchid' => '1230000109',
'description' => 'Image形象店-深圳腾大-QQ公仔',
'out_trade_no' => '1217752501201407033233368018',
'time_expire' => '2018-06-08T10:34:56+08:00',
'attach' => '自定义数据说明',
'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
'goods_tag' => 'WXG',
'support_fapiao' => true,
'amount' => [
'total' => 100,
'currency' => 'CNY',
],
'detail' => [
'cost_price' => 608800,
'invoice_id' => '微信123',
'goods_detail' => [[
'merchant_goods_id' => '1246464644',
'wechatpay_goods_id' => '1001',
'goods_name' => 'iPhoneX 256G',
'quantity' => 1,
'unit_price' => 528800,
],],
],
'scene_info' => [
'payer_client_ip' => '14.23.150.211',
'device_id' => '013467007045764',
'store_info' => [
'id' => '0001',
'name' => '腾讯大厦分店',
'area_code' => '440305',
'address' => '广东省深圳市南山区科技中一道10000号',
],
],
'settle_info' => [
'profit_sharing' => true,
],
'contract_info' => [
'plan_id' => '3484306348',
'contract_mchid' => '1200009811',
'contract_appid' => 'wxcbda96de0b165486',
'contract_code' => '100001256',
'request_serial' => '1695',
'contract_display_account' => '123456',
'contract_notify_url' => 'https://yoursite.com',
],
],
]);
print_r(json_decode((string) $response->getBody(), true));php
$response = $instance['v3/pay/transactions/app-with-contract']->post([
'json' => [
'appid' => 'wxd678efh567hg6787',
'mchid' => '1230000109',
'description' => 'Image形象店-深圳腾大-QQ公仔',
'out_trade_no' => '1217752501201407033233368018',
'time_expire' => '2018-06-08T10:34:56+08:00',
'attach' => '自定义数据说明',
'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
'goods_tag' => 'WXG',
'support_fapiao' => true,
'amount' => [
'total' => 100,
'currency' => 'CNY',
],
'detail' => [
'cost_price' => 608800,
'invoice_id' => '微信123',
'goods_detail' => [[
'merchant_goods_id' => '1246464644',
'wechatpay_goods_id' => '1001',
'goods_name' => 'iPhoneX 256G',
'quantity' => 1,
'unit_price' => 528800,
],],
],
'scene_info' => [
'payer_client_ip' => '14.23.150.211',
'device_id' => '013467007045764',
'store_info' => [
'id' => '0001',
'name' => '腾讯大厦分店',
'area_code' => '440305',
'address' => '广东省深圳市南山区科技中一道10000号',
],
],
'settle_info' => [
'profit_sharing' => true,
],
'contract_info' => [
'plan_id' => '3484306348',
'contract_mchid' => '1200009811',
'contract_appid' => 'wxcbda96de0b165486',
'contract_code' => '100001256',
'request_serial' => '1695',
'contract_display_account' => '123456',
'contract_notify_url' => 'https://yoursite.com',
],
],
]);
print_r(json_decode((string) $response->getBody(), true));| 返回字典 | 类型 | 描述 |
|---|---|---|
| prepay_id | string | 预支付交易会话标识 |
参阅 官方文档