Inheritance: extends Recurly_Resource
 protected function uri()
 {
     if (!empty($this->_href)) {
         return $this->getHref();
     } else {
         if (!empty($this->invoice_number)) {
             return Recurly_Invoice::uriForInvoice($this->invoice_number);
         } else {
             throw new Recurly_Error("Invoice number not specified");
         }
     }
 }
 public function ProcessDailyInvoices($id)
 {
     $verificationGuid = 'da68e4ab-dadd-4b15-94ef-a90be9fd7095';
     if ($id === $verificationGuid) {
         log_message('debug', 'Daily Invoices: Start');
         $screenOutput = "<h3>Daily Invoicing</h3>";
         try {
             $this->load->model("usermodel");
             $userList = $this->usermodel->getUsers();
             log_message('debug', 'Daily Invoices: Found ' . count($userList) . ' users');
             $screenOutput .= 'Daily Invoices: Found ' . count($userList) . ' users<br/><br/>';
             foreach ($userList as $user) {
                 $account = Recurly_Account::get($user->id);
                 //if ($user->email_address === "*****@*****.**") {
                 //	$account->chargeAccount(12.34, 'Charging $12.34 to account from unittest');
                 //}
                 if (isset($account)) {
                     $invoice = Recurly_Invoice::invoicePendingCharges($account->account_code);
                     if (isset($invoice)) {
                         $screenOutput .= 'Invoiced account: Name = ' . $user->first_name . ' ' . $user->last_name . ', Account Code = ' . $user->id . '<br/>';
                         log_message('debug', 'Daily Invoices: Invoiced user. Name = ' . $user->first_name . ' ' . $user->last_name . ', Account Code = ' . $user->id);
                     } else {
                         $screenOutput .= 'No charges for account: Name = ' . $user->first_name . ' ' . $user->last_name . ', Account Code = ' . $user->id . '<br/>';
                     }
                 } else {
                     $screenOutput .= 'No Recurly account found for ' . $user->first_name . ' ' . $user->last_name . ', Account Code = ' . $user->id . '<br/>';
                 }
             }
         } catch (Exception $e) {
             $screenOutput .= 'Error occurred: Reason: ' + $e->getMessage() . '<br/>';
             log_message('error', 'Daily Invoices: Failed. Reason: ' + $e->getMessage());
         }
         $screenOutput .= '<br/>Invoicing complete';
         log_message('debug', 'Daily Invo ices: Finished');
         $to = EMAIL_G_ADMIN;
         $subject = "[GRIND INVOICING REPORT]";
         $body = $screenOutput;
         $headers = "From: " . EMAIL_G_ADMIN . "\r\n" . "Reply-To: " . EMAIL_G_ADMIN . "\r\n" . "X-Mailer: PHP/" . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=ISO-8859-1\r\n";
         mail($to, $subject, $body, $headers);
         echo $screenOutput;
     } else {
         echo 'Invalid calling entity';
         log_message('error', 'Daily Invoices: Cron job is passing the wrong id parameter value. It should be ' . $verificationGuid);
     }
 }
 public function testGetInvoicePdf()
 {
     $result = Recurly_Invoice::getInvoicePdf('abcdef1234567890', 'en-GB', $this->client);
     $this->assertEquals(array('/invoices/abcdef1234567890', 'en-GB'), $result);
 }
 /**
  * Retrieve the PDF version of this invoice
  */
 public function getPdf($locale = null)
 {
     return Recurly_Invoice::getInvoicePdf($this->invoice_number, $locale, $this->_client);
 }
Beispiel #5
0
 protected function uri() {
   $invoiceNumberWithPrefix = $this->invoiceNumberWithPrefix();
   if (!empty($this->_href))
     return $this->getHref();
   else if (!empty($invoiceNumberWithPrefix))
     return Recurly_Invoice::uriForInvoice($invoiceNumberWithPrefix);
   else
     throw new Recurly_Error("Invoice number not specified");
 }
 public function testRefund()
 {
     $this->client->addResponse('POST', 'https://api.recurly.com/v2/invoices/1001/refund', 'invoices/refund-201.xml');
     $invoice = Recurly_Invoice::get('1001', $this->client);
     $line_items = $invoice->line_items;
     $adjustment_map = function ($line_item) {
         return $line_item->toRefundAttributes();
     };
     $adjustments = array_map($adjustment_map, $line_items);
     $refund_invoice = $invoice->refund($adjustments);
     $this->assertEquals($refund_invoice->subtotal_in_cents, -1000);
 }
// invoicing configuration
$include_monthly = TRUE;
$no_charges = "";
$charges = "";
$msg = "";
// begin routine
error_log("Starting Daily Invoice Routine", 0);
$sql = "select * from subscription_sync;";
$results = mysql_query($sql);
// insert db query here
try {
    while ($row = mysql_fetch_assoc($results)) {
        if ($include_monthly == TRUE || $row["plan_code"] == "daily") {
            try {
                $account = Recurly_Account::get($row["user_id"]);
                $invoice = Recurly_Invoice::invoicePendingCharges($account->account_code);
                if (isset($invoice)) {
                    $m = "Invoice created for member id: " . $row["user_id"] . "\n";
                    $charges .= $m;
                    // error_log($m,0);
                } else {
                    $m = "no charges for member id: " . $row["user_id"] . "\n";
                    $no_charges .= $m;
                    // error_log($m,0);
                }
                // end invoice
            } catch (Recurly_Error $e) {
                error_log("exception: " . $e->getMessage() . "\n", 0);
                //skip monthly user or account not found
            }
        } else {