Class: SolidusRazorpay::RazorpayController

Inherits:
Spree::StoreController
  • Object
show all
Defined in:
app/controllers/solidus_razorpay/razorpay_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/solidus_razorpay/razorpay_controller.rb', line 6

def create
  response_status = SolidusRazorpay::OrderDecorator.process_razorpayment(razorpay_params, order)
  if response_status == 'captured'
    order.next!
    @message = I18n.t('spree.order_processed_successfully')
    @current_order = nil
    flash.notice = I18n.t('spree.order_processed_successfully')
    flash['order_completed'] = true
    @error = false
    @redirect_path = spree.order_path(order)
  else
    order.update_attribute(:payment_state, 'failed')
    @error = true
    @message = 'There was an error processing your payment'
    @redirect_path = spree.checkout_state_path(order.state)
  end
rescue Spree::Core::GatewayError, StateMachine::InvalidTransition => ge
  error_message = ge.message
  puts "error_message: #{error_message}"
end