Module: SolidusRazorpay::OrderDecorator

Defined in:
app/models/solidus_razorpay/order_decorator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



8
9
10
11
12
13
14
15
# File 'app/models/solidus_razorpay/order_decorator.rb', line 8

def prepended(base)
  base.checkout_flow do
    go_to_state :address
    go_to_state :delivery
    go_to_state :payment
    go_to_state :complete
  end
end

.process_razorpayment(params, order) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/solidus_razorpay/order_decorator.rb', line 17

def process_razorpayment(params, order)
  setup_razorpay(payment_method(params[:payment_method_id]))
  razorpay_payment_object = Razorpay::Payment.fetch(params[:razorpay_payment_id])
  payment = payment(order, razorpay_payment_object, payment_method(params[:payment_method_id]))
  if payment_authorized?(razorpay_payment_object)
    razorpay_payment_object.capture({ amount: order.amount_in_paise })
    razorpay_payment_object = Razorpay::Payment.fetch(params[:razorpay_payment_id])
    payment.update(response_code: razorpay_payment_object.status)
    razorpay_payment_object.status
  else
    raise StandardError.new('Unable to capture payment')
  end
end

Instance Method Details

#amount_in_paiseObject



3
4
5
# File 'app/models/solidus_razorpay/order_decorator.rb', line 3

def amount_in_paise
  (total.to_f * 100).to_i
end