首页 文章

条带服务器中未创建条带标记

提问于
浏览
1

我正在使用Stripe创建一个rails应用程序 . 我只能使用standalone accounts,因为法国没有托管帐户 . 我使用shared customers因为在我的应用上赚钱的人正在分享他们的客户 .

Create Card Token doc

当然,我向您展示的内容使用了我的Test Stripe环境 .

为了向用户收取费用,我创建了一个令牌:

tok = Stripe::Token.create(
  {:customer => customer.id, :card => customer.cards.last.stripe_id},
  {:stripe_account => user.stripe_user_id}
)
=> #<Stripe::Token:0x3fd9c3830900 id=tok_19fYblIUbyeToO5BfgwmLR9Y> JSON: {
  "id": "tok_19fYblIUbyeToO5BfgwmLR9Y",
  "object": "token",
  "card":     {"id":"card_19fYblIUbyeToO5BwRTTlJ1x","object":"card","address_city":null,"address_country":null,"address_line1":null,"address_line1_check":null,"address_line2":null,"address_state":null,"address_zip":null,"address_zip_check":null,"brand":"Visa","country":"US","cvc_check":"pass","dynamic_last4":null,"exp_month":12,"exp_year":2020,"fingerprint":"xxsPLKbXK7swE7It","funding":"credit","last4":"4242","metadata":{},"name":null,"tokenization_method":null},
  "client_ip": "31.33.230.61",
  "created": 1485280889,
  "livemode": false,
  "type": "card",
  "used": false
}

之后,我想使用该令牌向客户收费但不幸的是,Stripe服务器上不存在该令牌:

Stripe::Token.retrieve(tok.id)
Stripe::InvalidRequestError: No such token: tok_19fYk2IUbyeToO5Bo4thhjn7
 from /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/stripe-1.58.0/lib/stripe.rb:326:in `handle_api_error'

当我尝试向客户收费或将令牌保存为客户来源时,它会给我同样的错误 . 我试图创建一个基本费用,看看它是否是一个更大规模的错误:

tok = Stripe::Token.create(
  :card => {
    :number => "4242424242424242",
    :exp_month => 1,
    :exp_year => 2018,
    :cvc => "314"
  },
)
=> #<Stripe::Token:0x3fd9c71b002c id=tok_19fYWGLTk1qRIoGhSApzxo8u> JSON: {
  "id": "tok_19fYWGLTk1qRIoGhSApzxo8u",
  "object": "token",
  "card": {"id":"card_19fYWGLTk1qRIoGhBpLf7sFp","object":"card","address_city":null,"address_country":null,"address_line1":null,"address_line1_check":null,"address_line2":null,"address_state":null,"address_zip":null,"address_zip_check":null,"brand":"Visa","country":"US","cvc_check":"unchecked","dynamic_last4":null,"exp_month":1,"exp_year":2018,"fingerprint":"D6Dfg1vPHxjxX2XI","funding":"credit","last4":"4242","metadata":{},"name":null,"tokenization_method":null},
  "client_ip": "31.33.230.61",
  "created": 1485280548,
  "livemode": false,
  "type": "card",
  "used": false
}

但后来我能够检索令牌:

Stripe::Token.retrieve(tok.id)
=> #<Stripe::Token:0x3fd9c2726b3c id=tok_19fYWGLTk1qRIoGhSApzxo8u> JSON: {
  "id": "tok_19fYWGLTk1qRIoGhSApzxo8u",
  "object": "token",
  "card": {"id":"card_19fYWGLTk1qRIoGhBpLf7sFp","object":"card","address_city":null,"address_country":null,"address_line1":null,"address_line1_check":null,"address_line2":null,"address_state":null,"address_zip":null,"address_zip_check":null,"brand":"Visa","country":"US","cvc_check":"unchecked","dynamic_last4":null,"exp_month":1,"exp_year":2018,"fingerprint":"D6Dfg1vPHxjxX2XI","funding":"credit","last4":"4242","metadata":{},"name":null,"tokenization_method":null},
  "client_ip": "31.33.230.61",
  "created": 1485280548,
  "livemode": false,
  "type": "card",
  "used": false
}

当我将客户作为参数传递时,它根本不起作用,为什么?我不知道因为我做了它因为文件告诉我 .

1 回答

  • 3

    令牌是使用Stripe-Account标头创建的,因此生成的令牌对象存在于目标帐户上 .

    因此,为了retrieve the token或在API请求中使用它,请求还必须使用具有相同帐户ID的 Stripe-Account 标头 .

相关问题