Skip to content

Commit

Permalink
refactor: rename payment link field and add debug logging
Browse files Browse the repository at this point in the history
- Rename oneoff_payment_link to linkpay_url for consistency
- Add debug logging in domain name controllers and invoice status
- Remove unused allowed_origins variable in domain names controller test
- Remove empty registration code controller

This change improves naming consistency for payment URLs and adds
logging to help with troubleshooting domain registration flow.
  • Loading branch information
OlegPhenomenon committed Nov 21, 2024
1 parent 02ebf69 commit bde0fc3
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@ class DomainNamesController < BaseController
before_action :validate_organization_name

def show
puts "params: #{params[:organization_name]}"
name = params[:organization_name]
all_variants = ::BusinessRegistry::DomainNameGeneratorService.generate(name)

puts "all_variants: #{all_variants.inspect}"
available_variants = ::BusinessRegistry::DomainAvailabilityCheckerService.filter_available(all_variants)


puts "available_variants: #{available_variants.inspect}"

render json: { variants: available_variants }, status: :ok
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def create
if result.status_code_success
render_success({
message: "Domains are in pending status. Need to pay for domains.",
oneoff_payment_link: result.oneoff_payment_link,
linkpay_url: result.linkpay_url,
invoice_number: result.invoice_number,
user_unique_id: result.user_unique_id,
available_domains: ReserveDomainInvoice.filter_available_domains(@domain_names)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class LongReserveDomainsStatusController < BaseController
def show
result = @reserved_domain_invoice.invoice_state

puts "result: #{result.inspect}"

if result.paid?
@reserved_domain_invoice.create_reserved_domains
render json: { status: 'paid', message: result.message, reserved_domains: @reserved_domain_invoice.build_reserved_domains_output }
Expand All @@ -19,7 +21,7 @@ def show

def set_reserved_domain_invoice
@reserved_domain_invoice = ReserveDomainInvoice.find_by(invoice_number: params[:invoice_number], metainfo: params[:user_unique_id])

puts "reserved_domain_invoice: #{@reserved_domain_invoice.inspect}"
raise ActiveRecord::RecordNotFound, 'Reserved domain invoice not found' if @reserved_domain_invoice.nil?
end
end
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions app/models/reserve_domain_invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class InvoiceStruct < Struct.new(:total, :number, :buyer_name, :buyer_email,
keyword_init: true)
end

class InvoiceResponseStruct < Struct.new(:status_code_success, :oneoff_payment_link, :invoice_number, :details, :user_unique_id,
class InvoiceResponseStruct < Struct.new(:status_code_success, :linkpay_url, :invoice_number, :details, :user_unique_id,
keyword_init: true)
end

Expand Down Expand Up @@ -152,7 +152,7 @@ def build_response(result, invoice_number, user_unique_id)

InvoiceResponseStruct.new(
status_code_success: success_status?(result.code),
oneoff_payment_link: parsed_result['everypay_link'],
linkpay_url: parsed_result['everypay_link'],
invoice_number: invoice_number,
user_unique_id: user_unique_id,
details: parsed_result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def call
http = EisBilling::Base.base_request
res = http.get(reserved_domain_invoice_statuses_url, EisBilling::Base.headers)

puts '---'
puts "res: #{res.inspect}"
puts '---'

wrap_result(res)
end

Expand Down
Binary file modified ettevotja_rekvisiidid__lihtandmed.csv.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

class Api::V1::BusinessRegistry::DomainNamesControllerTest < ActionDispatch::IntegrationTest
setup do
@allowed_origins = ['http://example.com', 'https://test.com']
@valid_ip = '127.0.0.1'
ENV['auction_api_allowed_ips'] = @valid_ip
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def setup
test "should create long reserve domains with valid parameters" do
mock_result = OpenStruct.new(
status_code_success: true,
oneoff_payment_link: "http://payment.test",
linkpay_url: "http://payment.test",
invoice_number: "123456"
)

Expand All @@ -52,7 +52,7 @@ def setup
json_response = JSON.parse(response.body)

assert_equal "Domains are in pending status. Need to pay for domains.", json_response['message']
assert_equal "http://payment.test", json_response['oneoff_payment_link']
assert_equal "http://payment.test", json_response['linkpay_url']
assert_equal "123456", json_response['invoice_number']
end
end
Expand Down Expand Up @@ -142,13 +142,13 @@ def setup

assert_response :created
json_response = JSON.parse(response.body)
assert_not_nil json_response['oneoff_payment_link']
assert_not_nil json_response['linkpay_url']
end

test "should accept request with valid URLs" do
mock_result = OpenStruct.new(
status_code_success: true,
oneoff_payment_link: "http://payment.test",
linkpay_url: "http://payment.test",
invoice_number: "123456"
)

Expand All @@ -166,7 +166,7 @@ def setup

assert_response :created
json_response = JSON.parse(response.body)
assert_not_nil json_response['oneoff_payment_link']
assert_not_nil json_response['linkpay_url']
end
end

Expand Down Expand Up @@ -206,7 +206,7 @@ def setup
test "should return available domains in response" do
mock_result = OpenStruct.new(
status_code_success: true,
oneoff_payment_link: "http://payment.test",
linkpay_url: "http://payment.test",
invoice_number: "123456",
user_unique_id: "user123"
)
Expand Down

0 comments on commit bde0fc3

Please sign in to comment.