Skip to content

Commit

Permalink
Merge pull request #81 from Mangopay/bugfix/NewPayIn
Browse files Browse the repository at this point in the history
Added new pay in support
  • Loading branch information
mickaelpois authored Aug 4, 2017
2 parents 289887b + 1972034 commit 7e8e3a6
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/mangopay/pay_in.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def self.url(*)
end
end

class ExternalInstruction < Resource
end

end

module DirectDebit
Expand Down
65 changes: 65 additions & 0 deletions spec/mangopay/payin_bankwire_external_instruction_spec.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion spec/mangopay/shared_resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,4 @@ def create_new_transfer(from_wallet, to_wallet, amnt = 500)
Country: 'LU'
}, new_wallet['Id'])
}
end
end

0 comments on commit 7e8e3a6

Please sign in to comment.