【问题标题】:Firebase Functions Error for Stripe Create Ephemeral KeyStripe 创建临时密钥的 Firebase 函数错误
【发布时间】:2023-01-14 21:16:01
【问题描述】:

我正在尝试使用 firebase-functions 通过教程创建 Stripe 临时密钥。这是执行此操作的 node.js 代码:

  exports.createEphemeralKey = functions.https.onCall(async (data, context) => {
 
    const customerId = data.customer_id;
    const stripeVersion = data.stripe_version;
    const uid = context.auth.uid;
   
    if (uid === null) {
        console.log('Illegal access attempt due to unauthenticated attempt.')
        throw new functions.https.HttpsError('internal', 'Illegal access attempt');
    }
   
    return stripe.ephemeralKeys.create(
      { customer: customerId },
      { stripe_version: stripeVersion }
    ).then((key) => {
      return key
    }).catch( (err) => {
      functions.logger.log('Error creating ephemeral key', err)
      throw new functions.https.HttpsError('internal', 'Unable to create ephemeral key: ' + err)
    });
  });

运行后,Xcode 立即显示以下错误代码:

Error Domain=com.firebase.functions Code=13 "INTERNAL" UserInfo={NSLocalizedDescription=INTERNAL}

当我单击“管理我的信用卡”(触发 Stripe 付款表)时,Stripe 付款表从不加载,只显示“正在加载...”

我的预感是我的 Swift 代码没问题,这只是 node.js createEphemeralKey 函数的问题。我认为 customerID 很好,因为我可以在 Xcode 中使用打印功能生成它。这可能是 stripeVersion 的问题吗?或者是其他东西?

【问题讨论】:

  • 您的 Stripe Dashboard 日志中是否有创建临时密钥的成功日志?您检查过 Firebase 函数的日志了吗?
  • 没有成功的日志。每条内容如下:Error creating ephemeral key Error: Stripe: Unknown arguments ([object Object]). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options. (on API request to POST /v1/ephemeral_keys) 有什么想法吗?谢谢。
  • stripe_version 参数应该是驼峰式 (stripeVersion)。此外,该错误表明您正在将对象作为参数传递。 customerIdstripeVersion 参数的值是多少?
  • 我进行了以下更改:const customerId = data.customerId & const stripeVersion = data.stripeVersion & {customer: customerId}, { stripeVersion: stripeVersion}(因此是骆驼式而不是蛇式)。和以前一样的错误。 customerId 返回用户的 Stripe ID,stripeVersion 显示为 2020-08-27 key 值打印为未定义,但这可能是预期的。

标签: swift xcode firebase google-cloud-functions stripe-payments


【解决方案1】:

here 如果创建了临时密钥,您将找到如何检查 Firebase 日志

【讨论】:

    猜你喜欢
    • 2018-07-12
    • 2021-06-15
    • 1970-01-01
    • 2020-08-08
    • 2018-11-26
    • 2013-06-14
    • 2021-01-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多