【发布时间】:2014-11-20 20:12:19
【问题描述】:
我有下面的 Stripe 脚本,它可以从 Stripe 检索一些帐户信息。这是在 html.erb 页面上。
<%=
require "stripe"
Stripe.api_key = ENV["STRIPE_API_KEY"]
Stripe::Recipient.retrieve("rp_14xkLm12344CMLmVxUbW3A6")
%>
以上在我的html视图中的输出是:
{ "id": "rp_14xkLm12344CMLmVxUbW3A6", "object": "recipient", "created": 1415734250, "livemode": false, "type": "individual", "description": null, "email": null, "name": "Rob Smith", "verified": false, "metadata": {}, "active_account": {"id":"ba_14xkLj2Wc0ZCCMLmDrfCmjJH","object":"bank_account","last4":"6789","country":"US","currency":"usd","status":"new","fingerprint":"fsQXqyeIRbyqMsvW","bank_name":"BANK OF AMERICA, N.A.","default_for_currency":false,"disabled":false,"validated":false,"verified":false}, "cards": {"object":"list","total_count":0,"has_more":false,"url":"/v1/recipients/rp_14xkLm12344CMLmVxUbW3A6/cards","data":[],"count":0}, "default_card": null }
从上面,我想提取 4 列:名称、国家、银行名称、last4。
我尝试将变量名称添加到末尾,例如 Stripe::Recipient.retrieve("rp_14xkLm12344CMLmVxUbW3A6").name,但我收到错误消息,提示未定义局部变量名称。
更新代码:
<%= require "stripe"
Stripe.api_key = ENV["STRIPE_API_KEY"]
rp = Stripe::Recipient.retrieve("rp_14xkLm12344CMLmVxUbW3A6")
"Name: #{rp['name']}"
"Bank Name: #{rp['bank_name']}"
"Last 4 of Account Number: #{rp['last4']}"
%>
当我只保留上面的名称行时,它可以工作。但是当我添加银行名称和最后 4 时,输出只是最后一行“帐号的最后 4”的文本
【问题讨论】:
标签: ruby-on-rails stripe-payments