Class: Vpago::PayoutProfiles::Payway::PayoutProfileRequestCreator

Inherits:
BasePayoutProfileRequest show all
Defined in:
app/services/vpago/payout_profiles/payway/payout_profile_request_creator.rb

Instance Attribute Summary

Attributes inherited from BasePayoutProfileRequest

#base_url, #error_messages, #profile

Instance Method Summary collapse

Methods inherited from BasePayoutProfileRequest

#connection, #initialize, #request_to_payway

Constructor Details

This class inherits a constructor from Vpago::PayoutProfiles::Payway::BasePayoutProfileRequest

Instance Method Details

#callObject

code: “00”: Success! “PTL148”: Payee already exists.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/services/vpago/payout_profiles/payway/payout_profile_request_creator.rb', line 13

def call
  json_response = request_to_payway
  return false if @error_messages.any?

  code = json_response['status']['code']

  if code == '00'
    profile.verify!(json_response['data'])
  elsif code == 'PTL148'
    (json_response)
  elsif code.present?
    profile.reset_verification!
    @error_messages << json_response['status']
  end

  error_messages.empty?
end

#handle_existing_account(json_response) ⇒ Object

if bank return that account already created, but account is not yet exist in our database, we can call updater to verify the profile as well as get account infos from bank.



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/services/vpago/payout_profiles/payway/payout_profile_request_creator.rb', line 34

def (json_response)
  other_existing_profile = Spree::PayoutProfile.where.not(id: profile.id).find_by(
    type: profile.type,
    bank_account_number: profile.
  )

  if other_existing_profile.nil?
    PayoutProfileRequestUpdater.new(profile).call
  else
    profile.reset_verification!
    @error_messages << json_response['status']
  end
end

#request_pathObject

override



6
7
8
# File 'app/services/vpago/payout_profiles/payway/payout_profile_request_creator.rb', line 6

def request_path
  'api/merchant-portal/merchant-access/whitelist-account/add-whitelist-payout'
end