diff --git a/lib/mangopay/pay_in.rb b/lib/mangopay/pay_in.rb index e1529c5..ee01983 100644 --- a/lib/mangopay/pay_in.rb +++ b/lib/mangopay/pay_in.rb @@ -58,6 +58,9 @@ def self.url(*) end end + class ExternalInstruction < Resource + end + end module DirectDebit diff --git a/spec/mangopay/payin_bankwire_external_instruction_spec.rb b/spec/mangopay/payin_bankwire_external_instruction_spec.rb new file mode 100644 index 0000000..078c301 --- /dev/null +++ b/spec/mangopay/payin_bankwire_external_instruction_spec.rb @@ -0,0 +1,65 @@ +describe MangoPay::PayIn::BankWire::ExternalInstruction, type: :feature do + include_context 'wallets' + include_context 'payins' + + def check_type_and_status(payin) + expect(payin['Type']).to eq('PAYIN') + expect(payin['Nature']).to eq('REGULAR') + expect(payin['PaymentType']).to eq('BANK_WIRE') + expect(payin['ExecutionType']).to eq('EXTERNAL_INSTRUCTION') + end + + describe 'FETCH' do + it 'fetches a payin' do + MangoPay.configure do |c| + c.preproduction = true + c.client_id = 'sdk-unit-tests' + c.root_url = 'https://api-test.mangopay.com' + c.client_passphrase = '9RMGpwVUwFLK0SurxObJ2yaadDcO0zeKFKxWmthjB93SQjFzy0' + c.http_timeout = 10000 + end + + id = "2826947" + payIn = MangoPay::PayIn.fetch(id) + expect(payIn['Id']).to eq(id) + check_type_and_status(payIn) + end + end + +############################################### +# refund not implemented for this type of payin +############################################### +# describe 'REFUND' do +# it 'refunds a payin' do +# payin = new_payin_bankwire_direct +# refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']}) +# expect(refund['Id']).not_to be_nil +# expect(refund['Status']).to eq('SUCCEEDED') +# expect(refund['Type']).to eq('PAYOUT') +# expect(refund['Nature']).to eq('REFUND') +# expect(refund['InitialTransactionType']).to eq('PAYIN') +# expect(refund['InitialTransactionId']).to eq(payin['Id']) +# expect(refund['DebitedWalletId']).to eq(payin['CreditedWalletId']) +# end +# end +# +############################################### +# status is CREATED instead of SUCCEEDED +# so no cash flow yet +############################################### +# describe 'CASH FLOW' do +# it 'changes balances correctly' do +# wlt = new_wallet +# wallets_check_amounts(wlt, 0) +# +# # payin: feed wlt1 with money +# payin = create_new_payin_bankwire_direct(wlt, 1000) +# wallets_reload_and_check_amounts(wlt, 1000) +# +# # refund the payin +# refund = MangoPay::PayIn.refund(payin['Id'], {AuthorId: payin['AuthorId']}) +# wallets_reload_and_check_amounts(wlt, 0) +# end +# end + +end diff --git a/spec/mangopay/shared_resources.rb b/spec/mangopay/shared_resources.rb index 64871ae..87a62f6 100644 --- a/spec/mangopay/shared_resources.rb +++ b/spec/mangopay/shared_resources.rb @@ -394,4 +394,4 @@ def create_new_transfer(from_wallet, to_wallet, amnt = 500) Country: 'LU' }, new_wallet['Id']) } -end \ No newline at end of file +end