【问题标题】:Card not saving for a Stripe Customer卡没有为 Stripe 客户保存
【发布时间】:2014-09-24 13:25:05
【问题描述】:

我在使用 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
} 

一切都和我预期的一样,除非卡没有被添加。

谁能告诉我这里可能做错了什么?

【问题讨论】:

    标签: ruby stripe-payments


    【解决方案1】:

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

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

    如果这有助于解决您的问题,请告诉我。

    【讨论】:

      猜你喜欢
      • 2020-05-21
      • 2016-09-23
      • 2021-04-25
      • 2017-03-12
      • 2020-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多