if (!empty($invoices) && property_exists($invoices, 'invoices')) { echo '<ul>' . "\n"; foreach ($invoices->invoices as $invoice) { echo ' <li>'; echo '<b>Id:</b> ' . $invoice->id; echo ' (created at ' . $invoice->created_at . ')'; echo '</li>' . "\n"; } echo '</ul>' . "\n"; } //example search criteria array $criteria = array('merchant_id' => MERCHANT_ID, 'start_time' => '2014-03-14T00:00:00.000Z', 'per_page' => 10); echo '<hr/>' . "\n"; echo '<h3 style="color:blue">Recent Invoices</h3>'; //search invoices with criteria $invoices = GoCoin::searchInvoices($token, $criteria); if (!empty($invoices) && property_exists($invoices, 'invoices')) { foreach ($invoices->invoices as $invoice) { showObject($invoice); echo '<hr/>' . "\n"; } } echo '<h3 style="color:blue">Specific Invoices</h3>'; //get a specific invoice $specific = GoCoin::getInvoice($token, INVOICE_ID); showObject($invoice); $NEW_INVOICE = FALSE; if ($NEW_INVOICE) { echo '<hr/>' . "\n"; echo '<h3 style="color:blue">New Invoice</h3>'; //create a new invoice
public function testGetInvoices() { if (!$this->doTest(__FUNCTION__)) { return; } //perform assertion $this->assertEquals(GoCoin::getApiMode(), 'test'); $this->assertNotEmpty(TOKEN); //search invoices with no criteria, returns all of em $invoices = GoCoin::searchInvoices(TOKEN); $this->assertEquals($invoices->status, '200'); echo '[DEBUG]: Found ' . $invoices->paging_info->total . ' total invoices' . "\n"; echo '[DEBUG]: Currently have ' . sizeof($invoices->invoices) . ' invoices' . "\n"; //example search criteria array $criteria = array('merchant_id' => MERCHANT_ID, 'start_time' => '2014-03-14T00:00:00.000Z', 'per_page' => 10); //search invoices with criteria $invoices = GoCoin::searchInvoices(TOKEN, $criteria); echo '[DEBUG]: Found ' . $invoices->paging_info->total . ' total recent invoices' . "\n"; echo '[DEBUG]: Currently have ' . sizeof($invoices->invoices) . ' recent invoices' . "\n"; //get a specific invoice $specific = GoCoin::getInvoice(TOKEN, INVOICE_ID); $this->assertEquals($specific->id, INVOICE_ID); echo '[DEBUG]: SUCCESS: ' . $specific->id . "\n"; }