Sha256: 1dd5504023a95e2da94628e0c24cf055602814d092f10c9c20831d1473c69cff
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
module PerfectMoneyMerchant class PaymentsController < ActionController::Base def status if Payment.exists?(payment_batch_num: sci_params.payment_batch_num) raise StandardError.new('payment exists') end SCIResponse.new(sci_params).tap { |obj| obj.set_secret_key(Account::Query.new.get_secret_key(sci_params.payee_account)) }.verify! payment = Payment.create( payment_batch_num: sci_params.payment_batch_num, payment_id: sci_params.payment_id, payment_amount: sci_params.payment_amount, payer_account: sci_params.payer_account, payee_account: sci_params.payee_account, ) Configuration.config.tasks[sci_params.payment_purpose].tap { |task| task.call(sci_params, payment.id) unless task.nil? } render status: 200, nothing: true rescue StandardError => exception render status: 400, inline: 'error occurred' end def success if sci_params.redirect_url.nil? render status: 200, inline: 'Success! You have paid for it successfully.' else redirect_to sci_params.redirect_url end end def error if sci_params.redirect_url.nil? render status: 400, inline: 'Error! Error occured.' else redirect_to sci_params.redirect_url end end private def sci_params @sci_params ||= Hashie::Mash.new(params.map { |k, v| [k.downcase, v] }.inject({}) { |hash, param| hash.merge!(param[0] => param[1]) }) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
perfect_money_merchant-0.1.2 | app/controllers/perfect_money_merchant/payments_controller.rb |