From 3869db4200586dccdebcb2c844456022bc94ca69 Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Thu, 21 Nov 2024 15:17:03 +0200 Subject: [PATCH] added unique user id handler --- .DS_Store | Bin 10244 -> 10244 bytes .../callback_handler_controller.rb | 7 ++++++- ...ved_domains_invoice_statuses_controller.rb | 6 +++++- app/services/invoice_instance_generator.rb | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.DS_Store b/.DS_Store index b15a4db512766c53ac354f69e0e2eb9bbc6e75cd..21fefacae3d134eaf6727acfb126aa4b72bba5fe 100644 GIT binary patch delta 85 zcmZn(XbITxN`i&?KzhdHcM@XuW@`U`$>$$)WME)mW+-9EWhltaPjN}g$xi}`aA3+7 XWEch~=jRpxWf@p?0yaBK9^?Z6%U~Js delta 85 zcmZn(XbITxN`i%PLd@~W??IX|}mD9ga4TCmw!@*p1oMK2s` diff --git a/app/controllers/api/v1/callback_handler/callback_handler_controller.rb b/app/controllers/api/v1/callback_handler/callback_handler_controller.rb index 8d73937..d7a21b7 100644 --- a/app/controllers/api/v1/callback_handler/callback_handler_controller.rb +++ b/app/controllers/api/v1/callback_handler/callback_handler_controller.rb @@ -38,9 +38,14 @@ class CallbackHandlerController < ApplicationController def callback payment_reference = params[:payment_reference] response = EverypayResponse.call(payment_reference) + + puts '====' + p response + puts '====' + result = Notify.call(response: response) - render status: :ok, json: { message: result } + render status: :ok, json: { message: result, user_unique_id: response['linkpay_customer_data']['custom_field_1'] } end private diff --git a/app/controllers/api/v1/invoice/reserved_domains_invoice_statuses_controller.rb b/app/controllers/api/v1/invoice/reserved_domains_invoice_statuses_controller.rb index 0a5767f..17b7075 100644 --- a/app/controllers/api/v1/invoice/reserved_domains_invoice_statuses_controller.rb +++ b/app/controllers/api/v1/invoice/reserved_domains_invoice_statuses_controller.rb @@ -25,7 +25,11 @@ def show private def set_invoice - @invoice = ::Invoice.find_by(invoice_number: params[:invoice_number]) + user_unique_id = params[:user_unique_id] + invoice_number = params[:invoice_number] + description_pattern = "%User unique id: #{user_unique_id}%" + @invoice = ::Invoice.where('invoice_number = ? AND description LIKE ?', invoice_number, + description_pattern).first raise ActiveRecord::RecordNotFound, 'Invoice not found' if @invoice.nil? end diff --git a/app/services/invoice_instance_generator.rb b/app/services/invoice_instance_generator.rb index 116c779..5b1924c 100644 --- a/app/services/invoice_instance_generator.rb +++ b/app/services/invoice_instance_generator.rb @@ -4,7 +4,7 @@ class InvoiceInstanceGenerator def self.create(params:) description = if params[:reserved_domain_names].present? - "Reserved domain names: #{params[:reserved_domain_names].join(', ')}" + "Reserved domain names: #{params[:reserved_domain_names].join(', ')}; User unique id: #{params[:custom_field1]}" else params.fetch(:custom_field1, 'reload balance').to_s end