收藏
回答

微信支付商户获取RSA公钥报错SYSTEM_ERR: INNER_ERR?

微信支付商户调这个接口报错,请问是什么原因?

https://fraud.mch.weixin.qq.com/risk/getpublickey

Array

(

    [return_code] => SUCCESS

    [return_msg] => SYSTEM_ERR

    [result_code] => FAIL

    [err_code] => SYSTEM_ERROR

    [err_code_desc] => SYSTEM_ERR: INNER_ERR

)

回答关注问题邀请回答
收藏

1 个回答

  • 北望沣渭
    北望沣渭
    2022-06-28

    composer require wechatpay/wechatpay

    <?php
    require_once('./vendor/autoload.php');
    
    $mchid = '';
    $key = '';
    $apiclient_key = '/path/to/apiclient_key.pem';
    $apiclient_cert = '/path/to/apiclient_cert.pem';
    
    use WeChatPay\Builder;
    use WeChatPay\Transformer;
    
    $instance = Builder::factory([
        'serial'     => 'nop',
        'privateKey' => 'any',
        'certs'      => ['any' => null],
        'mchid'      => $mchid,
        'secret'     => $key,
        'merchant'   => [
            'key' => $apiclient_key,
            'cert' => $apiclient_cert,
        ]
    ]);
    
    $res = $instance->v2->risk->getpublickey->post([
        'xml' => [
            'mch_id' => $mchid,
            'sign_type' => 'MD5',
        ],
        'security' => true,
        'base_uri' => 'https://fraud.mch.weixin.qq.com/',
    ]);
    var_dump(Transformer::toArray((string)$res->getBody()));
    


    array(5) {
      ["return_code"]=>
      string(7) "SUCCESS"
      ["return_msg"]=>
      string(2) "OK"
      ["result_code"]=>
      string(7) "SUCCESS"
      ["mch_id"]=>
      string(10) ""
      ["pub_key"]=>
      string(426) "-----BEGIN RSA PUBLIC KEY-----
    MIIBCgKCAQEA43u03cMF3QEgWDOy2nhUCEu0QxUzNRVgQfghRSmweBSeuufh6keu
    Qca30T+RwsiUU5tafKZFgeaUbOiQTvtBvt49pYUZKoWufl/RBqWkLtf0eOeaAzRF
    cAbGPm+ZM8tHhsFBAnrKASe72gZEUGodMsS7jRG9lGQMFPoksUwLVcnXYmHkOQrm
    KvF8AwkBgdVaMgyYShMys+sLjfrtcMc+SnnTt7T7aJBjsyhoRWvyF3OL+rMwwPfN
    4+ugAOopBuGMCwPz2GRXLzzxoJqIhAlO/WxqlII95i0wrI9QL224HbW1C0RWrvGe
    Ugr8GSWz3ywXPWUf3VIDGLwXZE8gN6liDwIDAQAB
    -----END RSA PUBLIC KEY-----
    "
    }
    
    2022-06-28
    有用
    回复
登录 后发表内容