Class: PaymentMethod::Check

Inherits:
PaymentMethod show all
Defined in:
app/models/payment_method/check.rb

Constant Summary

Constants inherited from PaymentMethod

DISPLAY

Instance Method Summary collapse

Methods inherited from PaymentMethod

active?, available, current, #destroy, find_with_destroyed, #method_type, #payment_profiles_supported?, #payment_source_class, #provider_class, providers, register

Instance Method Details

#actionsObject



2
3
4
# File 'app/models/payment_method/check.rb', line 2

def actions
  %w{capture void}
end

#can_capture?(payment) ⇒ Boolean

Indicates whether its possible to capture the payment

Returns:

  • (Boolean)


7
8
9
# File 'app/models/payment_method/check.rb', line 7

def can_capture?(payment)
  ['checkout', 'pending'].include?(payment.state)
end

#can_void?(payment) ⇒ Boolean

Indicates whether its possible to void the payment.

Returns:

  • (Boolean)


12
13
14
# File 'app/models/payment_method/check.rb', line 12

def can_void?(payment)
  payment.state != 'void'
end

#capture(payment) ⇒ Object



16
17
18
19
20
# File 'app/models/payment_method/check.rb', line 16

def capture(payment)
  payment.update_attribute(:state, 'pending') if payment.state == 'checkout'
  payment.complete
  true
end

#void(payment) ⇒ Object



22
23
24
25
26
# File 'app/models/payment_method/check.rb', line 22

def void(payment)
  payment.update_attribute(:state, 'pending') if payment.state == 'checkout'
  payment.void
  true
end