I'm working with Stripe managed accounts, I can create and retrieve Accounts without problem, but I can not add credit cards to any Stripe Account. I'm using Stripe.js
to deal with the card creation process, so in the views I collect the card fields and let Stripe.js do the dirty job of validation and processing. If everything is ok, I receive a stripeToken
from Stripe which is used in my controller to finally associate the managed account and the credit card.
However I receive this error:
Error creating card: (Status 400) You must provide a card that has the 'currency' field set when adding a card to a Stripe account.
Therefore I assumed I needed to add the currency
field in the Card form, so I tried again and then I had this error:
This card doesn't appear to be a debit card. (when submitting currency from views)
I already tried to search the error, but somehow there are no real references or previous answers.
Does anyone know how I can resolve this problem?
Thanks in advance!
Details
Since I'm testing on my local machine, I'm using Stripe's test Card number:
4242424242424242
which accepts any expiration date
and CVC
Here is some code:
This is how I create my managed account:
def create_account(email)
Stripe::Account.create(
{
:country => "US",
:managed => true,
:email => email,
:default_currency => "USD"
}
)
end
This is how I add the card token to the accounts (based on the API docs):
def add_card_to_account(account_id, card_token)
account = get_account(account_id)
account.external_accounts.create(:external_account => card_token)
end