Class: Gateway::PayuController

Inherits:
Spree::BaseController
  • Object
show all
Includes:
Spree::Core::ControllerHelpers::Order
Defined in:
app/controllers/spree/gateway/payu_controller.rb

Instance Method Summary collapse

Instance Method Details

#comebackObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/spree/gateway/payu_controller.rb', line 6

def comeback
  payment = Spree::Payment.find_by("public_metadata->>'token' = ?", params[:order][:orderId])

  if payment&.state == 'checkout' &&
     payment.payment_method.verify_transaction(params[:order][:status],
                                               payment,
                                               params[:order][:totalAmount],
                                               params[:order][:currencyCode],
                                               params[:order][:orderId]) &&
      payment.order.update_with_updater!
    head :ok
  else
    head :unprocessable_entity
  end
end