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);
 }
Esempio n. 2
0
 public static function findById($id)
 {
     return self::findByIdUsingCredentials(ChargeIO::getCredentials(), $id);
 }
Esempio n. 3
0
 public static function setDebug($debug)
 {
     self::$debug = $debug;
 }
<?php

require_once 'lib/ChargeIO.php';
require dirname(__FILE__) . '/TestCase.php';
ChargeIO::setCredentials(new ChargeIO_Credentials('<public_key>', '<secret_key>'));
ChargeIO::setDebug(true);
Esempio n. 5
0
 public static function create($paymentMethod, $amount, $params = array())
 {
     return self::createUsingCredentials(ChargeIO::getCredentials(), $paymentMethod, $amount, $params);
 }
Esempio n. 6
0
 public static function createOneTimeBank($attributes = array())
 {
     return self::createOneTimeBankUsingCredentials(ChargeIO::getCredentials(), $attributes);
 }
Esempio n. 7
0
 public static function allHolds($params = array())
 {
     return self::allHoldsUsingCredentials(ChargeIO::getCredentials(), $params);
 }
Esempio n. 8
0
 public static function findCurrent()
 {
     return self::findCurrentUsingCredentials(ChargeIO::getCredentials());
 }