Stripe 代币直接收费,但不能通过平台收费
Stripe token works on direct charge but not through the platform
这是一个我无法弄清楚的 Stripe 特定问题。
最初我的条纹连接设置是直接收费的,这意味着平台会削减它,但费用会直接转到接收者。我们的问题是 stripe 从用户那里收取费用,而我们希望它从我们这边收取费用。
因此我们需要通过平台进行收费。
现在,当我使用直接充电测试我的代码时,它可以正常工作,但是当我将其更改为通过平台时,它说:
No such token: tok_16lFgxDVBtbPPV
这是我的直接收费代码(有效):
token = Stripe::Token.create( { customer: customer.stripe_customer_id }, stripe_account: @user.uid)
Stripe::Charge.create({
amount: total_amount,
currency: 'usd',
source: token,
application_fee: platform_fee},
stripe_account: @user.uid
)
现在这是我通过平台收费的代码:
token = Stripe::Token.create( { customer: customer.stripe_customer_id }, stripe_account: @user.uid)
Stripe::Charge.create({
amount: total_amount,
currency: 'usd',
source: token,
application_fee: platform_fee,
destination: @user.uid
})
问题是通过平台收费时令牌应该不同地创建吗?
当您使用 token = Stripe::Token.create( { customer: customer.stripe_customer_id }, stripe_account: @user.uid)
创建令牌时,令牌是在用户的条带帐户中创建的。当您在用户帐户中创建费用时(如您的第一个示例),这很好用。但是,在您的第二个示例中,费用是在您的帐户中创建的。当费用在您的帐户中时,实际上无需创建新令牌,因为您只需向客户收费并设置目的地即可。
应该这样做:
Stripe::Charge.create({
amount: total_amount,
currency: 'usd',
customer: customer.stripe_customer_id,
application_fee: platform_fee,
destination: @user.uid
})
这是一个我无法弄清楚的 Stripe 特定问题。
最初我的条纹连接设置是直接收费的,这意味着平台会削减它,但费用会直接转到接收者。我们的问题是 stripe 从用户那里收取费用,而我们希望它从我们这边收取费用。
因此我们需要通过平台进行收费。
现在,当我使用直接充电测试我的代码时,它可以正常工作,但是当我将其更改为通过平台时,它说:
No such token: tok_16lFgxDVBtbPPV
这是我的直接收费代码(有效):
token = Stripe::Token.create( { customer: customer.stripe_customer_id }, stripe_account: @user.uid)
Stripe::Charge.create({
amount: total_amount,
currency: 'usd',
source: token,
application_fee: platform_fee},
stripe_account: @user.uid
)
现在这是我通过平台收费的代码:
token = Stripe::Token.create( { customer: customer.stripe_customer_id }, stripe_account: @user.uid)
Stripe::Charge.create({
amount: total_amount,
currency: 'usd',
source: token,
application_fee: platform_fee,
destination: @user.uid
})
问题是通过平台收费时令牌应该不同地创建吗?
当您使用 token = Stripe::Token.create( { customer: customer.stripe_customer_id }, stripe_account: @user.uid)
创建令牌时,令牌是在用户的条带帐户中创建的。当您在用户帐户中创建费用时(如您的第一个示例),这很好用。但是,在您的第二个示例中,费用是在您的帐户中创建的。当费用在您的帐户中时,实际上无需创建新令牌,因为您只需向客户收费并设置目的地即可。
应该这样做:
Stripe::Charge.create({
amount: total_amount,
currency: 'usd',
customer: customer.stripe_customer_id,
application_fee: platform_fee,
destination: @user.uid
})