不为条纹客户保存卡

时间:2014-08-01 10:47:58

标签: ruby stripe-payments

我遇到的问题是卡片令牌没有使用Ruby Stripe集成和Stripe.js对客户进行保存

我们从Stripe.js获得看似有效的卡片令牌(例如tok_4VeYrrjJpCwGG6

然后我打电话给以下人员;

customer = Stripe::Customer.retrieve(customer_id) #customer_id is correct and valid
customer.card = stripeToken # e.g. the tok_ I gave as an example
customer.save

如果我退出customer.save的结果,我会得到类似的内容;

{
    "id":"cus_4QR8ZuPUPlgA0G",
    "object":"customer",
    "created":1405685697,
    "livemode":false,
    "description":null,
    "email":"my_email",
    "delinquent":true,
    "metadata":{},
    "subscriptions": {
        "object":"list",
         "total_count":0,
         "has_more":false,
         "url":"/v1/customers/cus_4QR8ZuPUPlgA0G/subscriptions",
         "data":[],
         "count":0
    },
    "discount":null,
    "account_balance":0,
    "currency":"eur",
    "cards"{
         "object":"list",
         "total_count":0,
         "has_more":false,
         "url":"/v1/customers/cus_4QR8ZuPUPlgA0G/cards",
         "data":[],
         "count":0
     },
     "default_card":null,
     "subscription":null
} 

一切都如我所料那样没有添加卡片。

有人可以告诉我这里可能做错了吗?

1 个答案:

答案 0 :(得分:0)

要向现有客户添加新卡,您必须使用创建卡API调用。请查看https://stripe.com/docs/api/ruby#create_card了解有关如何解决此问题的详细信息。

在您的特定情况下,您可以使用以下内容更新用户:     customer = Stripe :: Customer.retrieve(customer_id)     customer.sources.create(:source => stripeToken)

请告诉我这是否有助于解决您的问题。

相关问题