我尝试付款到客户帐户时收到错误

时间:2016-09-11 00:24:30

标签: javascript stripe-payments stripe-connect

尝试使用托管帐户进行付款。基本上,用户需要付费,并且钱将被发送到管理帐户而不是平台帐户。我正在使用“分享客户”我正在使用此链接https://stripe.com/docs/connect/shared-customers底部的代码。检索令牌后,我尝试一次充电,我收到一条错误,上面写着“卡片信息未找到”,但我在创建令牌时传递了cardId

错误:message: "Could not find payment information"

Stripe.tokens.create(
 { customer: request.params.customerId, card: request.params.cardId },
 { stripe_account: 'acct_xyz' }, // id of the connected account
  function(err, token) {

  Stripe.charges.create(
 {
amount: 1000, // amount in cents
currency: "usd",
source: token,
description: "Example charge",
application_fee: 123 // amount in cents
},
function(err, charge) {
console.log(err);
 });
});

1 个答案:

答案 0 :(得分:5)

这对你有用吗?这里的主要区别是

  1. 我在{ stripe_account: 'acct_xyz' }请求中包含stripe.charges.create,如果使用共享客户,则需要在连接的帐户上进行此操作。 https://stripe.com/docs/connect/payments-fees#charging-directly

  2. 而不是token作为source我只使用令牌对象的id属性(例如tok_xxxyyyzzz)。

  3. 样品:

    // id of connected account you want to create customer on, charge
    var connectedAccountId = "acct_16MNx0I5dd9AuSl3";
    
    // id of customer and card you want to create a token from
    
    var platformCustomerId = "cus_8vEdBa4rQTGond";
    var platformCustomerCardId = "card_18dOAcFwTuOiiF4uwtDe2Nip";
    
    var stripe = require("stripe")(
      "sk_test_xxxyyyyzzz"
    );
    
        // create a token using a customer and card on the Platform account
        stripe.tokens.create(
          {customer: platformCustomerId, card: platformCustomerCardId },
          {stripe_account: connectedAccountId},
          function(err, token) {
            if (err)
              throw (err);
    
                stripe.charges.create({
                  amount: 4444,
                  currency: "usd",
                  source: token.id,
                  description: "Charge on a connected account",
                  application_fee: 1111
                },
                {stripe_account: connectedAccountId},
                function(err, charge) {
                  if (err)
                    throw (err);
                  console.log(charge);
                });
            });
    

    或者,如您所说,您正在使用托管帐户,您可能需要考虑通过平台收费,这样您就可以完全避免共享客户流,请参阅此处获取示例https://stripe.com/docs/connect/payments-fees#charging-through-the-platform