Closed amonks closed 9 years ago
maybe don't pull this yet; I'm still getting some complaints about wanting personal_address
instead of address
and something about a validation hash.
I'll aim to get it working and update here. done, see above
I'm done. I edited the top comment with a summary.
@amonks Thanks a lot for your work here and submitting a pull request. I'll look into this shortly and get the right stuff merged.
Cheers!
Ok so, a few things:
decline_charge_on
is supposed to be supported. That's a bug! Noted internally, so thanks a lot for that.type
and an empty verification
hash should both be optional.ssn_last_4
as well as personal_id_number
which is what would be used in Canada (and, likely, in the future other countries).Hopefully this works for you. Thanks again for the contributions!
Nope! Not quite yet!
on a freshly-bootstrapped install, I now get the following error when trying to update a newly-created managed account. (all form fields filled in, account in US)
Stripe::InvalidRequestError ('verification' must be a hash.):
app/services/stripe_managed.rb:82:in `update_account!'
app/controllers/users_controller.rb:33:in `update'
Do you get different results?
I'm using API version 2015-04-07 (latest)
, on mri ruby 2.1.4p265
Hm, what's in params
for you? That's what gets passed to update_account!
and it shouldn't have a verification
key at all. According to the docs verification
is optional, so if this doesn't work it's a bug I'd say.
, it sure is not! I'll boot back in and update here with the restverification
is an empty string
params[:verification].inspect
is an empty string? That should definitely not be the case, but would explain the error. There is no form field that would set it (https://github.com/rfunduk/rails-stripe-connect-example/blob/master/app/views/users/_settings.html.haml).
I lied! Could have sworn I was getting an empty string yesterday.
In either case, I still get the error.
when update_account!
is called, params is
42:
43: @account
44: end
45:
46: def update_account!( params: nil )
=> 47: binding.pry
48: if params
49: if params[:bank_account_token]
50: account.bank_account = params[:bank_account_token]
51: account.save
52: end
[1] pry(#<StripeManaged>)> params
=> {"utf8"=>"✓",
"_method"=>"patch",
"authenticity_token"=>
"2t/GS/h0PjUBcxe8fh77WyK06mV77nDg0ZbN9BdCBZOJwRI03j3ga/oIu672KjwIVkExUhkXfJ5onMzJCkSpYw==",
"bank_account_token"=>"btok_64AVY0PB7Kq8BL",
"legal_entity"=>
{"first_name"=>"Todd",
"last_name"=>"Dockstader",
"dob(1i)"=>"1931",
"dob(2i)"=>"11",
"dob(3i)"=>"8",
"address"=>
{"line1"=>"10 Main St.", "line2"=>"", "city"=>"Chicago", "state"=>"IL", "postal_code"=>"60606"}},
"controller"=>"users",
"action"=>"update",
"id"=>"2"}
when account.save is called, account is:
From: /Users/ajm/Dropbox/~/Desktop/rails-stripe-connect-example/app/services/stripe_managed.rb @ line 84 StripeManaged#update_account!:
79: # copy 'address' as 'personal_address'
80: new_legal_entity[:personal_address] = new_legal_entity['address']
81:
82: account.legal_entity = new_legal_entity
83:
=> 84: binding.pry
85:
86: account.save
87: end
88: end
89:
[1] pry(#<StripeManaged>)> account
=> #<Stripe::Account:0x3fe62e3161b4 id=acct_15s28bDXvdRnTVAB> JSON: {
"id": "acct_15s28bDXvdRnTVAB",
"email": "todd@monks.co",
"statement_descriptor": null,
"display_name": null,
"timezone": "Etc/UTC",
"details_submitted": false,
"charges_enabled": true,
"transfers_enabled": true,
"currencies_supported": [
"usd",
"aed",
"afn",
"all",
"amd",
...
"zmw"
],
"default_currency": "usd",
"country": "US",
"object": "account",
"business_name": null,
"business_url": null,
"support_phone": null,
"metadata": {},
"managed": true,
"product_description": null,
"debit_negative_balances": false,
"bank_accounts": {"object":"list","total_count":1,"has_more":false,"url":"/v1/accounts/acct_15s28bDXvdRnTVAB/bank_accounts","data":[{"id":"ba_15s2AWDXvdRnTVAB6Ir90Bd5","object":"bank_account","last4":"6789","country":"US","currency":"usd","status":"new","fingerprint":"QCuD5FkCKbaz7oHE","routing_number":"110000000","bank_name":"STRIPE TEST BANK","default_for_currency":true}]},
"verification": {"fields_needed":["legal_entity.first_name","legal_entity.last_name","legal_entity.dob.day","legal_entity.dob.month","legal_entity.dob.year"],"due_by":null,"contacted":false},
"transfer_schedule": {"delay_days":2,"interval":"daily"},
"tos_acceptance": {"ip":"127.0.0.1","date":1429148996,"user_agent":null},
"legal_entity": {
"first_name": "Todd",
"last_name": "Dockstader",
"address": {
"line1": "10 Main St.",
"city": "Chicago",
"state": "IL",
"postal_code": "60606"
},
"dob": {
"year": "1931",
"month": "11",
"day": "8"
},
"personal_address": {
"line1": "10 Main St.",
"city": "Chicago",
"state": "IL",
"postal_code": "60606"
}
},
"decline_charge_on": {"cvc_failure":false,"avs_failure":false}
}
Ok, thanks. Looking into this. I don't think that's intentional.
OK, these changes were enough to get managed accounts working for the US.
See the commit messages for a more complete explanation, but in summary:
ab52ee5 and 7f76021 fix clear bugs and should definitely be pulled.
58f05e2 and b4139fd are additional changes that made managed accounts work for me and should probably be pulled:
Stripe now requires submitting a
verification
when creating a managed account. It can be a scanned document, the last 4 digits of an SSN, or I think an EIN for a corporate account. In the interest of a simple solution, I added anssn_last_4
form field, and did not include functionality for choosing a different verification scheme.I don't think Canadian people have SSNs, and the managed account public beta does include Canada, so this is probably not ideal.