【问题标题】:Firebase function Stripe errorFirebase 功能条带错误
【发布时间】:2018-07-05 00:46:24
【问题描述】:

每次我尝试为我的自定义条带用户创建外部帐户时都会收到此错误消息。

这是我的实际功能:

exports.createExternalAccount =      functions.database.ref('/users/{userId}/sources/{pushId}/token').onWrite(event => {
         const source = event.data.val();
         console.log('SOURCE', source);
        if (source === null) return null;
      return admin.database().ref(`/users/${event.params.userId}/customer_id`).once('value').then(snapshot => {

         return snapshot.val(); 
      }).then(customer => {
          console.log('CREATE EXTERNAL FOR COSTUMER', customer);
          const source = event.data.val();
         return stripe.accounts.createExternalAccount(customer,{ 
             external_account: source
        });
      });
    });

我尝试添加货币,但还是不行:

exports.createExternalAccount =        functions.database.ref('/users/{userId}/sources/{pushId}/token').onWrite(event => {
     const source = event.data.val();
     console.log('SOURCE', source);
    if (source === null) return null;
  return admin.database().ref(`/users/${event.params.userId}/customer_id`).once('value').then(snapshot => {

     return snapshot.val(); 
  }).then(customer => {
      console.log('CREATE EXTERNAL FOR COSTUMER', customer);
      const source = event.data.val();
     return stripe.accounts.createExternalAccount(customer,{ 
         external_account: source, 
         currency: 'usd'
    });
  });
});

有人知道怎么解决吗?

这是我的付款来源功能

exports.addPaymentSource = functions.database.ref('/users/{userId}/sources/{pushId}/token').onWrite(event => {
  const source = event.data.val();
  if (source === null) return null;
  return admin.database().ref(`/users/${event.params.userId}/customer_id`).once('value').then(snapshot => {
    return snapshot.val();
  }).then(customer => {
    return stripe.customers.createSource(customer, {source});
  }).then(response => {
      return event.data.adminRef.parent.set(response);
    }, error => {
      return event.data.adminRef.parent.child('error').set(userFacingMessage(error)).then(() => {
        return reportError(error, {user: event.params.userId});
      });
  });
});

【问题讨论】:

  • 添加货币后,您收到什么错误? @约翰

标签: node.js firebase stripe-payments google-cloud-functions


【解决方案1】:

当您发出Create a Source 请求时,最好是通过ElementsStripe.js/v3,您还应该传递currency-argument

【讨论】:

  • 感谢您的回答!那么我应该在创建外部帐户之前添加付款来源吗?我刚刚在我的问题中添加了我的付款来源功能。
  • 对不起。我想你误解了我的建议。此解决方案不涉及 customer 记录。您只需创建源,就像您已经在做的那样,但是您还可以在该请求中添加一个 currency-argument。
猜你喜欢
  • 2021-05-12
  • 2018-11-17
  • 2020-10-30
  • 2018-07-22
  • 2021-12-01
  • 2018-08-20
  • 2018-05-15
  • 1970-01-01
相关资源
最近更新 更多