【问题标题】:How can i create a token for the card in stripe and charge the card for a user?如何为卡创建条带令牌并为用户收取卡费用?
【发布时间】:2014-04-22 08:48:21
【问题描述】:

我已经在 Stripe 中创建了一个应用程序,现在我允许用户注册到我的网站,在他们注册后,我会要求他们使用凭据连接到 Stripe,如果他们有或在 Stripe 中注册并将它们带回具有条带访问令牌的站点。

现在说另一个用户登录,他想购买属于已经连接到 stripe 的另一个用户的东西。

user1(连接到条带)

user2(想购买user1展示的产品)

所以我使用结帐来获取 user2 的卡详细信息,我用来创建令牌的可发布密钥是我创建的应用程序的密钥。令牌已创建,如果我继续为卡充电,则会显示

Invalid token id: tok_1278ghsdg26hsdfs. The publishable key used to create this token is from a different account. 

以下是我的收费方式

token = params[:stripeToken]
charge = Stripe::Charge.create({
    :amount      => @amount,
    :card        => token,
    :description => 'sample desc',
    :currency    => 'usd'
  },
  Accesstoken
  )

那么我怎样才能为客户从卡中扣款呢?

【问题讨论】:

  • 这是一个艰难的过程,因为 Rails 应用程序中的 Stripe 集成被设计为“单租户”。每个帐户都有不同的 Publishable 密钥,这意味着您必须找到一种方法为每次付款创建一个新的 Strip 实例——我还不确定这一点
  • 感谢您的回复。如果您发现任何对这个主题有用的东西,请更新我,以便我可以使用它。

标签: ruby-on-rails ruby-on-rails-4 stripe-payments


【解决方案1】:
猜你喜欢
  • 1970-01-01
  • 2018-12-27
  • 2019-11-10
  • 1970-01-01
  • 2020-09-10
  • 2020-02-23
  • 1970-01-01
  • 2015-02-24
  • 2015-02-24
相关资源
最近更新 更多