[英]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.