Skip to content

Commit

Permalink
Merge pull request #179 from Mangopay/fix/remove-testing-versions
Browse files Browse the repository at this point in the history
removed some testing versions
  • Loading branch information
catacraciun authored Oct 28, 2020
2 parents 092187b + c3ca0f8 commit 205df5a
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 9 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: ruby
rvm:
- 2.0.0
- 2.1
- 2.2
- 2.3
- 2.4
# - 2.0.0
# - 2.1
# - 2.2
# - 2.3
# - 2.4
- 2.5
script: bundle exec rspec
deploy:
Expand Down
8 changes: 8 additions & 0 deletions lib/mangopay/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ def validate(client_id, card_id)
MangoPay.request(:post, url)
end

def create_bank_account(params)
MangoPay.request(:post, url() + "/bankaccounts/iban", params)
end

def create_payout(params)
MangoPay.request(:post, url() + "/payouts", params)
end

end
end
end
4 changes: 4 additions & 0 deletions lib/mangopay/pre_authorization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ def self.create(params, idempotency_key = nil)
MangoPay.request(:post, "#{url}/card/direct", params, {}, idempotency_key)
end

def self.transactions(pre_authorization_id, filters = {})
MangoPay.request(:get, "#{url}/#{pre_authorization_id}/transactions", {}, filters)
end

end
end
59 changes: 55 additions & 4 deletions spec/mangopay/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
describe 'UPLOAD LOGO' do
it 'accepts Base64 encoded file content' do
fnm = __FILE__.sub('.rb', '.png')
bts = File.open(fnm, 'rb') {|f| f.read}
bts = File.open(fnm, 'rb') { |f| f.read }
b64 = Base64.encode64(bts)
ret = MangoPay::Client.upload_logo(b64)
expect(ret).to be_nil
Expand All @@ -56,7 +56,7 @@

it 'fails when input string is not base64-encoded' do
file = 'any file content...'
expect {MangoPay::Client.upload_logo(file)}.to raise_error {|err|
expect { MangoPay::Client.upload_logo(file) }.to raise_error { |err|
expect(err).to be_a MangoPay::ResponseError
expect(err.code).to eq '400'
expect(err.type).to eq 'param_error'
Expand All @@ -75,14 +75,14 @@
wlts = MangoPay::Client.fetch_wallets('fees')
expect(wlts).to be_kind_of(Array)
expect(wlts).not_to be_empty
expect((wlts.map {|m| m['FundsType']}).uniq).to eq(['FEES'])
expect((wlts.map { |m| m['FundsType'] }).uniq).to eq(['FEES'])
end

it 'fetches all client credit wallets' do
wlts = MangoPay::Client.fetch_wallets('credit')
expect(wlts).to be_kind_of(Array)
expect(wlts).not_to be_empty
expect((wlts.map {|m| m['FundsType']}).uniq).to eq(['CREDIT'])
expect((wlts.map { |m| m['FundsType'] }).uniq).to eq(['CREDIT'])
end
end

Expand Down Expand Up @@ -139,4 +139,55 @@
end
end

describe 'create_bank_account' do
it 'creates a new bank account' do
bank_account = MangoPay::Client.create_bank_account(Type: 'IBAN',
OwnerName: 'John',
OwnerAddress: {
AddressLine1: 'Le Palais Royal',
AddressLine2: '8 Rue de Montpensier',
City: 'Paris',
Region: '',
PostalCode: '75001',
Country: 'FR'
},
IBAN: 'FR7618829754160173622224154',
BIC: 'CMBRFR2BCME',
Tag: 'Test bank account')
expect(bank_account).not_to be_nil
expect(bank_account['Id']).not_to be_nil
end
end

describe 'create_payout' do
it 'creates a new payout' do
wallets = MangoPay::Client.fetch_wallets('FEES')
bank_account = MangoPay::Client.create_bank_account(Type: 'IBAN',
OwnerName: 'John',
OwnerAddress: {
AddressLine1: 'Le Palais Royal',
AddressLine2: '8 Rue de Montpensier',
City: 'Paris',
Region: '',
PostalCode: '75001',
Country: 'FR'
},
IBAN: 'FR7618829754160173622224154',
BIC: 'CMBRFR2BCME',
Tag: 'Test bank account')
pay_out = MangoPay::Client.create_payout(BankAccountId: bank_account['Id'],

DebitedFunds: {
Currency: 'EUR',
Amount: 12
},
DebitedWalletId: wallets[0]['Id'],
BankWireRef: 'invoice 7282',
Tag: 'bla')

expect(pay_out).not_to be_nil
expect(pay_out['Id']).not_to be_nil
end
end

end
2 changes: 2 additions & 0 deletions spec/mangopay/payin_preauthorized_direct_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def check_type_and_status(payin)
describe 'CREATE' do
it 'creates a preauthorized direct payin' do
created = new_payin_preauthorized_direct
transactions = MangoPay::PreAuthorization.transactions(created['PreauthorizationId'])
expect(created['Id']).not_to be_nil
expect(transactions[0]['Status']).to eq('SUCCEEDED')
check_type_and_status(created)
end
end
Expand Down

0 comments on commit 205df5a

Please sign in to comment.