From c9a480f1ebd55e6ef10b56c625a7eac59d62f3d9 Mon Sep 17 00:00:00 2001 From: SoloJr Date: Thu, 30 Sep 2021 11:07:14 +0300 Subject: [PATCH] MPSDK-922: Payconiq implementation --- lib/mangopay/pay_in.rb | 11 +++++++++++ spec/mangopay/payin_payconiq_web_spec.rb | 25 ++++++++++++++++++++++++ spec/mangopay/shared_resources.rb | 16 +++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 spec/mangopay/payin_payconiq_web_spec.rb diff --git a/lib/mangopay/pay_in.rb b/lib/mangopay/pay_in.rb index e2c63c6..fefe578 100644 --- a/lib/mangopay/pay_in.rb +++ b/lib/mangopay/pay_in.rb @@ -106,6 +106,17 @@ def self.url(*) end + module Payconiq + + class Web < Resource + include HTTPCalls::Create + def self.url(*) + "#{MangoPay.api_path}/payins/payconiq/#{CGI.escape(class_name.downcase)}" + end + end + + end + module ApplePay class Direct < Resource include HTTPCalls::Create diff --git a/spec/mangopay/payin_payconiq_web_spec.rb b/spec/mangopay/payin_payconiq_web_spec.rb new file mode 100644 index 0000000..4062572 --- /dev/null +++ b/spec/mangopay/payin_payconiq_web_spec.rb @@ -0,0 +1,25 @@ +describe MangoPay::PayIn::Payconiq::Web, type: :feature do + 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('PAYCONIQ') + expect(payin['ExecutionType']).to eq('WEB') + + # not SUCCEEDED yet: waiting for processing + expect(payin['Status']).to eq('CREATED') + expect(payin['ResultCode']).to be_nil + expect(payin['ResultMessage']).to be_nil + expect(payin['ExecutionDate']).to be_nil + end + + describe 'CREATE' do + it 'creates a payconiq web payin' do + created = new_payin_payconiq_web + expect(created['Id']).not_to be_nil + check_type_and_status(created) + end + end + +end diff --git a/spec/mangopay/shared_resources.rb b/spec/mangopay/shared_resources.rb index 8a2bdf1..d56ecf7 100644 --- a/spec/mangopay/shared_resources.rb +++ b/spec/mangopay/shared_resources.rb @@ -215,6 +215,22 @@ def create_new_document(user) ) end + ############################################### + # payconiq/web + ############################################### + + let(:new_payin_payconiq_web) do + MangoPay::PayIn::Payconiq::Web.create( + AuthorId: new_natural_user['Id'], + CreditedWalletId: new_wallet['Id'], + DebitedFunds: {Currency: 'EUR', Amount: 100}, + Fees: {Currency: 'EUR', Amount: 0}, + ReturnURL: MangoPay.configuration.root_url, + Country: "BE", + Tag: 'Custom Meta' + ) + end + ############################################### # applepay/direct ###############################################