Class: Vpago::PaymentProcessor

Inherits:
Object
  • Object
show all
Includes:
PaymentProcessable
Defined in:
app/services/vpago/payment_processor.rb

Instance Method Summary collapse

Methods included from PaymentProcessable

#can_cancel_pre_auth?, #cancel_pre_auth, #extract_completer_failure_reason_code, #failure, #log_process, #success?, #user_informer

Constructor Details

#initialize(payment:) ⇒ PaymentProcessor

Returns a new instance of PaymentProcessor.



12
13
14
15
# File 'app/services/vpago/payment_processor.rb', line 12

def initialize(payment:)
  @payment = payment
  @error = nil
end

Instance Method Details

#callObject



17
18
19
# File 'app/services/vpago/payment_processor.rb', line 17

def call
  log_process('call!') { call! }
end

#call!Object



21
22
23
24
25
26
27
28
29
30
# File 'app/services/vpago/payment_processor.rb', line 21

def call!
  process_payment!
  process_order! if @payment.completed? || @payment.pending?
rescue Spree::Core::GatewayError => e
  return handle_payment_failure(:unable_to_connect_to_gateway, e.message) if e.message == Spree.t(:unable_to_connect_to_gateway)

  handle_payment_failure(:gateway_error, e.message)
rescue StateMachines::InvalidTransition => e
  handle_payment_failure(:invalid_state_machine_transition, e.message)
end