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 81c902b..306f134 100644 --- a/app/controllers/api/v1/callback_handler/callback_handler_controller.rb +++ b/app/controllers/api/v1/callback_handler/callback_handler_controller.rb @@ -36,10 +36,12 @@ class CallbackHandlerController < ApplicationController param :event_name, String, desc: event_descr def callback - puts '============ CALLBACK' puts params puts '============ CALLBACK' + Rails.logger.info '============ CALLBACK' + Rails.logger.info params + Rails.logger.info '============ CALLBACK' payment_reference = params[:payment_reference] response = EverypayResponse.call(payment_reference) diff --git a/app/controllers/invoice_creators_controller.rb b/app/controllers/invoice_creators_controller.rb index 7b898f3..548fc4e 100644 --- a/app/controllers/invoice_creators_controller.rb +++ b/app/controllers/invoice_creators_controller.rb @@ -1,6 +1,10 @@ class InvoiceCreatorsController < ParentController def index - @invoices = Invoice.where(initiator: 'billing_system').order(created_at: :desc) + @pagy, @invoices = pagy(Invoice.search(params).where(initiator: 'billing_system').order(created_at: :desc), + items: params[:per_page] ||= 25, + link_extra: 'data-turbo-action="advance"') + @min_amount = 0 + @max_amount = 200_000 end def new @@ -25,12 +29,17 @@ def create linkpay_params_mutation = params[:linkpay].merge( invoice_number: @invoice.invoice_number, - transaction_amount: @invoice.transaction_amount, + transaction_amount: @invoice.transaction_amount ) @linkpay = EverypayLinkGenerator.create(params: linkpay_params_mutation) - @invoice.everypay_response = { + @invoice.linkpay_info = { linkpay: @linkpay, + customer_name: params[:linkpay][:customer_name], + customer_email: params[:linkpay][:customer_email], + description: params[:linkpay][:custom_field1], + custom_field2: params[:linkpay][:custom_field2], + invoice_number: @invoice.invoice_number } @invoice.save! diff --git a/app/controllers/invoice_details/linkpay_informations_controller.rb b/app/controllers/invoice_details/linkpay_informations_controller.rb new file mode 100644 index 0000000..ad39215 --- /dev/null +++ b/app/controllers/invoice_details/linkpay_informations_controller.rb @@ -0,0 +1,5 @@ +class InvoiceDetails::LinkpayInformationsController < ParentController + def show + @info = Invoice.find(params[:id])&.linkpay_info + end +end diff --git a/app/services/notify.rb b/app/services/notify.rb index 2d45ea9..e8ac25b 100644 --- a/app/services/notify.rb +++ b/app/services/notify.rb @@ -16,6 +16,14 @@ def self.call(response:) parsed_response = notifier.parse_response(response) + puts '============ parsed_response' + puts parsed_response + puts '============ parsed_response' + + Rails.logger.info '============ parsed_response' + Rails.logger.info parsed_response + Rails.logger.info '============ parsed_response' + order_number = if parsed_response[:order_reference].split(', ').size > 1 parsed_response[:order_reference].split(', ')[0].split(':')[1] else @@ -32,6 +40,7 @@ def self.call(response:) notifier.update_invoice_state(parsed_response:, invoice:) return unless invoice.paid? + return if invoice.billing_system? url = notifier.get_update_payment_url[invoice.initiator.to_sym] return notifier.define_for_deposit(invoice, url) if invoice.auction_deposit_prepayment? diff --git a/app/views/invoice_creators/index.html.erb b/app/views/invoice_creators/index.html.erb index a3567f2..3369923 100644 --- a/app/views/invoice_creators/index.html.erb +++ b/app/views/invoice_creators/index.html.erb @@ -1,29 +1,108 @@
+ Total pages: + <%= @pagy.pages %> +
+ <%= form.number_field :page, + class: 'w-full px-2 py-2 border-2 border-gray-200 rounded-xl hover:border-gray-300 focus:outline-none focus:border-blue-500 transition-colors bg-white w-64' %> +Invoice number | -Status | -transaction_amount | -Linkpay URL | -
---|---|---|---|
<%= invoice.invoice_number %> | -<%= invoice.status %> | -<%= invoice.transaction_amount %> | -<%= invoice.everypay_response["linkpay"] if invoice.everypay_response.present? %> | -
Invoice number | +Status | +transaction_amount | +Linkpay Info | +Everypay Response Info | +
---|---|---|---|---|
<%= invoice.invoice_number %> | +<%= invoice.status %> | +<%= invoice.transaction_amount %> | ++ <%= link_to invoice_details_linkpay_information_path(invoice), class: 'w-6 h-6 p-2 rounded-full bg-blue-300 hover:bg-blue-500 text-black border-gray-300 flex items-center justify-center focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black text-center', data: { turbo_frame: 'modal' } do %> + + <% end %> + | ++ <%= link_to invoice_details_everypay_response_path(invoice), class: 'w-6 h-6 p-2 rounded-full bg-blue-300 hover:bg-blue-500 text-black border-gray-300 flex items-center justify-center focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black text-center', data: { turbo_frame: 'modal' } do %> + + <% end %> + | +
+<%= yield %><%= button_tag "Close", data: { action: "turbo-modal#hideModal" }, type: "button", class: "rounded-lg py-3 px-5 bg-red-600 text-white" %> <% end %> -<% end %> +<% end %> \ No newline at end of file diff --git a/app/views/shared/_navbar.html.erb b/app/views/shared/_navbar.html.erb index 46a0b26..b42cd97 100644 --- a/app/views/shared/_navbar.html.erb +++ b/app/views/shared/_navbar.html.erb @@ -23,7 +23,7 @@ <% end %> <%= link_to invoice_creators_path, class: 'px-6 py-1 flex flex-col md:flex-row md:items-center' do %> - Invoice creator + Invoice creator <% end %> <%= link_to white_codes_path, class: 'px-6 py-1 flex flex-col md:flex-row md:items-center' do %> diff --git a/config/routes.rb b/config/routes.rb index f28f1c0..e105479 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -23,6 +23,7 @@ namespace :invoice_details do resources :payment_references, only: [:show] resources :everypay_response, only: [:show] + resources :linkpay_informations, only: [:show] resources :directo, only: [:show] resources :descriptions, only: [:show] end diff --git a/db/migrate/20231130114315_add_linkpay_info_to_invoices.rb b/db/migrate/20231130114315_add_linkpay_info_to_invoices.rb new file mode 100644 index 0000000..54a6f88 --- /dev/null +++ b/db/migrate/20231130114315_add_linkpay_info_to_invoices.rb @@ -0,0 +1,5 @@ +class AddLinkpayInfoToInvoices < ActiveRecord::Migration[7.0] + def change + add_column :invoices, :linkpay_info, :jsonb, default: {}, null: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 3b96e01..fbb91db 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_09_21_075925) do +ActiveRecord::Schema[7.0].define(version: 2023_11_30_114315) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -65,6 +65,7 @@ t.string "description" t.datetime "sent_at_omniva", precision: nil t.integer "affiliation", default: 0 + t.jsonb "linkpay_info", default: {} t.index ["status"], name: "index_invoices_on_status" end @@ -74,6 +75,7 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "owner" + t.string "email" end create_table "setting_entries", force: :cascade do |t|