public function testRecurringFromCharge() { $m = ChargeIO_Merchant::findCurrent(); $accounts = $m->merchantAccounts(); $account = reset($accounts); // Create a recurring charge from a new charge with a schedule $card = $this->newCard(); $charge = ChargeIO_Charge::create($card, 10000, array('account_id' => $account->id, 'recur' => array('interval_unit' => 'WEEK', 'interval_delay' => 1))); $this->assertNotNull($charge); $this->assertEquals('AUTHORIZED', $charge->status); $this->assertNotNull($charge->recurring_charge_id); $this->assertNotNull($charge->recurring_charge_occurrence_id); // Retrieve occurrences -- should contain the initial paid occurrence associated with the charge and the next pending occurrence $rc = ChargeIO_RecurringCharge::findById($charge->recurring_charge_id); $this->assertNotNull($rc); $occs = $rc->occurrences(); $this->assertEquals(2, $occs->getTotalEntries()); $this->assertEquals('PENDING', $occs[0]->status); $this->assertEquals('PAID', $occs[1]->status); $this->assertEquals(1, count($occs[1]->transactions)); $this->assertEquals($charge->id, $occs[1]->transactions[0]['id']); $transaction_id = $occs[1]->transactions[sizeof($occs[1]->transactions) - 1]['id']; $this->assertNotNull($transaction_id); $c = new ChargeIO_Charge($occs[1]->transactions[0], new ChargeIO_Connection(ChargeIO::getCredentials())); $this->assertNotNull($c); $this->assertEquals($charge->id, $c->id); $r = $c->refund(10); $this->assertNotNull($r); $this->assertNotNull($r->id); }
public function testCurrentMerchant() { $m = ChargeIO_Merchant::findCurrent(); $this->assertNotNull($m); }