From 99a58f8220a8dc3e2d791d841f4c2c92c61ab945 Mon Sep 17 00:00:00 2001 From: Iulian Masar Date: Mon, 4 Sep 2023 09:55:46 +0300 Subject: [PATCH] added multibanco web payin --- lib/mangopay/pay_in.rb | 10 +++++++ spec/mangopay/payin_multibanco_web_spec.rb | 32 ++++++++++++++++++++++ spec/mangopay/shared_resources.rb | 17 +++++++++++- 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 spec/mangopay/payin_multibanco_web_spec.rb diff --git a/lib/mangopay/pay_in.rb b/lib/mangopay/pay_in.rb index 42f22e5..6384d7e 100644 --- a/lib/mangopay/pay_in.rb +++ b/lib/mangopay/pay_in.rb @@ -157,6 +157,16 @@ def self.url(*) end end + module Multibanco + class Web < Resource + include HTTPCalls::Create + + def self.url(*) + "#{MangoPay.api_path}/payins/payment-methods/multibanco" + end + end + end + module RecurringPayments class Recurring < Resource include HTTPCalls::Create diff --git a/spec/mangopay/payin_multibanco_web_spec.rb b/spec/mangopay/payin_multibanco_web_spec.rb new file mode 100644 index 0000000..aef7d85 --- /dev/null +++ b/spec/mangopay/payin_multibanco_web_spec.rb @@ -0,0 +1,32 @@ +describe MangoPay::PayIn::Multibanco::Web, 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('MULTIBANCO') + expect(payin['ExecutionType']).to eq('WEB') + expect(payin['Status']).to eq('CREATED') + end + + describe 'CREATE' do + it 'creates a multibanco web payin' do + created = new_payin_multibanco_web + expect(created['Id']).not_to be_nil + expect(created['ReturnURL']).not_to be_nil + check_type_and_status(created) + end + end + + describe 'FETCH' do + it 'fetches a payin' do + created = new_payin_multibanco_web + fetched = MangoPay::PayIn.fetch(created['Id']) + expect(fetched['Id']).to eq(created['Id']) + check_type_and_status(created) + check_type_and_status(fetched) + end + end + +end diff --git a/spec/mangopay/shared_resources.rb b/spec/mangopay/shared_resources.rb index c23401c..de712ee 100644 --- a/spec/mangopay/shared_resources.rb +++ b/spec/mangopay/shared_resources.rb @@ -441,7 +441,7 @@ def create_new_document(user) let(:new_payin_card_direct) { create_new_payin_card_direct(new_wallet) } ############################################### - # MBWAY/direct + # MBWAY/web ############################################### let(:new_payin_mbway_web) do MangoPay::PayIn::Mbway::Web.create( @@ -455,6 +455,21 @@ def create_new_document(user) ) end + ############################################### + # MULTIBANCO/web + ############################################### + let(:new_payin_multibanco_web) do + MangoPay::PayIn::Multibanco::Web.create( + AuthorId: new_natural_user['Id'], + DebitedFunds: {Currency: 'EUR', Amount: 199}, + Fees: {Currency: 'EUR', Amount: 1}, + CreditedWalletId: new_wallet['Id'], + StatementDescriptor: "ruby", + Tag: 'Test PayIn/Multibanco/Web', + ReturnURL: 'http://www.my-site.com/returnURL' + ) + end + ############################################### # PAYPAL/direct ###############################################