Class: WHMCS::Invoice
Overview
WHMCS::Invoice is the class for managing invoices
Class Method Summary collapse
-
.add_billable_item(params = {}) ⇒ Object
Add a new billable item.
-
.add_credit(params = {}) ⇒ Object
Add a credit to client's account.
-
.add_invoice_payment(params = {}) ⇒ Object
Add an invoice payment.
-
.add_transaction(params = {}) ⇒ Object
Add transaction.
-
.capture_payment(params = {}) ⇒ Object
Attempt to capture payment for an invoice.
-
.create_invoice(params = {}) ⇒ Object
Create a new invoice.
-
.get_invoice(params = {}) ⇒ Object
Get an invoice.
-
.get_invoices(params = {}) ⇒ Object
Get invoices.
-
.get_payment_methods ⇒ Object
Get configured payment methods.
-
.update_invoice(params = {}) ⇒ Object
Update an existing invoice.
Methods inherited from Base
Class Method Details
.add_billable_item(params = {}) ⇒ Object
Add a new billable item
Parameters:
- :clientid
- :description
- :amount
- :recur - frequency to recur - 1,2,3,etc...
- :recurcycle - Days, Weeks, Months or Years
- :recurfor - number of times to repeat
- :invoiceaction - noinvoice, nextcron, nextinvoice, duedate, recur
- :duedate - date the invoice should be due
See:
143 144 145 146 |
# File 'lib/whmcs/invoice.rb', line 143 def self.add_billable_item(params = {}) params.merge!(:action => 'addbillableitem') send_request(params) end |
.add_credit(params = {}) ⇒ Object
Add a credit to client's account
Parameters:
- :clientid - the ID of the client the credit is to be added to
- :description - reason for credit being added (stored in admin credit log)
- :amount - the amount to be added
See:
159 160 161 162 |
# File 'lib/whmcs/invoice.rb', line 159 def self.add_credit(params = {}) params.merge!(:action => 'addcredit') send_request(params) end |
.add_invoice_payment(params = {}) ⇒ Object
Add an invoice payment
Parameters:
- :invoiceid - should contact the ID number of the invoice to add the payment to
- :transid - should contain the transaction number for the payment
- :amount - should contact the amount paid, can be left blank to take full amount of invoice
- :fees - optional, if set defines how much fees were involved in the transaction
- :gateway - should contain the gateway used in system name format, eg. paypal, authorize, etc...
- :noemail - set to true to not send an email if the payment marks the invoice paid
- :date - optional, if set defines the date the payment was made
See:
107 108 109 110 |
# File 'lib/whmcs/invoice.rb', line 107 def self.add_invoice_payment(params = {}) params.merge!(:action => 'addinvoicepayment') send_request(params) end |
.add_transaction(params = {}) ⇒ Object
Add transaction
Parameters:
- :userid - Optional Add Transaction to a user
- :invoiceid - Optional Add transaction to a particular invoice
- :description - Description of the transaction
- :amountin - amount to add to the account
- :amountout - if an outgoing enter this
- :fees - transaction fee you were charged
- :paymentmethod - gateway used in WHMCS
- :transid - Transaction ID you wish to assign
- :date - date of transaction (same format as your WHMCS eg DD/MM/YYYY)
See:
181 182 183 |
# File 'lib/whmcs/invoice.rb', line 181 def self.add_transaction(params = {}) send_request(params.merge(:action => 'addtransaction')) end |
.capture_payment(params = {}) ⇒ Object
Attempt to capture payment for an invoice
Parameters:
- :invoiceid - the ID of the invoice the capture is to be attempted for
- :cvv - optionally can be used to pass the cards verification value in the payment request
See:
122 123 124 125 |
# File 'lib/whmcs/invoice.rb', line 122 def self.capture_payment(params = {}) params.merge!(:action => 'capturepayment') send_request(params) end |
.create_invoice(params = {}) ⇒ Object
Create a new invoice
Parameters:
-
:userid - should contain the user id of the client you wish to create the invoice for
-
:date - the date the invoice is created in the format YYYYMMDD
-
:duedate - the date the invoice is due in the format YYYYMMDD
-
:taxrate - the rate of tax that should be charged
-
:paymentmethod - the payment method for the invoice eg. banktransfer
-
:notes - any additional notes the invoice should display to the customer
-
:sendinvoice - set to true to send the "Invoice Created" email to the customer
-
:itemdescription1 - item 1 description
-
:itemamount1 - item 1 amount
-
:itemtaxed1 - set to true if item 1 should be taxed
-
:itemdescription2 - item 2 description
-
:itemamount2 - item 2 amount
-
:itemtaxed2 - set to true if item 2 should be taxed
etc...
See:
60 61 62 63 |
# File 'lib/whmcs/invoice.rb', line 60 def self.create_invoice(params = {}) params.merge!(:action => 'createinvoice') send_request(params) end |
.get_invoice(params = {}) ⇒ Object
Get an invoice
Parameters:
- :invoiceid - should be the invoice id you wish to retrieve
See:
31 32 33 34 |
# File 'lib/whmcs/invoice.rb', line 31 def self.get_invoice(params = {}) params.merge!(:action => 'getinvoice') send_request(params) end |
.get_invoices(params = {}) ⇒ Object
Get invoices
Parameters:
- :userid - the client ID to retrieve invoices for
- :status - the status to filter for, Paid, Unpaid, Cancelled, etc...
- :limitstart - the offset number to start at when returning matches (optional, default 0)
- :limitnum - the number of records to return (optional, default 25)
See:
17 18 19 20 |
# File 'lib/whmcs/invoice.rb', line 17 def self.get_invoices(params = {}) params.merge!(:action => 'getinvoices') send_request(params) end |
.get_payment_methods ⇒ Object
190 191 192 |
# File 'lib/whmcs/invoice.rb', line 190 def self.get_payment_methods send_request(:action => 'getpaymentmethods') end |
.update_invoice(params = {}) ⇒ Object
Update an existing invoice
Parameters:
- :invoiceid - The ID of the invoice to update
- :itemdescription - Array of existing line item descriptions to update. Line ID from database needed
- :itemamount - Array of existing line item amounts to update
- :itemtaxed - Array of existing line items taxed or not
- :newitemdescription - Array of new line item descriptipons to add
- :newitemamount - Array of new line item amounts
- :newitemtaxed - Array of new line items taxed or not
- :date - date of invoice format yyyymmdd
- :duedate - duedate of invoice format yyyymmdd
- :datepaid - date invoice was paid format yyyymmdd
- :status - status of invoice. Unpaid, Paid, Cancelled, Collection, Refunded
- :paymentmethod - payment method of invoice eg paypal, banktransfer
Other than invoiceid, no other fields are required
See:
87 88 89 90 |
# File 'lib/whmcs/invoice.rb', line 87 def self.update_invoice(params = {}) params.merge!(:action => 'updateinvoice') send_request(params) end |