diff --git a/app/controllers/invoices_controller.rb b/app/controllers/invoices_controller.rb index 227152ba..daa03537 100644 --- a/app/controllers/invoices_controller.rb +++ b/app/controllers/invoices_controller.rb @@ -65,10 +65,8 @@ def add_credit def pay invoice_number = params[:invoice_number] - reference_no = params[:reference_no] response = Billing::Oneoff.send_invoice(invoice_number: invoice_number.to_s, - customer_url: callback_url, - reference_number: reference_no) + customer_url: callback_url) if response['error'].present? flash.alert = response['error']['message'] diff --git a/app/services/billing/oneoff.rb b/app/services/billing/oneoff.rb index 6c3c14a0..a251cbdb 100644 --- a/app/services/billing/oneoff.rb +++ b/app/services/billing/oneoff.rb @@ -3,13 +3,13 @@ class Oneoff include Billing::Request attr_reader :invoice_number, :customer_url, :reference_number - def initialize(invoice_number:, customer_url:, reference_number:) + def initialize(invoice_number:, customer_url:, reference_number: nil) @invoice_number = invoice_number @customer_url = customer_url @reference_number = reference_number end - def self.send_invoice(invoice_number:, customer_url:, reference_number:) + def self.send_invoice(invoice_number:, customer_url:, reference_number: nil) fetcher = new(invoice_number: invoice_number, customer_url: customer_url, reference_number: reference_number) fetcher.send_it end diff --git a/app/views/invoices/partials/_invoice.html.erb b/app/views/invoices/partials/_invoice.html.erb index 4b7643ef..69bc2525 100644 --- a/app/views/invoices/partials/_invoice.html.erb +++ b/app/views/invoices/partials/_invoice.html.erb @@ -18,7 +18,7 @@ <%= currency(invoice[:total].to_f) %> <% if invoice[:payable] && invoice[:payment_link].present? %> - <%= link_to ''.html_safe, pay_path(invoice_number: invoice[:number], reference_no: invoice[:reference_no]), data: { 'turbo-method': :post } %> + <%= link_to ''.html_safe, pay_path(invoice_number: invoice[:number]), data: { 'turbo-method': :post } %> <% end %> diff --git a/app/views/invoices/show.html.erb b/app/views/invoices/show.html.erb index 3b5e4094..4887a904 100644 --- a/app/views/invoices/show.html.erb +++ b/app/views/invoices/show.html.erb @@ -19,7 +19,7 @@ <% if @invoice[:payable] && @invoice[:payment_link].present? %>
- <%= button_to t(:pay), pay_path(invoice_number: @invoice[:number], reference_no: @invoice[:reference_no]), method: :post, class: 'button button--secondary' %> + <%= button_to t(:pay), pay_path(invoice_number: @invoice[:number]), method: :post, class: 'button button--secondary' %>
<% end %> <% if @invoice[:cancellable] && !@invoice[:monthly_invoice] %>