comment out generating invoices via lhv transaction

This commit is contained in:
olegphenomenon 2022-02-08 10:06:57 +02:00
parent de9504fef7
commit ccd9260ce8
9 changed files with 62 additions and 91 deletions

View file

@ -26,6 +26,10 @@ class Registrar
add_invoice_instance = EisBilling::AddDeposits.new(@invoice) add_invoice_instance = EisBilling::AddDeposits.new(@invoice)
result = add_invoice_instance.send_invoice result = add_invoice_instance.send_invoice
Rails.logger.info "Deposits controller ------->"
Rails.logger.info result.body
Rails.logger.info "-----------------------------------------"
link = JSON.parse(result.body)['everypay_link'] link = JSON.parse(result.body)['everypay_link']
@invoice.update(payment_link: link) @invoice.update(payment_link: link)

View file

@ -109,13 +109,13 @@ class Registrar < ApplicationRecord
SendEInvoiceJob.set(wait: 1.minute).perform_now(invoice.id, payable: payable) SendEInvoiceJob.set(wait: 1.minute).perform_now(invoice.id, payable: payable)
add_invoice_instance = EisBilling::AddDeposits.new(invoice) # add_invoice_instance = EisBilling::AddDeposits.new(invoice)
result = add_invoice_instance.send_invoice # result = add_invoice_instance.send_invoice
Rails.logger.info "Invoice created from transaction ------->" # Rails.logger.info "Invoice created from transaction ------->"
Rails.logger.info invoice # Rails.logger.info invoice
Rails.logger.info result.body # Rails.logger.info result.body
Rails.logger.info "-----------------------------------------" # Rails.logger.info "-----------------------------------------"
invoice invoice
end end

View file

@ -7,7 +7,7 @@ module EisBilling
end end
def send_invoice def send_invoice
base_request(json_obj: parse_invoice) send_request(json_obj: parse_invoice)
end end
private private
@ -25,19 +25,9 @@ module EisBilling
data data
end end
def base_request(json_obj:) def send_request(json_obj:)
uri = URI(invoice_generator_url) http = EisBilling::Base.base_request(url: invoice_generator_url)
http = Net::HTTP.new(uri.host, uri.port) http.post(invoice_generator_url, json_obj.to_json, HEADERS)
headers = {
'Authorization' => 'Bearer foobar',
'Content-Type' => 'application/json',
'Accept' => TOKEN
}
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.post(invoice_generator_url, json_obj.to_json, headers)
end end
def invoice_generator_url def invoice_generator_url

View file

@ -1,18 +1,37 @@
module EisBilling module EisBilling
class Base class Base
# crypt = ActiveSupport::MessageEncryptor.new(Rails.application.secrets.secret_key_base[0..31]) # crypt = ActiveSupport::MessageEncryptor.new(Rails.application.secrets.secret_key_base[0..31])
# irb(main):047:0> encrypted_data = crypt.encrypt_and_sign('PLEASE CREATE INVOICE') # irb(main):047:0> encrypted_data = crypt.encrypt_and_sign('PLEASE CREATE INVOICE')
# => # =>
# irb(main):048:0> decrypted_back = crypt.decrypt_and_verify(encrypted_data) # irb(main):048:0> decrypted_back = crypt.decrypt_and_verify(encrypted_data)
# => # =>
TOKEN = 'Bearer WA9UvDmzR9UcE5rLqpWravPQtdS8eDMAIynzGdSOTw==--9ZShwwij3qmLeuMJ--NE96w2PnfpfyIuuNzDJTGw=='.freeze TOKEN = 'Bearer WA9UvDmzR9UcE5rLqpWravPQtdS8eDMAIynzGdSOTw==--9ZShwwij3qmLeuMJ--NE96w2PnfpfyIuuNzDJTGw=='.freeze
BASE_URL = ""
BASE_URL = ''
if Rails.env.staging? if Rails.env.staging?
BASE_URL = ENV['eis_billing_system_base_url_staging'] BASE_URL = ENV['eis_billing_system_base_url_staging']
else else
BASE_URL = ENV['eis_billing_system_base_url_dev'] BASE_URL = ENV['eis_billing_system_base_url_dev']
end end
INITIATOR = 'registry' INITIATOR = 'registry'
HEADERS = {
'Authorization' => 'Bearer foobar',
'Content-Type' => 'application/json',
'Accept' => TOKEN
}
def self.base_request(url:)
uri = URI(url)
http = Net::HTTP.new(uri.host, uri.port)
unless Rails.env.development?
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
http
end
end end
end end

View file

@ -1,34 +1,21 @@
module EisBilling module EisBilling
class GetInvoiceNumber < EisBilling::Base class GetInvoiceNumber < EisBilling::Base
def self.send_invoice def self.send_invoice
result = base_request p "+++++++++++"
Rails.logger.info invoice_number_generator_url
p "+++++++++++"
Rails.logger.info "---------->" send_request
Rails.logger.info result.body
Rails.logger.info invoice_generator_url
Rails.logger.info "---------->"
result
end end
private private
def self.base_request def self.send_request
uri = URI(invoice_generator_url) http = EisBilling::Base.base_request(url: invoice_number_generator_url)
http = Net::HTTP.new(uri.host, uri.port) http.post(invoice_number_generator_url, nil, HEADERS)
headers = {
'Authorization' => 'Bearer foobar',
'Content-Type' => 'application/json',
'Accept' => TOKEN
}
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.post(invoice_generator_url, nil, headers)
end end
def self.invoice_generator_url def self.invoice_number_generator_url
"#{BASE_URL}/api/v1/invoice_generator/invoice_number_generator" "#{BASE_URL}/api/v1/invoice_generator/invoice_number_generator"
end end
end end

View file

@ -1,7 +1,7 @@
module EisBilling module EisBilling
class GetReferenceNumber < EisBilling::Base class GetReferenceNumber < EisBilling::Base
def self.send_request def self.send_request
base_request send_request
end end
private private
@ -12,22 +12,12 @@ module EisBilling
} }
end end
def self.base_request def self.send_request
uri = URI(invoice_generator_url) http = EisBilling::Base.base_request(url: reference_number_generator_url)
http = Net::HTTP.new(uri.host, uri.port) http.post(reference_number_generator_url, obj_data.to_json, HEADERS)
headers = {
'Authorization' => 'Bearer foobar',
'Content-Type' => 'application/json',
'Accept' => TOKEN
}
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.post(invoice_generator_url, obj_data.to_json, headers)
end end
def self.invoice_generator_url def self.reference_number_generator_url
"#{BASE_URL}/api/v1/invoice_generator/reference_number_generator" "#{BASE_URL}/api/v1/invoice_generator/reference_number_generator"
end end
end end

View file

@ -1,10 +1,10 @@
module EisBilling module EisBilling
class SendDataToDirecto < EisBilling::Base class SendDataToDirecto < EisBilling::Base
def self.send_request(object_data:, monthly:, dry:) def self.send_request(object_data:, monthly:, dry:)
base_request(object_data: object_data, monthly: monthly, dry: dry) send_info(object_data: object_data, monthly: monthly, dry: dry)
end end
def self.base_request(object_data:, monthly:, dry:) def self.send_info(object_data:, monthly:, dry:)
prepared_data = { prepared_data = {
invoice_data: object_data, invoice_data: object_data,
monthly: monthly, monthly: monthly,
@ -12,21 +12,11 @@ module EisBilling
initiator: INITIATOR initiator: INITIATOR
} }
uri = URI(invoice_generator_url) http = EisBilling::Base.base_request(url: directo_url)
http = Net::HTTP.new(uri.host, uri.port) http.post(directo_url, prepared_data.to_json, HEADERS)
headers = {
'Authorization' => 'Bearer foobar',
'Content-Type' => 'application/json',
'Accept' => TOKEN
}
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.post(invoice_generator_url, prepared_data.to_json, headers)
end end
def self.invoice_generator_url def self.directo_url
"#{BASE_URL}/api/v1/directo/directo" "#{BASE_URL}/api/v1/directo/directo"
end end
end end

View file

@ -1,10 +1,10 @@
module EisBilling module EisBilling
class SendEInvoice < EisBilling::Base class SendEInvoice < EisBilling::Base
def self.send_request(invoice:, payable:) def self.send_request(invoice:, payable:)
base_request(invoice: invoice, payable: payable) send_info(invoice: invoice, payable: payable)
end end
def self.base_request(invoice:, payable:) def self.send_info(invoice:, payable:)
items = [] items = []
prepared_data = { prepared_data = {
invoice: invoice, invoice: invoice,
@ -33,21 +33,11 @@ module EisBilling
prepared_data[:items] = items prepared_data[:items] = items
uri = URI(invoice_generator_url) http = EisBilling::Base.base_request(url: e_invoice_url)
http = Net::HTTP.new(uri.host, uri.port) http.post(e_invoice_url, prepared_data.to_json, HEADERS)
headers = {
'Authorization' => 'Bearer foobar',
'Content-Type' => 'application/json',
'Accept' => TOKEN
}
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.post(invoice_generator_url, prepared_data.to_json, headers)
end end
def self.invoice_generator_url def self.e_invoice_url
"#{BASE_URL}/api/v1/e_invoice/e_invoice" "#{BASE_URL}/api/v1/e_invoice/e_invoice"
end end
end end

View file

@ -52,9 +52,10 @@ def base_request(url:, json_obj:)
'Accept' => TOKEN 'Accept' => TOKEN
} }
unless Rails.env.development?
http.use_ssl = true http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
http.post(url, json_obj.to_json, headers) http.post(url, json_obj.to_json, headers)
end end