mirror of
https://github.com/internetee/registry.git
synced 2025-08-11 03:59:33 +02:00
refactoring
This commit is contained in:
parent
29e7f954f3
commit
9856a2a5c0
10 changed files with 31 additions and 33 deletions
|
@ -18,13 +18,13 @@ module EisBilling
|
|||
end
|
||||
|
||||
def decoded_token
|
||||
if auth_header
|
||||
token = auth_header.split(' ')[1]
|
||||
begin
|
||||
JWT.decode(token, billing_secret_key, true, algorithm: 'HS256')
|
||||
rescue JWT::DecodeError
|
||||
nil
|
||||
end
|
||||
return unless auth_header
|
||||
|
||||
token = auth_header.split(' ')[1]
|
||||
begin
|
||||
JWT.decode(token, billing_secret_key, true, algorithm: 'HS256')
|
||||
rescue JWT::DecodeError
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ class EisBilling::EInvoiceResponseController < EisBilling::BaseController
|
|||
invoice_number = params[:invoice_number]
|
||||
|
||||
set_e_invoice_sent_at(invoice_number)
|
||||
render status: 200, json: { messege: 'Response received', status: :ok }
|
||||
render status: :ok, json: { messege: 'Response received' }
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
module EisBilling
|
||||
class LhvConnectTransactionsController < EisBilling::BaseController
|
||||
def create
|
||||
params["_json"].each do |incoming_transaction|
|
||||
params['_json'].each do |incoming_transaction|
|
||||
process_transactions(incoming_transaction)
|
||||
end
|
||||
|
||||
render status: 200, json: { message: 'RECEIVED', status: :ok, params: params }
|
||||
render status: :ok, json: { message: 'RECEIVED', params: params }
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -15,16 +15,16 @@ module EisBilling
|
|||
logger.info incoming_transaction
|
||||
|
||||
bank_statement = BankStatement.new(bank_code: Setting.registry_bank_code,
|
||||
iban: Setting.registry_iban)
|
||||
iban: Setting.registry_iban)
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
bank_statement.save!
|
||||
|
||||
transaction_attributes = { sum: incoming_transaction["amount"],
|
||||
currency: incoming_transaction["currency"],
|
||||
paid_at: incoming_transaction["date"],
|
||||
reference_no: incoming_transaction["payment_reference_number"],
|
||||
description: incoming_transaction["payment_description"] }
|
||||
transaction_attributes = { sum: incoming_transaction['amount'],
|
||||
currency: incoming_transaction['currency'],
|
||||
paid_at: incoming_transaction['date'],
|
||||
reference_no: incoming_transaction['payment_reference_number'],
|
||||
description: incoming_transaction['payment_description'] }
|
||||
transaction = bank_statement.bank_transactions.create!(transaction_attributes)
|
||||
|
||||
next if transaction.registrar.blank?
|
||||
|
|
|
@ -18,7 +18,7 @@ module EisBilling
|
|||
registrar = invoice.buyer
|
||||
bank.create_activity(registrar, invoice)
|
||||
|
||||
render status: 200, json: { status: :ok }
|
||||
render status: :ok
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -41,10 +41,10 @@ class DirectoInvoiceForwardTwoJob < ApplicationJob
|
|||
def collect_monthly_data
|
||||
registrars_data = []
|
||||
|
||||
Registrar.where.not(test_registrar: true).find_each do |registrar|
|
||||
registrars_data << {
|
||||
Registrar.where.not(test_registrar: true).find_each do |registrar|
|
||||
registrars_data << {
|
||||
registrar: registrar,
|
||||
registrar_summery: registrar.monthly_summary(month: @month)
|
||||
registrar_summery: registrar.monthly_summary(month: @month),
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
module EisBilling
|
||||
class Base
|
||||
BASE_URL = ENV['eis_billing_system_base_url']
|
||||
BASE_URL = ENV['eis_billing_system_base_url'] || 'https://st-billing.infra.tld.ee'
|
||||
INITIATOR = 'registry'.freeze
|
||||
|
||||
def self.base_request(url:)
|
||||
uri = URI(url)
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
|
||||
if Rails.env.production?
|
||||
http.use_ssl = true
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
end
|
||||
http.use_ssl = true unless Rails.env.development?
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if Rails.env.development?
|
||||
|
||||
http
|
||||
end
|
||||
|
@ -26,7 +24,7 @@ module EisBilling
|
|||
def self.headers
|
||||
{
|
||||
'Authorization' => "Bearer #{generate_token}",
|
||||
'Content-Type' => 'application/json'
|
||||
'Content-Type' => 'application/json',
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ module EisBilling
|
|||
|
||||
def self.obj_data
|
||||
{
|
||||
initiator: INITIATOR
|
||||
initiator: INITIATOR,
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ module EisBilling
|
|||
invoice_data: object_data,
|
||||
monthly: monthly,
|
||||
dry: dry,
|
||||
initiator: INITIATOR
|
||||
initiator: INITIATOR,
|
||||
}
|
||||
|
||||
http = EisBilling::Base.base_request(url: directo_url)
|
||||
|
|
|
@ -15,7 +15,7 @@ module EisBilling
|
|||
seller_country_code: invoice.seller_country_code,
|
||||
buyer_country_code: invoice.buyer_country_code,
|
||||
payable: payable,
|
||||
initiator: EisBilling::Base::INITIATOR
|
||||
initiator: EisBilling::Base::INITIATOR,
|
||||
}
|
||||
|
||||
invoice.items.each do |invoice_item|
|
||||
|
@ -27,7 +27,7 @@ module EisBilling
|
|||
subtotal: invoice_item.subtotal,
|
||||
vat_rate: invoice_item.vat_rate,
|
||||
vat_amount: invoice_item.vat_amount,
|
||||
total: invoice_item.total
|
||||
total: invoice_item.total,
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
BASE_URL = ENV['eis_billing_system_base_url']
|
||||
BASE_URL = ENV['eis_billing_system_base_url'] || 'https://st-billing.infra.tld.ee'
|
||||
INITIATOR = 'registry'.freeze
|
||||
|
||||
namespace :eis_billing do
|
||||
|
@ -9,7 +9,7 @@ namespace :eis_billing do
|
|||
parsed_data << {
|
||||
invoice_number: invoice.number,
|
||||
initiator: 'registry',
|
||||
transaction_amount: invoice.total
|
||||
transaction_amount: invoice.total,
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace :eis_billing do
|
|||
Registrar.all.each do |registrar|
|
||||
parsed_data << {
|
||||
reference_number: registrar.reference_no,
|
||||
initiator: 'registry'
|
||||
initiator: 'registry',
|
||||
}
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue