Skip to content

Commit

Permalink
Merge pull request stripe#116 from JustinHook/master
Browse files Browse the repository at this point in the history
Fix stripe#114. Pass API key to _scopedSave
  • Loading branch information
bkrausz committed Dec 15, 2014
2 parents 3d40798 + 9a728c2 commit 6c428e9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Stripe/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function create($params=null, $apiKey=null)
public function save()
{
$class = get_class();
return self::_scopedSave($class);
return self::_scopedSave($class, $this->_apiKey);
}

/**
Expand Down
10 changes: 10 additions & 0 deletions test/Stripe/CustomerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ public function testSave()

$stripeCustomer = Stripe_Customer::retrieve($customer->id);
$this->assertEqual($customer->email, $stripeCustomer->email);


Stripe::setApiKey(null);
$customer = Stripe_Customer::create(null, StripeTestCase::API_KEY);
$customer->email = '[email protected]';
$customer->save();

StripeTestCase::authorizeFromEnv();
$updatedCustomer = Stripe_Customer::retrieve($customer->id);
$this->assertEqual($updatedCustomer->email, '[email protected]');
}

public function testBogusAttribute()
Expand Down
4 changes: 3 additions & 1 deletion test/Stripe/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
*/
abstract class StripeTestCase extends UnitTestCase
{
const API_KEY = "tGN0bIwXnHdwOa85VABjPdSn8nWY7G7I";

protected static function authorizeFromEnv()
{
$apiKey = getenv('STRIPE_API_KEY');
if (!$apiKey) {
$apiKey = "tGN0bIwXnHdwOa85VABjPdSn8nWY7G7I";
$apiKey = self::API_KEY;
}
Stripe::setApiKey($apiKey);
}
Expand Down

0 comments on commit 6c428e9

Please sign in to comment.