使用customer_id(strip_id)分条付款给客户

时间:2020-03-22 05:17:52

标签: stripe-payments strip

我已经为用户创建了一个捐赠应用程序。

  1. 使用devise和stripe添加用户并使用用户登录凭据创建客户。
  2. 然后创建了一个捐赠页面,任何人都可以前来捐赠而无需注册。

下面是用户界面。

Donation_list

现在,我想通过以下代码向在 Bio:hello 中注册并带有其customer_ID的客户付款。

token = params[:stripeToken]

  Stripe::Charge.create(
    customer: @user.stripe_id,
    source: token,
    amount:   2000,
    currency: 'usd',
    description: 'Example charge'
  )



But its throwing error. Stripe::InvalidRequestError: Customer cus_** does not have a linked source with ID tok_**.

请帮助我在不向该用户注册帐户的情况下捐款。

1 个答案:

答案 0 :(得分:0)

您需要先将Token附加/保存到Customer [0]。

[0] https://stripe.com/docs/saving-cards#saving-credit-card-details-for-later