Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added multibanco web payin #229

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/mangopay/pay_in.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions spec/mangopay/payin_multibanco_web_spec.rb
Original file line number Diff line number Diff line change
@@ -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
17 changes: 16 additions & 1 deletion spec/mangopay/shared_resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
###############################################
Expand Down
Loading