本文整理汇总了PHP中Invoice::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Invoice::getInstance方法的具体用法?PHP Invoice::getInstance怎么用?PHP Invoice::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Invoice
的用法示例。
在下文中一共展示了Invoice::getInstance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Create
public function Create($invoiceid, $gatewayid, $amount, $date = NULL, $comments = '', $userid = NULL)
{
if (!is_numeric($invoiceid) && !is_float($amount)) {
throw new Exception("Invoice ID or amount in wrong format");
}
$inv = Invoice::getInstance();
$invdata = $inv->FetchData($invoiceid);
$time = Time::getInstance();
if ($date == NULL) {
$date = $time->UtoM(time());
}
$this->raw = $this->db->query_insert('Transaction', array('invoiceid' => $invoiceid, 'customerid' => $invdata['accountid'], 'date' => $date, 'amount' => $amount, 'gatewayid' => $gatewayid, 'comments' => $comments));
$inv->Update('status', 'Paid', $invoiceid);
$inv->Update('transactionid', $this->raw, $invoiceid);
$inv->Update('datepaid', $date, $invoiceid);
return $this->raw;
}
示例2: define
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
require_once '../../core.php';
//change to your gateway's name
define('GWNAME', 'othertestgateway');
define('INVOICE', (int) $_REQUEST['inv']);
define('AMOUNT', (int) $_REQUEST['received']);
define('KEY', $_REQUEST['secretkey']);
define('COMMENT', '');
$gm = GatewayModule::getInstance();
$curr = Currency::getInstance();
$service = Service::getInstance();
$invoice = Invoice::getInstance();
$tr = Transaction::getInstance();
//finding ID for this gateway
$gwid = $gm->GetID(GWNAME);
if (!$gwid) {
die("This gateway is not activated and configured to accept payments");
}
$gmdata = $gm->FetchData($gwid);
$invdata = $invoice->FetchData(INVOICE);
$currency = $curr->FetchData($curr->GetID($gmdata['currency'], 'name'));
//$currency = $curr->GetCurrency('',$gmdata['currency']);
$gateway_data = unserialize($gmdata['data']);
if ($invdata['amount'] > AMOUNT * $currency['rate']) {
echo "Received amount is not enough for this invoice";
//send some notifications
exit;
示例3: UserViewInvoice
public static function UserViewInvoice($invid)
{
$xtpl = self::$xtpl;
$invoice = Invoice::getInstance();
$xtpl->assign('FINCURR', 'current');
$xtpl->assign('INVSCURR', 'current');
if (!is_numeric($invid)) {
$xtpl->parse('main.viewinvoice.inverror');
} else {
$invdata = $invoice->FetchData($invid);
if ($invdata['accountid'] != self::$userid) {
$xtpl->parse('main.viewinvoice.invrights');
} else {
$order = Order::getInstance();
$pkg = Package::getInstance();
$orderdata = $order->FetchData($invdata['orderid']);
$pkgdata = $pkg->FetchData($orderdata['productid']);
$xtpl->assign('INV', $invdata);
$xtpl->assign('PKG', $pkgdata);
$xtpl->assign('ORDER', $orderdata);
if ($invdata['status'] == 'Paid') {
$xtpl->parse('main.viewinvoice.invoice.paid');
}
$xtpl->parse('main.viewinvoice.invoice');
}
}
$xtpl->parse('main.viewinvoice');
$xtpl->parse('main');
$xtpl->out('main');
}
示例4: generateLastInv
public function generateLastInv($orderid = '')
{
$time = Time::getInstance();
$inv = Invoice::getInstance();
$pkg = Package::getInstance();
$setting = Settings::getInstance();
if (!is_numeric($orderid) && !is_numeric($this->orderid)) {
$result = array();
$days = $time->add_date($time->UtoM(time()), $setting->Get('system.cron.daystonewinv'));
$this->raw = $this->db->fetch_all_array('SELECT * FROM `Order` WHERE `status` = "Active" AND `nextdue` < "' . $days . '" AND `cycle` > 0');
for ($i = 0; $i < count($this->raw); $i++) {
$invdata = $inv->FetchData($this->raw[$i]['lastinv']);
if ($time->MtoU($invdata['datedue']) < $time->MtoU($this->raw[$i]['nextdue'])) {
//new invoice should be generated
$pkgdata = $pkg->FetchData($this->raw[$i]['productid']);
$nextdue = $time->add_date($this->raw[$i]['nextdue'], '', $this->raw[$i]['cycle']);
$comment = "Order for package " . $pkgdata['name'] . " (" . $this->raw[$i]['nextdue'] . " - " . $nextdue . ")";
$lastinv = $inv->Create($this->raw[$i]['accountid'], $this->raw[$i]['id'], $this->raw[$i]['recuramount'], $this->raw[$i]['nextdue'], 'Unpaid', $comment);
$result[] = array('invoice' => $lastinv, 'order' => $this->raw[$i]['id']);
$this->Update('lastinv', $lastinv, $this->raw[$i]['id']);
}
}
return $result;
} else {
if (!is_numeric($orderid)) {
$orderid = $this->orderid;
}
$orderdata = $this->FetchData($orderid);
$lastinvdata = $inv->FetchData($orderdata['lastinv']);
if ($orderdata['status'] == 'Active' && $orderdata['cycle'] > 0 && $time->MtoU($orderdata['nextdue']) > $time->MtoU($lastinvdata['datedue'])) {
$pkgdata = $pkg->FetchData($orderdata['productid']);
$nextdue = $time->add_date($orderdata['nextdue'], '', $orderdata['cycle']);
$comment = "Order for package " . $pkgdata['name'] . " (" . $orderdata['nextdue'] . " - " . $nextdue . ")";
$lastinv = $inv->Create($orderdata['accountid'], $orderdata['id'], $orderdata['recuramount'], $orderdata['nextdue'], '', $comment);
$this->Update($orderdata['id'], 'lastinv', $lastinv);
}
}
}
示例5: newPayment
public function newPayment($invid)
{
if (!is_numeric($this->invid) && !is_numeric($invid)) {
throw new Exception("Invoice ID is not set or set incorrectly");
} elseif (is_numeric($this->invid) && !is_numeric($invid)) {
$invid = $this->invid;
}
$error = 0;
$sm = ServerModule::getInstance();
$user = User::getInstance();
$order = Order::getInstance();
$invoice = Invoice::getInstance();
$time = Time::getInstance();
$nt = Notification::getInstance();
$invdata = $invoice->FetchData($invid);
$users = $user->GetButch(1, '`id` = "' . $invdata['accountid'] . '"');
$orderdata = $order->FetchData($invdata['orderid']);
$ntarray = array('USER' => $users[0], 'INV' => $invdata, 'ORDER' => $orderdata);
switch ($orderdata['status']) {
case 'Active':
$nt->Send($users, $ntarray, 'usernewpayment');
$order->Update('nextdue', $time->add_date($orderdata['nextdue'], 0, $orderdata['cycle']), $orderdata['id']);
break;
case 'Pending':
//Making all this shit for creating new account; sendmail email with access data
try {
$this->Create($orderdata['id']);
} catch (Exception $e) {
$admins = $user->GetButch('', '`status` = "Admin"');
$nterarray = array('USER' => $users[0], 'INV' => $invdata, 'MESSAGE' => $e->getMessage(), 'DEBUG' => $e);
$nt->Send($admins, $nterarray, 'adminservicesetuperror');
$error = 1;
}
if ($error > 0) {
//we need to refetch order data as we updated accessdata when created new service
$orderdata = $order->FetchData($invdata['orderid']);
$accessdata = unserialize($orderdata['accessdata']);
$order->orderid = $invdata['orderid'];
$sm->id = $order->FindModuleID();
$modulecreatearray = $sm->getArray('Create');
$acdata_to_mail = '';
for ($i = 0; $i < count($modulecreatearray); $i++) {
if (array_key_exists($modulecreatearray[$i]['name'], $accessdata)) {
$acdata_to_mail .= $modulecreatearray[$i]['label'] . ": " . $accessdata[$modulecreatearray[$i]['name']] . "\n";
}
}
$ntarray['ACCESSDATA'] = $acdata_to_mail;
//there email should me sent
$nt->Send($admins, $ntarray, 'usernewservicedetails');
$order->Update('status', 'Active', $invdata['orderid']);
} else {
die("Error");
}
break;
case 'Suspended':
$this->Unsuspend($order->orderid);
$order->Update('', 'status', 'Active');
break;
case 'Terminated':
//there are should be some notification for admin and user about payment for terminated service or money should be returned back to the balance
//$this->Create($order->orderid);
//$order->Update('','status', 'Active');
break;
default:
throw new Exception("Unknown order status!");
}
}