收藏
回答

微信支付财付通合单支付,多个子单如何拼写参数?

array(7) {
  ["combine_appid"]=>
  string(18) "wx948d4e11762e6bac"
  ["combine_mchid"]=>
  string(10) "1606143582"
  ["combine_out_trade_no"]=>
  string(23) "810688748219833539-mini"
  ["time_expire"]=>
  string(25) "2021-10-28T16:14:00+08:00"
  ["notify_url"]=>
  string(80) "https://mlsldshop.codechain.shop/cmobile/api/payment/xcx_jsapi_v3/notify_url.php"
  ["sub_orders"]=>
  array(2) {
    [0]=>
    array(7) {
      ["mchid"]=>
      string(10) "1606143582"
      ["attach"]=>
      string(23) "product_buy-wxpay_jsapi"
      ["out_trade_no"]=>
      string(23) "810688748219833539-mini"
      ["sub_mchid"]=>
      string(10) "1606794343"
      ["description"]=>
      string(31) "实物订单_810688748219833539"
      ["amount"]=>
      array(2) {
        ["total_amount"]=>
        int(1)
        ["currency"]=>
        string(3) "CNY"
      }
      ["settle_info"]=>
      array(2) {
        ["profit_sharing"]=>
        bool(true)
        ["subsidy_amount"]=>
        int(0)
      }
    }
    [1]=>
    array(7) {
      ["mchid"]=>
      string(10) "1606143582"
      ["attach"]=>
      string(23) "product_buy-wxpay_jsapi"
      ["out_trade_no"]=>
      string(23) "810688748219833539-mini"
      ["sub_mchid"]=>
      string(10) "1606995864"
      ["description"]=>
      string(31) "实物订单_810688748219833539"
      ["amount"]=>
      array(2) {
        ["total_amount"]=>
        int(1)
        ["currency"]=>
        string(3) "CNY"
      }
      ["settle_info"]=>
      array(2) {
        ["profit_sharing"]=>
        bool(true)
        ["subsidy_amount"]=>
        int(0)
      }
    }
  }
  ["combine_payer_info"]=>
  array(1) {
    ["openid"]=>
    string(28) "o4baQ0njOxeXDO4yZ0fPXH3lgkuc"
  }
}
w我是这样拼的,报错Client error: `POST https://api.mch.weixin.qq.com/v3/combine-transactions/jsapi` resulted in a `400 Bad Request` response
回答关注问题邀请回答
收藏

1 个回答

  • 北望沣渭
    北望沣渭
    2021-10-28
    <?php
    interface Native
    {
        /**
         * 合单下单-Native支付(同步模式)
         * @param array<string,mixed> $options
         * @link https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/combine/chapter3_10.shtml
         */
        public function post(array $options = [
            'json' => [
                'combine_appid' => 'wxd678efh567hg6787',
                'combine_mchid' => '1900000109',
                'combine_out_trade_no' => 'P20150806125346',
                'scene_info' => [
                    'device_id' => 'POS1:1',
                    'payer_client_ip' => '14.17.22.32',
                ],
                'sub_orders' => [[
                    'mchid' => '1900000109',
                    'attach' => '深圳分店',
                    'amount' => [
                        'total_amount' => 100,
                        'currency' => 'CNY',
                    ],
                    'out_trade_no' => '20150806125346',
                    'sub_mchid' => '1900000109',
                    'goods_tag' => 'WXG',
                    'description' => '腾讯充值中心-QQ会员充值',
                    'settle_info' => [
                        'profit_sharing' => true,
                        'subsidy_amount' => 10,
                    ],
                ],],
                'time_start' => '2019-12-31T15:59:60+08:00',
                'time_expire' => '2019-12-31T15:59:60+08:00',
                'notify_url' => 'https://yourapp.com/notify',
            ],
        ]): ResponseInterface;
    
        /**
         * 合单下单-Native支付(异步模式)
         * @param array<string,mixed> $options
         * @link https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/combine/chapter3_10.shtml#async
         */
        public function postAsync(array $options = [
            'json' => [
                'combine_appid' => 'wxd678efh567hg6787',
                'combine_mchid' => '1900000109',
                'combine_out_trade_no' => 'P20150806125346',
                'scene_info' => [
                    'device_id' => 'POS1:1',
                    'payer_client_ip' => '14.17.22.32',
                ],
                'sub_orders' => [[
                    'mchid' => '1900000109',
                    'attach' => '深圳分店',
                    'amount' => [
                        'total_amount' => 100,
                        'currency' => 'CNY',
                    ],
                    'out_trade_no' => '20150806125346',
                    'sub_mchid' => '1900000109',
                    'goods_tag' => 'WXG',
                    'description' => '腾讯充值中心-QQ会员充值',
                    'settle_info' => [
                        'profit_sharing' => true,
                        'subsidy_amount' => 10,
                    ],
                ],],
                'time_start' => '2019-12-31T15:59:60+08:00',
                'time_expire' => '2019-12-31T15:59:60+08:00',
                'notify_url' => 'https://yourapp.com/notify',
            ],
        ]): PromiseInterface;
    }
    
    


    以函数默认值的形式,说明参数数据格式如上,composer require iwechatpay/openapi 可能适合你。

    为 wechatpay-php 增加IDE提示的接口描述包 iwechatpay/openapi 介绍wechapay-php 开发包的辅助包

    2021-10-28
    有用 1
    回复 7
    • 沉梦昂志
      沉梦昂志
      2021-10-28
      多个子单怎么拼写参数呢?
      2021-10-28
      回复
    • 北望沣渭
      北望沣渭
      2021-10-28回复沉梦昂志
      2021-10-28
      回复
    • 沉梦昂志
      沉梦昂志
      2021-10-29回复北望沣渭
      2021-10-29
      回复
    • 沉梦昂志
      沉梦昂志
      2021-10-29回复北望沣渭
      之前也一直报这个错误,找不到原因,请问您知道吗?
      2021-10-29
      回复
    • 北望沣渭
      北望沣渭
      2021-10-29回复沉梦昂志
      按照官方文档说明,子单是需要按照「商户/子商户」做商品信息合并,你这个400错误应该就是这个的原因,你的子单没有做合并
      2021-10-29
      回复
    查看更多(2)
登录 后发表内容