Class: TrueWalletPaymentService

Inherits:
Object
  • Object
show all
Defined in:
app/services/true_wallet_payment_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(reservation) ⇒ TrueWalletPaymentService

Returns a new instance of TrueWalletPaymentService.



2
3
4
5
# File 'app/services/true_wallet_payment_service.rb', line 2

def initialize(reservation)
  @reservation = reservation
  BUSINESS_LOGGER.set_business_context({ reservation_id: reservation.id })
end

Instance Method Details

#executeObject



7
8
9
10
11
12
13
14
15
16
17
# File 'app/services/true_wallet_payment_service.rb', line 7

def execute
  return true if reservation.charge_amount.to_i.zero?

  success = false
  ActiveRecord::Base.transaction do
    reservation.charges.build(charge_attribute(reservation))
    success = true
  end
  BUSINESS_LOGGER.info 'Done processing True Wallet Payment', reservation_id: reservation.id
  success
end

#normalize_phone_number(phone) ⇒ Object



19
20
21
22
23
24
# File 'app/services/true_wallet_payment_service.rb', line 19

def normalize_phone_number(phone)
  parsed_phone = Phonelib.parse(phone)
  return phone unless parsed_phone.country_code != 0

  parsed_phone.national.gsub(' ', '')
end