Skip to content

Commit

Permalink
Fix broken retrieve method
Browse files Browse the repository at this point in the history
  • Loading branch information
gdb committed Jun 2, 2011
1 parent 1aae623 commit ece7221
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/stripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ protected function ident() {
return array($this['id']);
}

public static function retrieve($id, $apiKey=null) {
$instance = new self($id, $apiKey);
protected static function scopedRetrieve($class, $id, $apiKey=null) {
$instance = new $class($id, $apiKey);
$instance->refresh();
return $instance;
}
Expand Down Expand Up @@ -512,6 +512,11 @@ public static function constructFrom($values, $apiKey=null) {
return self::scopedConstructFrom($class, $values, $apiKey);
}

public static function retrieve($id, $apiKey=null) {
$class = get_class();
return self::scopedRetrieve($class, $id, $apiKey);
}

public static function all($params=null, $apiKey=null) {
$class = get_class();
return self::scopedAll($class, $params, $apiKey);
Expand All @@ -537,6 +542,11 @@ public static function constructFrom($values, $apiKey=null) {
return self::scopedConstructFrom($class, $values, $apiKey);
}

public static function retrieve($id, $apiKey=null) {
$class = get_class();
return self::scopedRetrieve($class, $id, $apiKey);
}

public static function all($params=null, $apiKey=null) {
$class = get_class();
return self::scopedAll($class, $params, $apiKey);
Expand Down Expand Up @@ -612,6 +622,11 @@ public static function constructFrom($values, $apiKey=null) {
return self::scopedConstructFrom($class, $values, $apiKey);
}

public static function retrieve($id, $apiKey=null) {
$class = get_class();
return self::scopedRetrieve($class, $id, $apiKey);
}

public static function all($params=null, $apiKey=null) {
$class = get_class();
return self::scopedAll($class, $params, $apiKey);
Expand All @@ -631,6 +646,11 @@ public static function constructFrom($values, $apiKey=null) {
return self::scopedConstructFrom($class, $values, $apiKey);
}

public static function retrieve($id, $apiKey=null) {
$class = get_class();
return self::scopedRetrieve($class, $id, $apiKey);
}

public static function all($params=null, $apiKey=null) {
$class = get_class();
return self::scopedAll($class, $params, $apiKey);
Expand Down
11 changes: 11 additions & 0 deletions test/test_stripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ public function testCreate() {
$this->assertTrue($c->paid);
$this->assertFalse($c->refunded);
}

public function testRetrieve() {
authorizeFromEnv();
$c = StripeCharge::create(array('amount' => 100,
'currency' => 'usd',
'card' => array('number' => 4242424242424242,
'exp_month' => 5,
'exp_year' => 2015)));
$d = StripeCharge::retrieve($c->id);
$this->assertEqual($d->id, $c->id);
}
}

class TestCustomer extends UnitTestCase {
Expand Down

0 comments on commit ece7221

Please sign in to comment.