我正在使用https://github.com/rfunduk/rails-stripe-connect-example中的示例设置条带连接,并且在使用序列化存储时遇到问题stripe_account_status
,应该将其存储为数组。
这就是它的存储方式(从上面的示例链接生成)
{"details_submitted"=>false, "charges_enabled"=>true, "transfers_enabled"=>false, "fields_needed"=>["legal_entity.first_name", "legal_entity.last_name", "legal_entity.dob.day", "legal_entity.dob.month", "legal_entity.dob.year", "legal_entity.address.line1", "legal_entity.address.city", "legal_entity.address.postal_code", "bank_account"], "due_by"=>nil}
这就是我的应用程序存储它的方式
{:details_submitted=>false, :charges_enabled=>true, :transfers_enabled=>false, :fields_needed=>["legal_entity.first_name", "legal_entity.last_name", "legal_entity.dob.day", "legal_entity.dob.month", "legal_entity.dob.year", "legal_entity.address.line1", "legal_entity.address.city", "legal_entity.address.postal_code", "bank_account"], :due_by=>nil}
就我而言,一切都设置相同。唯一的区别是第一个示例使用
serialize :stripe_account_status, JSON
我的应用程序只有
serialize :stripe_account_status
原因是当我添加JSON时出现此错误:
JSON::ParserError - 795: unexpected token at '':
我尝试找出 JSON 错误,包括将 config/initializers/cookies_serializer.rb 更改为使用:hybrid但这给了我同样的错误。
有人可以指出我修复 JSON 问题或找到一种方法来确保stripe_account_status
正确存储为数组的正确方向。
以下是用于存储数组的方法:
if @account
user.update_attributes(
currency: @account.default_currency,
stripe_account_type: 'managed',
stripe_user_id: @account.id,
secret_key: @account.keys.secret,
publishable_key: @account.keys.publishable,
stripe_account_status: account_status
)
end
def account_status
{
details_submitted: account.details_submitted,
charges_enabled: account.charges_enabled,
transfers_enabled: account.transfers_enabled,
fields_needed: account.verification.fields_needed,
due_by: account.verification.due_by
}
end
谢谢我真的很感激你能指出我的任何方向!