Class: Vpago::PayoutProfiles::Payway::PayoutProfileRequestCreator
- Inherits:
-
BasePayoutProfileRequest
- Object
- BasePayoutProfileRequest
- Vpago::PayoutProfiles::Payway::PayoutProfileRequestCreator
- 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
-
#call ⇒ Object
code: “00”: Success! “PTL148”: Payee already exists.
-
#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.
-
#request_path ⇒ Object
override.
Methods inherited from BasePayoutProfileRequest
#connection, #initialize, #request_to_payway
Constructor Details
This class inherits a constructor from Vpago::PayoutProfiles::Payway::BasePayoutProfileRequest
Instance Method Details
#call ⇒ Object
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 .any? code = json_response['status']['code'] if code == '00' profile.verify!(json_response['data']) elsif code == 'PTL148' handle_existing_account(json_response) elsif code.present? profile.reset_verification! << json_response['status'] end .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 handle_existing_account(json_response) other_existing_profile = Spree::PayoutProfile.where.not(id: profile.id).find_by( type: profile.type, bank_account_number: profile.bank_account_number ) if other_existing_profile.nil? PayoutProfileRequestUpdater.new(profile).call else profile.reset_verification! << json_response['status'] end end |
#request_path ⇒ Object
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 |