繁体   English   中英

卡未为Stripe客户保存

[英]Card not saving for a Stripe Customer

我遇到了问题,即使用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的结果, 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
} 

一切都与我期望的一样,尚未添加卡。

有人可以建议我在这里做错什么吗?

要将新卡添加到现有客户,您必须使用create card API调用。 请查看https://stripe.com/docs/api/ruby#create_card了解有关如何执行此操作的详细信息。

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

让我知道这是否有助于解决您的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM