收藏
回答

wechatpay-php付款到零钱功能demo返回异常

use WeChatPay\Transformer;

$res = $instance

->v2->mmpaymkttransfers->promotion->transfers

->postAsync([

    'xml' => [

      'mch_appid'        => 'wx8888888888888888',

      'mchid'            => '1900000109',// 注意这个商户号,key是`mchid`非`mch_id`

      'partner_trade_no' => '10000098201411111234567890',

      'openid'           => 'oxTWIuGaIt6gTKsQRLau2M0yL16E',

      'check_name'       => 'FORCE_CHECK',

      're_user_name'     => '王小王',

      'amount'           => '10099',

      'desc'             => '理赔',

      'spbill_create_ip' => '192.168.0.1',

    ],

    'security' => true, //请求需要双向证书

    'debug' => true //开启调试模式

])

->then(static function($response) {

    return Transformer::toArray((string)$response->getBody());

})

->otherwise(static function($e) {

    // 更多`$e`异常类型判断是必须的,这里仅列出一种可能情况,请根据实际对接过程调整并增加

    if ($e instanceof \GuzzleHttp\Promise\RejectionException) {

        return Transformer::toArray((string)$e->getReason()->getBody());

    }

    return [];

})

->wait();

print_r($res);

上面的官方demo运行后可以正常给openid付款,但是返回却是异常信息:The promise was rejected.请问是怎么回事?


最后一次编辑于  2022-05-11
回答关注问题邀请回答
收藏
登录 后发表内容