alipay / alipay-sdk-nodejs-all

支付宝开放平台 Alipay SDK for Node.js
https://docs.open.alipay.com/54/103419/
Other
408 stars 64 forks source link

无法调用alipay.user.certify.open.certify #36

Closed gavin1995 closed 5 years ago

gavin1995 commented 5 years ago

无法调用alipay.user.certify.open.certify接口

nodejs版本:v12.2.0 sdk版本:3.0.7 egg版本:2.15.1

其它接口调用都正常,如:alipay.user.certify.open.initialize

调用alipay.user.certify.open.certify的代码如下

try {
  const res = await this.alipaySdk.exec('alipay.user.certify.open.certify', {
    bizContent: {
      certifyId: '559fdxxxxxx' // initialize接口正常返回生成的
    }
  });
  return res;
} catch (e) {
  console.log(e);
  return false;
}

生成this.alipaySdk关键代码

// 可以确保alipaySdk没有问题,因为调用其它接口都没有问题
this.alipaySdk = new AlipaySdk({
  signType: 'RSA2',
  appId: constants.alipayAppId,
  charset: 'utf-8',
  privateKey: fs.readFileSync(path.resolve(__dirname, '../rsa/rsa_private_key.pem'), 'ascii'),
  alipayPublicKey: `MIIBIjAxxxxxxxxxx`,
});

console.log(e)的打印错误信息如下:

{
  serverResult: {
    data: '',
    status: 302,
    headers: {
      server: 'Tengine/2.1.0',
      date: 'Thu, 04 Jul 2019 13:01:45 GMT',
      'content-length': '0',
      connection: 'keep-alive',
      'set-cookie': [Array],
      location: 'https://custweb.alipay.com/certify/open/personal/dispatch/?alipay_exterface_invoke_assign_target=invoke_efffxxxxxxxxxxxxx&alipay_exterface_invoke_assign_sign=_d_m6xxxxxx_y_cc_t_f_na%2Bdat_p84_ids_txxxxxxxx0ln_a9_ja3pbv3_qn%2Bbhpxxxxxy_x%2B_s_a%3D%3D',
      via: 'spanner-app-ldc-g1-16.gtj[302]'
    },
    res: {
      status: 302,
      statusCode: 302,
      statusMessage: 'Found',
      headers: [Object],
      size: 0,
      aborted: false,
      rt: 769,
      keepAliveSocket: false,
      data: '',
      requestUrls: [Array],
      timing: null,
      remoteAddress: '110.75.244.202',
      remotePort: 443,
      socketHandledRequests: 1,
      socketHandledResponses: 1
    }
  },
  errorMessage: '[AlipaySdk]HTTP 请求错误'
}

已查看文档及与客服沟通,正常应该返回一个跳转链接,不应该错误的302响应。

谢谢!

tudou527 commented 5 years ago

返回值是跳转链接的情况可以参考这个例子:https://www.yuque.com/chenqiu/alipay-node-sdk/page_api#7brFB

paomian commented 5 years ago

可以在后端拿到这个 location 在给用户的移动端浏览器使用么?因为我看到还有 cookies 的信息,不知道这部分信息对这个接口有什么影响?

tudou527 commented 5 years ago

@paomian 可以试试,我并没有把所有的 api 都试过