-
Notifications
You must be signed in to change notification settings - Fork 122
Description
I'm finding it difficult to find any examples of how to use the internal classes outlined here. It also seems to be missing WHMCS\Database\Capsule
but has what I'm looking for here (these docs seem all over the place!).
Currently I'm trying to look for a method to create an invoice with the type AddFunds
. There doesn't seem to be any easy way to do this via the API or available methods.
Perhaps I can create a new invoice and use a new WHMCS\Billing\Invoice\Item
class on the WHMCS\Billing\Invoice
class? I can't even find information about the constructors, so these could just be 'dummy' classes for holding information. But again, there is no information available.
E.g. can I create an invoice like this:
$addFundsInvoice = new WHMCS\Billing\Invoice;
// there is no addLine()?
$addFundsLine = new WHMCS\Billing\Invoice\Item;
// ... something?
I've done heavy research online and have been made aware of the methods like createInvoices($userid);
but I feel these might be going away (are they?) because WHMCS seems to be stepping away from using functions and using classes.
This seems like a solution but it also doesn't seem like the safest way to go about it:
$userid = ...;
$amount = ...;
// I think true here = no email?
include_once(WHMCS_ROOT_PATH . "/includes/processinvoices.php");
$invoiceid = createInvoices(userid, true);
Capsule::table("tblinvoiceitems")
->insert([
"userid" => $userid,
"type" => "AddFunds",
"relid" => $invoiceid,
"description" => $_LANG['addfunds'],
"amount" => $amount,
"taxed" => "0",
"duedate" => "now()",
"paymentmethod" => "paypal"
]);
Looking forward to some help here :)