module Paysto::Controller
Public Instance Methods
callback()
click to toggle source
Second step of payment workflow: Payment creation. Render invoice ID if everything right or anything else if not.
# File lib/paysto/controller.rb, line 23 def callback invoice = Paysto.invoice_class.find_by(id: params['PAYSTO_INVOICE_ID']) if invoice && invoice.need_to_be_paid?(:paysto, params['PAYSTO_REQUEST_MODE'], params['PAYSTO_SUM']) && Paysto.ip_valid?(request.remote_ip) && Paysto.md5_valid?(params) invoice.notify(params, :paysto) invoice.send("create_#{Paysto.payment_class_name.underscore}", Paysto.get_payment_type(invoice.id), 'paysto', Paysto.real_amount(params['PAYSTO_SUM'])) render text: invoice.id else render text: I18n.t('paysto.callback.fail') end end
check()
click to toggle source
First step of payment workflow: Invoice, IP and MD5 verification. Render invoice ID if everything right or anything else if not.
# File lib/paysto/controller.rb, line 12 def check invoice = Paysto.invoice_class.find_by(id: params['PAYSTO_INVOICE_ID']) if Paysto.invoice_valid?(invoice) && Paysto.ip_valid?(request.remote_ip) && Paysto.md5_valid?(params) render text: invoice.id else render text: I18n.t('paysto.check.fail') end end
fail()
click to toggle source
Fail callback.
# File lib/paysto/controller.rb, line 41 def fail flash[:alert] = I18n.t('paysto.fail') redirect_to root_path end
success()
click to toggle source
Success callback.
# File lib/paysto/controller.rb, line 35 def success flash[:success] = I18n.t('paysto.success') redirect_to root_path end