mirror of
https://github.com/internetee/registry.git
synced 2025-07-29 05:56:20 +02:00
added endpoint to receive payment data and update it
This commit is contained in:
parent
df48b2137b
commit
005a888f50
2 changed files with 56 additions and 0 deletions
52
app/controllers/eis_billing/payment_status_controller.rb
Normal file
52
app/controllers/eis_billing/payment_status_controller.rb
Normal file
|
@ -0,0 +1,52 @@
|
|||
module EisBilling
|
||||
class PaymentStatusController < ApplicationController
|
||||
skip_authorization_check # Temporary solution
|
||||
skip_before_action :verify_authenticity_token # Temporary solution
|
||||
|
||||
TYPE = "PaymentOrders::EveryPay".freeze
|
||||
|
||||
def update
|
||||
invoice_number = params[:order_reference]
|
||||
paid_at = params[:transaction_time]
|
||||
sum = params[:standing_amount]
|
||||
everypay_response = params
|
||||
payment_status = nil
|
||||
|
||||
if PaymentOrders::EveryPay::SUCCESSFUL_PAYMENT.include? params[:payment_state]
|
||||
payment_status = :paid
|
||||
elsif params[:payment_state] == 'failed'
|
||||
payment_status = :failed
|
||||
end
|
||||
|
||||
invoice = Invoice.find_by(number: invoice_number)
|
||||
|
||||
bank = BankTransaction.new
|
||||
bank.description = invoice.order
|
||||
bank.reference_no = invoice.reference_no
|
||||
bank.currency = invoice.currency
|
||||
bank.iban = invoice.seller_iban
|
||||
bank.sum = sum
|
||||
bank.paid_at = paid_at
|
||||
bank.buyer_name = invoice.buyer_name
|
||||
bank.save
|
||||
|
||||
p "++++ BANK TRANSACTION ERRORS ? ++++"
|
||||
p bank.errors
|
||||
|
||||
payment = PaymentOrder.new
|
||||
payment.type = TYPE
|
||||
payment.invoice = invoice
|
||||
payment.response = everypay_response
|
||||
payment.status = payment_status
|
||||
payment.save
|
||||
|
||||
p "++++ PAYMENT ORDER ERRORS ? ++++"
|
||||
p bank.errors
|
||||
|
||||
registrar = Registrar.find_by(reference_no: params[:reference_number])
|
||||
bank.create_activity(registrar, invoice)
|
||||
|
||||
render status: 200, json: { status: 'ok' }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -11,6 +11,10 @@ Rails.application.routes.draw do
|
|||
mount PgHero::Engine, at: "pghero"
|
||||
end
|
||||
|
||||
namespace :eis_billing do
|
||||
put '/payment_status', to: 'payment_status#update', as: 'payment_status'
|
||||
end
|
||||
|
||||
namespace :epp do
|
||||
constraints(EppConstraint.new(:session)) do
|
||||
get 'session/hello', to: 'sessions#hello', as: 'hello'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue