mirror of
https://github.com/internetee/registry.git
synced 2025-07-31 23:16:23 +02:00
added new services to get invoice payment link from billing system, added everypay link to invoice in registrar portal
This commit is contained in:
parent
9aba744494
commit
df48b2137b
6 changed files with 69 additions and 62 deletions
|
@ -14,7 +14,7 @@ class Registrar
|
|||
flash[:notice] = t(:please_pay_the_following_invoice)
|
||||
|
||||
add_invoice_instance = EisBilling::AddDeposits.new(@invoice)
|
||||
add_invoice_instance.some_meth
|
||||
add_invoice_instance.send_invoice
|
||||
|
||||
redirect_to [:registrar, @invoice]
|
||||
else
|
||||
|
|
|
@ -13,7 +13,13 @@ class Registrar
|
|||
end
|
||||
end
|
||||
|
||||
def show; end
|
||||
def show
|
||||
invoice = Invoice.find(params[:id])
|
||||
link_handler = EisBilling::GetInvoiceLink.new(invoice.number)
|
||||
response = link_handler.send_request
|
||||
|
||||
@everypay_link = JSON.parse(response.body)["payment_link"]
|
||||
end
|
||||
|
||||
def cancel
|
||||
@invoice.cancel
|
||||
|
|
|
@ -1,18 +1,13 @@
|
|||
module EisBilling
|
||||
class AddDeposits
|
||||
class AddDeposits < EisBilling::Base
|
||||
attr_reader :invoice
|
||||
|
||||
def initialize(invoice)
|
||||
@invoice = invoice
|
||||
end
|
||||
|
||||
def some_meth
|
||||
result = base_request(url: invoice_generator_url, json_obj: parse_invoice)
|
||||
|
||||
p "++++++++++"
|
||||
p result
|
||||
p result.body
|
||||
p "++++++++++"
|
||||
def send_invoice
|
||||
base_request(json_obj: parse_invoice)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -43,68 +38,21 @@ module EisBilling
|
|||
json_obj
|
||||
end
|
||||
|
||||
# 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')
|
||||
# => "HFW8ADSIrjyD9cbH4H5Rk3MY/ZfhV85IlnGl7YI2CQ==--OvlWMMiTLLotgdfT--/ffejEDaIGFfz7FzzNSlYA=="
|
||||
# irb(main):048:0> decrypted_back = crypt.decrypt_and_verify(encrypted_data)
|
||||
# => "PLEASE CREATE INVOICE"
|
||||
def base_request(url:, json_obj:)
|
||||
uri = URI(url)
|
||||
token = "Bearer WA9UvDmzR9UcE5rLqpWravPQtdS8eDMAIynzGdSOTw==--9ZShwwij3qmLeuMJ--NE96w2PnfpfyIuuNzDJTGw=="
|
||||
def base_request(json_obj:)
|
||||
uri = URI(invoice_generator_url)
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
headers = {
|
||||
'Authorization'=>'Bearer foobar',
|
||||
'Content-Type' =>'application/json',
|
||||
'Accept'=> token
|
||||
'Accept'=> TOKEN
|
||||
}
|
||||
|
||||
res = http.post("http://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator", json_obj.to_json, headers)
|
||||
res = http.post(invoice_generator_url, json_obj.to_json, headers)
|
||||
res
|
||||
end
|
||||
|
||||
def invoice_generator_url
|
||||
"http://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator"
|
||||
"#{BASE_URL}/api/v1/invoice_generator/invoice_generator"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# http://127.0.0.1:3000/api/v1/invoice_generator/invoice_generator?description=this is description¤cy=EUR&invoice_number=1233244&transaction_amount=1000&seller_name=EIS&seller_reg_no=122&seller_iban=34234234234424&seller_bank=LHV&seller_swift=1123344&seller_vat_no=23321&seller_country_code=EE&seller_state=Harjumaa&seller_street=Paldiski mnt&seller_city=Tallinn&seller_zip=23123&seller_phone=+372.342342&seller_url=eis.ee&seller_email=eis@internet.ee&seller_contact_name=Eesti Internet SA&buyer_name=Oleg&buyer_reg_no=324344&buyer_country_code=EE&buyer_state=Harjumaa&buyer_street=Kivila&buyer_city=Tallinn&buyer_zip=13919&buyer_phone=+372.59813318&buyer_url=n-brains.com&buyer_email=oleg.hasjanov@eestiinternet.ee&vat_rate=20&role=private_user&reference_number=22112233&buyer_vat_no=2332323&buyer_iban=4454322423432&invoice_items={}
|
||||
|
||||
|
||||
# :description,
|
||||
# :currency,
|
||||
# :invoice_number,
|
||||
# :transaction_amount, => total
|
||||
# :order_reference, => no need
|
||||
# :seller_name,
|
||||
# :seller_reg_no,
|
||||
# :seller_iban,
|
||||
# :seller_bank,
|
||||
# :seller_swift,
|
||||
# :seller_vat_no,
|
||||
# :seller_country_code,
|
||||
# :seller_state,
|
||||
# :seller_street,
|
||||
# :seller_city,
|
||||
# :seller_zip,
|
||||
# :seller_phone,
|
||||
# :seller_url,
|
||||
# :seller_email,
|
||||
# :seller_contact_name,
|
||||
# :buyer_name,
|
||||
# :buyer_reg_no,
|
||||
# :buyer_country_code,
|
||||
# :buyer_state,
|
||||
# :buyer_street,
|
||||
# :buyer_city,
|
||||
# :buyer_zip,
|
||||
# :buyer_phone,
|
||||
# :buyer_url,
|
||||
# :buyer_email,
|
||||
# :vat_rate,
|
||||
# :items_attributes, => ??
|
||||
# :role, => ???
|
||||
# :buyer_iban, => ??
|
||||
# :buyer_vat_no,
|
||||
# :reference_number, => reference_no
|
||||
# :invoice_items => ?????
|
||||
|
|
15
app/services/eis_billing/base.rb
Normal file
15
app/services/eis_billing/base.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
module EisBilling
|
||||
class Base
|
||||
|
||||
# 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')
|
||||
# => "HFW8ADSIrjyD9cbH4H5Rk3MY/ZfhV85IlnGl7YI2CQ==--OvlWMMiTLLotgdfT--/ffejEDaIGFfz7FzzNSlYA=="
|
||||
# irb(main):048:0> decrypted_back = crypt.decrypt_and_verify(encrypted_data)
|
||||
# => "PLEASE CREATE INVOICE"
|
||||
TOKEN = "Bearer WA9UvDmzR9UcE5rLqpWravPQtdS8eDMAIynzGdSOTw==--9ZShwwij3qmLeuMJ--NE96w2PnfpfyIuuNzDJTGw==".freeze
|
||||
BASE_URL = "http://eis_billing_system:3000".freeze
|
||||
|
||||
protected
|
||||
|
||||
end
|
||||
end
|
32
app/services/eis_billing/get_invoice_link.rb
Normal file
32
app/services/eis_billing/get_invoice_link.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
module EisBilling
|
||||
class GetInvoiceLink < EisBilling::Base
|
||||
attr_reader :invoice_number
|
||||
|
||||
def initialize(invoice_number)
|
||||
@invoice_number = invoice_number
|
||||
end
|
||||
|
||||
def send_request
|
||||
base_request
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def base_request
|
||||
uri = URI(invoice_generator_url)
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
headers = {
|
||||
'Authorization'=>'Bearer foobar',
|
||||
'Content-Type' =>'application/json',
|
||||
'Accept'=> TOKEN
|
||||
}
|
||||
|
||||
res = http.get(invoice_generator_url + "?invoice_number=#{@invoice_number}", headers)
|
||||
res
|
||||
end
|
||||
|
||||
def invoice_generator_url
|
||||
"#{BASE_URL}/api/v1/get_invoice_payment_link/show"
|
||||
end
|
||||
end
|
||||
end
|
|
@ -5,3 +5,9 @@
|
|||
- meth = meth.strip
|
||||
= link_to registrar_payment_with_path(meth, invoice_id: params[:id]), id: meth do
|
||||
= image_tag("#{meth}.png")
|
||||
%hr
|
||||
|
||||
- if @everypay_link.present?
|
||||
= link_to 'Everypay link', @everypay_link, target: :_blank
|
||||
- else
|
||||
= "No everypay link"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue