Class: PaymentOxxoPolicy

Inherits:
Object
  • Object
show all
Defined in:
app/policies/payment_oxxo_policy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payment) ⇒ PaymentOxxoPolicy

Returns a new instance of PaymentOxxoPolicy.



6
7
8
# File 'app/policies/payment_oxxo_policy.rb', line 6

def initialize(payment)
  @payment = payment
end

Instance Attribute Details

#paymentObject (readonly)

Returns the value of attribute payment.



4
5
6
# File 'app/policies/payment_oxxo_policy.rb', line 4

def payment
  @payment
end

Instance Method Details

#process(options) ⇒ Object



10
11
12
13
14
15
# File 'app/policies/payment_oxxo_policy.rb', line 10

def process(options)
  return unless options[:status].eql?('paid')

  payment.complete if (options[:amount].to_i / 100 - payment.amount).abs < 0.01
  payment.order.updater.update
end