Skip to content

Commit

Permalink
Merge pull request #98 from internetee/94-fix-invoice-payment-error
Browse files Browse the repository at this point in the history
Removed reference no param from invoice payment
  • Loading branch information
vohmar authored Jun 7, 2023
2 parents 4390ef6 + 9ee78c1 commit 9776768
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions app/controllers/invoices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
4 changes: 2 additions & 2 deletions app/services/billing/oneoff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/invoices/partials/_invoice.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<td><%= currency(invoice[:total].to_f) %></td>
<td class="table--action">
<% if invoice[:payable] && invoice[:payment_link].present? %>
<%= link_to '<i class="fas fa-credit-card"></i>'.html_safe, pay_path(invoice_number: invoice[:number], reference_no: invoice[:reference_no]), data: { 'turbo-method': :post } %>
<%= link_to '<i class="fas fa-credit-card"></i>'.html_safe, pay_path(invoice_number: invoice[:number]), data: { 'turbo-method': :post } %>
<% end %>
</td>
<td class="table--action">
Expand Down
2 changes: 1 addition & 1 deletion app/views/invoices/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</div>
<% if @invoice[:payable] && @invoice[:payment_link].present? %>
<div class="col-xs-auto">
<%= 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' %>
</div>
<% end %>
<% if @invoice[:cancellable] && !@invoice[:monthly_invoice] %>
Expand Down

0 comments on commit 9776768

Please sign in to comment.