invoicePendingCharges() 공개 정적인 메소드

Creates an invoice for an account using its pending charges
public static invoicePendingCharges ( $accountCode, $attributes = [], $client = null ) : Recurly_Invoice
리턴 Recurly_Invoice invoice on success
예제 #1
0
 public function testFailedInvoicePendingCharges()
 {
     $this->client->addResponse('POST', '/accounts/abcdef1234567890/invoices', 'invoices/create-422.xml');
     try {
         $invoice = Recurly_Invoice::invoicePendingCharges('abcdef1234567890', $this->client);
         $this->fail("Expected Recurly_ValidationError");
     } catch (Recurly_ValidationError $e) {
         $this->assertEquals($e->errors[0]->symbol, 'will_not_invoice');
     }
 }
 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);
     }
 }
예제 #3
0
// 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 {