当前位置: 首页>>代码示例>>PHP>>正文


PHP invoice::autoApproveInvoice方法代码示例

本文整理汇总了PHP中invoice::autoApproveInvoice方法的典型用法代码示例。如果您正苦于以下问题:PHP invoice::autoApproveInvoice方法的具体用法?PHP invoice::autoApproveInvoice怎么用?PHP invoice::autoApproveInvoice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在invoice的用法示例。


在下文中一共展示了invoice::autoApproveInvoice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postback


//.........这里部分代码省略.........
         if ($result === false) {
             $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
         }
         $actual_billed_currency_id = $result->fields['id'];
         if (is_string($result->fields["convert_array"])) {
             $convert = unserialize($result->fields["convert_array"]);
         } else {
             $convert = false;
         }
         $this->format_currency[$actual_billed_currency_id] = array('symbol' => $result->fields["symbol"], 'convert' => $convert, 'iso' => $result->fields["three_digit"]);
         if ($result->RecordCount() == 0 || $actual_billed_currency_id == $billed_currency_id) {
             # same as billed_currency_id
             $this->billed_amt = $arr['amount'] + $billed_amt;
             $this->actual_billed_amt = $arr['amount'] + $billed_amt;
             $this->actual_billed_currency_id = $actual_billed_currency_id;
         } else {
             # Get the billed currency id currency info:
             $q = "SELECT * FROM " . AGILE_DB_PREFIX . "currency WHERE\n\t\t        \t\t\tid   \t= " . $db->qstr($billed_currency_id) . " AND\n\t\t        \t\t\tsite_id = " . $db->qstr(DEFAULT_SITE);
             $result = $db->Execute($q);
             if ($result === false) {
                 $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
             }
             $this->format_currency[$billed_currency_id] = array('symbol' => $result->fields["symbol"], 'convert' => unserialize($result->fields["convert_array"]), 'iso' => $result->fields["three_digit"]);
             # Convert the invoice amount to the actual billed currency amount
             $due_amount = $invoice->fields['total_amt'] - $invoice->fields['billed_amt'];
             $conversion = $this->format_currency[$billed_currency_id]["convert"][$actual_billed_currency_id]["rate"];
             $this->billed_amt = $billed_amt + ($arr['amount'] /= $conversion);
             $this->actual_billed_amt = $actual_billed_amt + $arr['amount'];
             $this->actual_billed_currency_id = $actual_billed_currency_id;
         }
     }
     # Check for any subscription_id
     if (!empty($arr['subscription_id'])) {
         $this->subscription_id = trim($arr['subscription_id']);
     } else {
         $this->subscription_id = trim($invoice->fields['checkout_plugin_data']);
     }
     # Check for the checkout_id
     if (!empty($arr['checkout_id'])) {
         $this->checkout_id = $arr['checkout_id'];
     } else {
         $this->checkout_id = $invoice->fields['checkout_plugin_id'];
     }
     # Check for the billing status:
     if ($this->billed_amt >= $invoice->fields['total_amt']) {
         $this->billing_status = '1';
     } else {
         $this->billing_status = '0';
     }
     # Check if this transaction_id has already been processed:
     $q = "SELECT id FROM " . AGILE_DB_PREFIX . "invoice_memo WHERE\n        \t\t\tinvoice_id \t= " . $db->qstr($invoice_id) . " AND\n        \t\t\ttype\t\t= " . $db->qstr('postback') . " AND\n        \t\t\tmemo\t\t= " . $db->qstr($arr['transaction_id']) . " AND\n        \t\t\tsite_id \t= " . $db->qstr(DEFAULT_SITE);
     $memo = $db->Execute($q);
     if ($memo === false) {
         $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
     }
     if ($memo->RecordCount() > 0) {
         # duplicate post:
         $C_debug->error('Duplicate Postback', 'checkout.inc.php :: postback()', "Duplicate postback for invoice {$arr['invoice_id']} & transaction id {$arr['transaction_id']}");
     } else {
         # Create the invoice memo:
         $memo_id = $db->GenID(AGILE_DB_PREFIX . 'invoice_memo_id');
         $q = "INSERT INTO\n\t        \t\t\t" . AGILE_DB_PREFIX . "invoice_memo \n\t        \t      SET\n\t        \t\t\tid \t\t\t\t\t= " . $db->qstr($memo_id) . ",\n\t        \t\t\tsite_id \t\t\t= " . $db->qstr(DEFAULT_SITE) . ",\n\t        \t\t\tdate_orig \t\t\t= " . $db->qstr(time()) . ", \n\t        \t\t\tinvoice_id\t \t\t= " . $db->qstr($invoice_id) . ", \n\t        \t\t\taccount_id\t\t\t= " . $db->qstr(0) . ", \n\t        \t\t\ttype\t\t\t\t= " . $db->qstr('postback') . ", \n\t        \t\t\tmemo\t\t\t\t= " . $db->qstr($arr['transaction_id']);
         $memosql = $db->Execute($q);
         if ($memosql === false) {
             $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
         }
         # Update the invoice billing info:
         $q = "UPDATE\n\t        \t\t\t" . AGILE_DB_PREFIX . "invoice \n\t        \t      SET\n\t        \t\t\tdate_last \t\t\t= " . $db->qstr(time()) . ", \n\t        \t\t\tbilling_status \t\t= " . $db->qstr($this->billing_status) . ", \n\t        \t\t\tcheckout_plugin_id\t= " . $db->qstr($this->checkout_id) . ", \n\t        \t\t\tcheckout_plugin_data = " . $db->qstr($this->subscription_id) . ", \n\t        \t\t\tbilled_amt\t\t\t= " . $db->qstr($this->billed_amt) . ", \n\t        \t\t\tactual_billed_amt\t= " . $db->qstr($this->actual_billed_amt) . ", \n\t        \t\t\tactual_billed_currency_id = " . $db->qstr($this->actual_billed_currency_id) . "\n\t        \t\t   WHERE\n\t        \t\t\tid \t\t\t= " . $db->qstr($invoice_id) . " AND\n\t        \t\t\tsite_id \t= " . $db->qstr(DEFAULT_SITE);
         $memosql = $db->Execute($q);
         if ($memosql === false) {
             $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
         }
         # Update the invoice approval status
         $VAR['id'] = $invoice_id;
         include_once PATH_MODULES . 'invoice/invoice.inc.php';
         $inv = new invoice();
         if (!$arr['status']) {
             # void
             $inv->voidInvoice($VAR);
             # create a record of the viod in an invoice memo:
             $memo_id = $db->GenID(AGILE_DB_PREFIX . 'invoice_memo_id');
             $q = "INSERT INTO\n\t\t        \t\t\t" . AGILE_DB_PREFIX . "invoice_memo \n\t\t        \t      SET\n\t\t        \t\t\tid \t\t\t\t\t= " . $db->qstr($memo_id) . ",\n\t\t        \t\t\tsite_id \t\t\t= " . $db->qstr(DEFAULT_SITE) . ",\n\t\t        \t\t\tdate_orig \t\t\t= " . $db->qstr(time()) . ", \n\t\t        \t\t\tinvoice_id\t \t\t= " . $db->qstr($invoice_id) . ", \n\t\t        \t\t\taccount_id\t\t\t= " . $db->qstr(0) . ", \n\t\t        \t\t\ttype\t\t\t\t= " . $db->qstr('void') . ", \n\t\t        \t\t\tmemo\t\t\t\t= " . $db->qstr("Voided due to postback: " . $arr['transaction_id']);
             $rsql = $db->Execute($q);
             if ($rsql === false) {
                 $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
             }
         } else {
             # approve
             $inv->autoApproveInvoice($invoice_id);
             # User invoice payment confirmation
             include_once PATH_MODULES . 'email_template/email_template.inc.php';
             $email = new email_template();
             $email->send('invoice_paid_user', $invoice->fields['account_id'], $invoice_id, DEFAULT_CURRENCY, '');
             # Admin alert of payment processed
             $email = new email_template();
             $email->send('admin->invoice_paid_admin', $invoice->fields['account_id'], $invoice_id, DEFAULT_CURRENCY, '');
         }
     }
     return true;
 }
开发者ID:hbustun,项目名称:agilebill,代码行数:101,代码来源:checkout.inc.php


注:本文中的invoice::autoApproveInvoice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。