mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 00:42:04 +02:00
Merge branch 'story/107571572-seb' into staging
This commit is contained in:
commit
5adf38a485
7 changed files with 243 additions and 14 deletions
46
app/controllers/registrar/payments_controller.rb
Normal file
46
app/controllers/registrar/payments_controller.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
class Registrar::PaymentsController < RegistrarController
|
||||
protect_from_forgery except: :back
|
||||
|
||||
skip_authorization_check # actually anyone can pay, no problems at all
|
||||
skip_before_action :authenticate_user!, :check_ip, only: [:back]
|
||||
before_action :check_bank
|
||||
|
||||
# to handle existing model we should
|
||||
# get invoice_id and then get number
|
||||
# build BankTransaction without connection with right reference number
|
||||
# do not connect transaction and invoice
|
||||
def pay
|
||||
invoice = Invoice.find(params[:invoice_id])
|
||||
@bank_link = BankLink::Request.new(params[:bank], invoice, self)
|
||||
@bank_link.make_transaction
|
||||
end
|
||||
|
||||
|
||||
# connect invoice and transaction
|
||||
# both back and IPN
|
||||
def back
|
||||
@bank_link = BankLink::Response.new(params[:bank], params)
|
||||
if @bank_link.valid?
|
||||
@bank_link.complete_payment
|
||||
|
||||
if @bank_link.invoice.binded?
|
||||
flash[:notice] = t(:pending_applieds)
|
||||
else
|
||||
flash[:error] = t(:something_wrong)
|
||||
end
|
||||
else
|
||||
flash[:error] = t(:something_wrong)
|
||||
end
|
||||
redirect_to registrar_invoice_path(@bank_link.invoice)
|
||||
end
|
||||
|
||||
private
|
||||
def banks
|
||||
ENV['payments_banks'].split(",").map(&:strip)
|
||||
end
|
||||
|
||||
def check_bank
|
||||
raise StandardError.new("Not Implemented bank") unless banks.include?(params[:bank])
|
||||
end
|
||||
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue