Skip to content

H5下单

H5支付是指商户在微信客户端外的移动端网页展示商品或服务,用户在前述页面确认使用微信支付时,商户发起本服务呼起微信客户端进行支付。主要用于触屏版的手机浏览器请求微信支付的场景,可以方便的从外部浏览器唤起微信支付。

请求参数类型描述
jsonobject声明请求的JSON数据结构
sp_appidstring服务商公众号ID
sp_mchidstring服务商户号
sub_appidstring子商户公众号ID
sub_mchidstring子商户号
settle_infoobject结算信息
profit_sharingboolean是否指定分账
subsidy_amountinteger补差金额
descriptionstring商品描述
attachstring附加数据
out_trade_nostring商户订单号
amountobject订单金额
totalinteger总金额
currencystring货币类型
time_expirestring交易结束时间
notify_urlstring通知地址
goods_tagstring订单优惠标记
limit_paystring[]支付方式
no_balance | no_credit | no_debit | balance_only 枚举值之一
support_fapiaoboolean电子发票入口开放标识
detailobject优惠功能
cost_priceinteger订单原价
invoice_idstring商品小票ID
goods_detailobject[]单品列表
merchant_goods_idstring商户侧商品编码
wechatpay_goods_idstring微信侧商品编码
goods_namestring商品名称
quantityinteger商品数量
unit_priceinteger商品单价
scene_infoobject场景信息
payer_client_ipstring用户终端IP
device_idstring商户端设备号
store_infoobject商户门店信息
idstring门店编号
namestring门店名称
area_codestring地区编码
addressstring详细地址
h5_infoobjectH5场景信息
typestring场景类型
app_namestring应用名称
app_urlstring网站URL
bundle_idstringiOS平台BundleID
package_namestringAndroid平台PackageName
php
$instance->v3->pay->partner->transactions->h5->postAsync([
  'json' => [
    'sp_appid' => 'wx8888888888888888',
    'sp_mchid' => '1230000109',
    'sub_appid' => 'wxd678efh567hg6999',
    'sub_mchid' => '1900000109',
    'settle_info' => [
      'profit_sharing' => true,
      'subsidy_amount' => 10,
    ],
    'description' => 'Image形象店-深圳腾大-QQ公仔',
    'attach' => '自定义数据',
    'out_trade_no' => '1217752501201407033233368018',
    'amount' => [
      'total' => 100,
      'currency' => 'CNY',
    ],
    'time_expire' => '2018-06-08T10:34:56+08:00',
    'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
    'goods_tag' => 'WXG',
    'limit_pay' => ['string'],
    'support_fapiao' => true,
    'detail' => [
      'cost_price' => 608800,
      'invoice_id' => '微信123',
      'goods_detail' => [[
        'merchant_goods_id' => '商品编码',
        'wechatpay_goods_id' => '1001',
        'goods_name' => 'iPhoneX 256G',
        'quantity' => 1,
        'unit_price' => 828800,
      ],],
    ],
    'scene_info' => [
      'payer_client_ip' => '14.23.150.211',
      'device_id' => '013467007045764',
      'store_info' => [
        'id' => '0001',
        'name' => '腾讯大厦分店',
        'area_code' => '440305',
        'address' => '广东省深圳市南山区科技中一道10000号',
      ],
      'h5_info' => [
        'type' => 'iOSAndroidWap',
        'app_name' => '王者荣耀',
        'app_url' => 'https://pay.qq.com',
        'bundle_id' => 'com.tencent.wzryiOS',
        'package_name' => 'com.tencent.tmgp.sgame',
      ],
    ],
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/pay/partner/transactions/h5')->postAsync([
  'json' => [
    'sp_appid' => 'wx8888888888888888',
    'sp_mchid' => '1230000109',
    'sub_appid' => 'wxd678efh567hg6999',
    'sub_mchid' => '1900000109',
    'settle_info' => [
      'profit_sharing' => true,
      'subsidy_amount' => 10,
    ],
    'description' => 'Image形象店-深圳腾大-QQ公仔',
    'attach' => '自定义数据',
    'out_trade_no' => '1217752501201407033233368018',
    'amount' => [
      'total' => 100,
      'currency' => 'CNY',
    ],
    'time_expire' => '2018-06-08T10:34:56+08:00',
    'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
    'goods_tag' => 'WXG',
    'limit_pay' => ['string'],
    'support_fapiao' => true,
    'detail' => [
      'cost_price' => 608800,
      'invoice_id' => '微信123',
      'goods_detail' => [[
        'merchant_goods_id' => '商品编码',
        'wechatpay_goods_id' => '1001',
        'goods_name' => 'iPhoneX 256G',
        'quantity' => 1,
        'unit_price' => 828800,
      ],],
    ],
    'scene_info' => [
      'payer_client_ip' => '14.23.150.211',
      'device_id' => '013467007045764',
      'store_info' => [
        'id' => '0001',
        'name' => '腾讯大厦分店',
        'area_code' => '440305',
        'address' => '广东省深圳市南山区科技中一道10000号',
      ],
      'h5_info' => [
        'type' => 'iOSAndroidWap',
        'app_name' => '王者荣耀',
        'app_url' => 'https://pay.qq.com',
        'bundle_id' => 'com.tencent.wzryiOS',
        'package_name' => 'com.tencent.tmgp.sgame',
      ],
    ],
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/pay/partner/transactions/h5']->postAsync([
  'json' => [
    'sp_appid' => 'wx8888888888888888',
    'sp_mchid' => '1230000109',
    'sub_appid' => 'wxd678efh567hg6999',
    'sub_mchid' => '1900000109',
    'settle_info' => [
      'profit_sharing' => true,
      'subsidy_amount' => 10,
    ],
    'description' => 'Image形象店-深圳腾大-QQ公仔',
    'attach' => '自定义数据',
    'out_trade_no' => '1217752501201407033233368018',
    'amount' => [
      'total' => 100,
      'currency' => 'CNY',
    ],
    'time_expire' => '2018-06-08T10:34:56+08:00',
    'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
    'goods_tag' => 'WXG',
    'limit_pay' => ['string'],
    'support_fapiao' => true,
    'detail' => [
      'cost_price' => 608800,
      'invoice_id' => '微信123',
      'goods_detail' => [[
        'merchant_goods_id' => '商品编码',
        'wechatpay_goods_id' => '1001',
        'goods_name' => 'iPhoneX 256G',
        'quantity' => 1,
        'unit_price' => 828800,
      ],],
    ],
    'scene_info' => [
      'payer_client_ip' => '14.23.150.211',
      'device_id' => '013467007045764',
      'store_info' => [
        'id' => '0001',
        'name' => '腾讯大厦分店',
        'area_code' => '440305',
        'address' => '广东省深圳市南山区科技中一道10000号',
      ],
      'h5_info' => [
        'type' => 'iOSAndroidWap',
        'app_name' => '王者荣耀',
        'app_url' => 'https://pay.qq.com',
        'bundle_id' => 'com.tencent.wzryiOS',
        'package_name' => 'com.tencent.tmgp.sgame',
      ],
    ],
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->pay->partner->transactions->h5->post([
  'json' => [
    'sp_appid' => 'wx8888888888888888',
    'sp_mchid' => '1230000109',
    'sub_appid' => 'wxd678efh567hg6999',
    'sub_mchid' => '1900000109',
    'settle_info' => [
      'profit_sharing' => true,
      'subsidy_amount' => 10,
    ],
    'description' => 'Image形象店-深圳腾大-QQ公仔',
    'attach' => '自定义数据',
    'out_trade_no' => '1217752501201407033233368018',
    'amount' => [
      'total' => 100,
      'currency' => 'CNY',
    ],
    'time_expire' => '2018-06-08T10:34:56+08:00',
    'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
    'goods_tag' => 'WXG',
    'limit_pay' => ['string'],
    'support_fapiao' => true,
    'detail' => [
      'cost_price' => 608800,
      'invoice_id' => '微信123',
      'goods_detail' => [[
        'merchant_goods_id' => '商品编码',
        'wechatpay_goods_id' => '1001',
        'goods_name' => 'iPhoneX 256G',
        'quantity' => 1,
        'unit_price' => 828800,
      ],],
    ],
    'scene_info' => [
      'payer_client_ip' => '14.23.150.211',
      'device_id' => '013467007045764',
      'store_info' => [
        'id' => '0001',
        'name' => '腾讯大厦分店',
        'area_code' => '440305',
        'address' => '广东省深圳市南山区科技中一道10000号',
      ],
      'h5_info' => [
        'type' => 'iOSAndroidWap',
        'app_name' => '王者荣耀',
        'app_url' => 'https://pay.qq.com',
        'bundle_id' => 'com.tencent.wzryiOS',
        'package_name' => 'com.tencent.tmgp.sgame',
      ],
    ],
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/pay/partner/transactions/h5')->post([
  'json' => [
    'sp_appid' => 'wx8888888888888888',
    'sp_mchid' => '1230000109',
    'sub_appid' => 'wxd678efh567hg6999',
    'sub_mchid' => '1900000109',
    'settle_info' => [
      'profit_sharing' => true,
      'subsidy_amount' => 10,
    ],
    'description' => 'Image形象店-深圳腾大-QQ公仔',
    'attach' => '自定义数据',
    'out_trade_no' => '1217752501201407033233368018',
    'amount' => [
      'total' => 100,
      'currency' => 'CNY',
    ],
    'time_expire' => '2018-06-08T10:34:56+08:00',
    'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
    'goods_tag' => 'WXG',
    'limit_pay' => ['string'],
    'support_fapiao' => true,
    'detail' => [
      'cost_price' => 608800,
      'invoice_id' => '微信123',
      'goods_detail' => [[
        'merchant_goods_id' => '商品编码',
        'wechatpay_goods_id' => '1001',
        'goods_name' => 'iPhoneX 256G',
        'quantity' => 1,
        'unit_price' => 828800,
      ],],
    ],
    'scene_info' => [
      'payer_client_ip' => '14.23.150.211',
      'device_id' => '013467007045764',
      'store_info' => [
        'id' => '0001',
        'name' => '腾讯大厦分店',
        'area_code' => '440305',
        'address' => '广东省深圳市南山区科技中一道10000号',
      ],
      'h5_info' => [
        'type' => 'iOSAndroidWap',
        'app_name' => '王者荣耀',
        'app_url' => 'https://pay.qq.com',
        'bundle_id' => 'com.tencent.wzryiOS',
        'package_name' => 'com.tencent.tmgp.sgame',
      ],
    ],
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/pay/partner/transactions/h5']->post([
  'json' => [
    'sp_appid' => 'wx8888888888888888',
    'sp_mchid' => '1230000109',
    'sub_appid' => 'wxd678efh567hg6999',
    'sub_mchid' => '1900000109',
    'settle_info' => [
      'profit_sharing' => true,
      'subsidy_amount' => 10,
    ],
    'description' => 'Image形象店-深圳腾大-QQ公仔',
    'attach' => '自定义数据',
    'out_trade_no' => '1217752501201407033233368018',
    'amount' => [
      'total' => 100,
      'currency' => 'CNY',
    ],
    'time_expire' => '2018-06-08T10:34:56+08:00',
    'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
    'goods_tag' => 'WXG',
    'limit_pay' => ['string'],
    'support_fapiao' => true,
    'detail' => [
      'cost_price' => 608800,
      'invoice_id' => '微信123',
      'goods_detail' => [[
        'merchant_goods_id' => '商品编码',
        'wechatpay_goods_id' => '1001',
        'goods_name' => 'iPhoneX 256G',
        'quantity' => 1,
        'unit_price' => 828800,
      ],],
    ],
    'scene_info' => [
      'payer_client_ip' => '14.23.150.211',
      'device_id' => '013467007045764',
      'store_info' => [
        'id' => '0001',
        'name' => '腾讯大厦分店',
        'area_code' => '440305',
        'address' => '广东省深圳市南山区科技中一道10000号',
      ],
      'h5_info' => [
        'type' => 'iOSAndroidWap',
        'app_name' => '王者荣耀',
        'app_url' => 'https://pay.qq.com',
        'bundle_id' => 'com.tencent.wzryiOS',
        'package_name' => 'com.tencent.tmgp.sgame',
      ],
    ],
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
h5_urlstring支付跳转链接

参阅 官方文档

Published on the GitHub by TheNorthMemory