Process payments: Create new invoice by transaction to allow direct top ups

This commit is contained in:
Karl Erik Õunapuu 2020-09-07 16:58:27 +03:00
parent 39a21cb790
commit be960457e6
No known key found for this signature in database
GPG key ID: C9DD647298A34764
4 changed files with 23 additions and 6 deletions

View file

@ -31,12 +31,18 @@ class BankTransaction < ApplicationRecord
@registrar ||= Invoice.find_by(reference_no: parsed_ref_number)&.buyer
end
def autobindable?
return false if binded?
return false unless registrar
return false unless invoice
return false unless invoice.payable?
true
end
# For successful binding, reference number, invoice id and sum must match with the invoice
def autobind_invoice(manual: false)
return if binded?
return unless registrar
return unless invoice
return unless invoice.payable?
return unless autobindable?
channel = if manual
'admin_payment'