-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add status and update callback URL for domain reservations
Add status tracking and update callback handling for domain reservations: - Add status enum to ReserveDomainInvoice (pending, paid, cancelled, failed) - Add status column to reserve_domain_invoices table with default 'pending' - Update ONE_OFF_CUSTOMER_URL to include callback path - Add callback route for EIS billing system - Update database structure for new status column This change enables tracking reservation payment status and proper callback handling for the business registry domain reservation process.
- Loading branch information
1 parent
02fec75
commit 815d627
Showing
6 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
app/controllers/eis_billing/business_registry_callback_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module EisBilling | ||
class BusinessRegistryCallbackController < ApplicationController | ||
skip_authorization_check | ||
|
||
def callback | ||
|
||
result = EisBilling::SendCallbackService.call(reference_number: params[:payment_reference]) | ||
|
||
invoice_number = params[:order_reference] | ||
|
||
puts '----' | ||
puts result.body | ||
puts result.code | ||
puts invoice_number | ||
puts '----' | ||
|
||
if result.code == '200' | ||
reserve_domain_invoice = ReserveDomainInvoice.find_by(number: invoice_number) | ||
filtered_domains = BusinessRegistry::DomainAvailabilityCheckerService.filter_available(reserve_domain_invoice.domain_names) | ||
|
||
reserved_domains = [] | ||
|
||
# TODO: | ||
# - create reservied domains | ||
# - somehow bind them to the current invoice, maybe need to add some field there | ||
# - find invoices where are the same domains | ||
|
||
filtered_domains.each do |domain| | ||
reserved_domains << ReservedDomain.create(name: domain) | ||
end | ||
|
||
reserve_domain_invoice.paid! | ||
|
||
pending_invoices = ReserveDomainInvoice.pending.where('domain_names && ARRAY[?]::varchar[]', reserve_domain_invoice.domain_names) | ||
|
||
# - cancel them or recreate and change the price ?!?! | ||
|
||
|
||
render status: :ok, json: { message: 'Callback received' } | ||
else | ||
render status: :internal_server_error, json: { message: 'Callback failed' } | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module EisBilling | ||
class SendCallbackService < EisBilling::Base | ||
|
||
attr_reader :reference_number | ||
|
||
def initialize(reference_number:) | ||
@reference_number = reference_number | ||
end | ||
|
||
def self.call(reference_number:) | ||
new(reference_number: reference_number).call | ||
end | ||
|
||
def call | ||
send_request | ||
end | ||
|
||
private | ||
|
||
def send_request | ||
http = EisBilling::Base.base_request | ||
http.get(billing_callback_url) | ||
end | ||
|
||
def billing_callback_url | ||
"/api/v1/callback_handler/callback?payment_reference=#{reference_number}" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters