Skip to content

Commit

Permalink
Local bank accounts
Browse files Browse the repository at this point in the history
Local bank accounts : Evolution of the method to accept new formats

- addition of 5 new types of BankAccounts available (IBAN,GB, US, CA,
Other)

- documentation:  http://docs.mangopay.com/api-references/bank-accounts/
  • Loading branch information
Sergiusz Woźnicki committed Mar 5, 2014
1 parent 4348eb5 commit 55952b1
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/mangopay/bank_account.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
module MangoPay
class BankAccount < Resource
include MangoPay::HTTPCalls::Create
include MangoPay::HTTPCalls::Fetch

def self.create(user_id, params)
type = params.fetch(:Type) { |no_symbol_key| params.fetch('Type') }
MangoPay.request(:post, "#{url(user_id)}/#{type}", params)
end

# Fetches:
# - list of bank accounts belonging to the given +user_id+
# - or single bank account belonging to the given +user_id+ with the given +bank_account_id+.
Expand Down
63 changes: 62 additions & 1 deletion spec/lib/mangopay/bank_account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,72 @@

describe MangoPay::BankAccount do
include_context 'bank_accounts'

def create(params)
params_fixed = { OwnerName: 'John', OwnerAddress: 'Here' }.merge(params)
MangoPay::BankAccount.create(new_natural_user['Id'], params_fixed)
end

describe 'CREATE' do
it 'creates a new bank detail' do

it 'creates a new IBAN bank detail' do
expect(new_bank_account['Id']).not_to be_nil
end

it 'creates a new GB bank detail' do
created = create({
Type: 'GB',
AccountNumber: '234234234234',
SortCode: '234334',
})
expect(created['Id']).not_to be_nil
expect(created['Type']).to eq('GB')
expect(created['AccountNumber']).to eq('234234234234')
expect(created['SortCode']).to eq('234334')
end

it 'creates a new US bank detail' do
created = create({
Type: 'US',
AccountNumber: '234234234234',
ABA: '234334789',
})
expect(created['Id']).not_to be_nil
expect(created['Type']).to eq('US')
expect(created['AccountNumber']).to eq('234234234234')
expect(created['ABA']).to eq('234334789')
end

it 'creates a new CA bank detail' do
created = create({
Type: 'CA',
BankName: 'TestBankName',
BranchCode: '12345',
AccountNumber: '234234234234',
InstitutionNumber: '123',
})
expect(created['Id']).not_to be_nil
expect(created['Type']).to eq('CA')
expect(created['BankName']).to eq('TestBankName')
expect(created['BranchCode']).to eq('12345')
expect(created['AccountNumber']).to eq('234234234234')
expect(created['InstitutionNumber']).to eq('123')
end

it 'creates a new OTHER bank detail' do
created = create({
Type: 'OTHER',
Country: 'FR',
AccountNumber: '234234234234',
BIC: 'BINAADADXXX',
})
expect(created['Id']).not_to be_nil
expect(created['Type']).to eq('OTHER')
expect(created['Country']).to eq('FR')
expect(created['AccountNumber']).to eq('234234234234')
expect(created['BIC']).to eq('BINAADADXXX')
end

end

describe 'FETCH' do
Expand Down

0 comments on commit 55952b1

Please sign in to comment.