From 8737a00bc2d91ca2d45fd9aafa6775ddee9a2df0 Mon Sep 17 00:00:00 2001 From: Mike Jablecki Date: Wed, 20 Jan 2016 11:23:44 -0500 Subject: [PATCH] Updates stripe api to 2.0 - 3.x --- Action/Api/CreateChargeAction.php | 9 ++++++--- Action/Api/CreateCustomerAction.php | 10 +++++++--- StripeCheckoutGatewayFactory.php | 4 ++-- composer.json | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Action/Api/CreateChargeAction.php b/Action/Api/CreateChargeAction.php index b581b6c..61a9c2a 100644 --- a/Action/Api/CreateChargeAction.php +++ b/Action/Api/CreateChargeAction.php @@ -9,6 +9,9 @@ use Payum\Core\Exception\UnsupportedApiException; use Payum\Stripe\Keys; use Payum\Stripe\Request\Api\CreateCharge; +use Stripe\Charge; +use Stripe\Error; +use Stripe\Stripe; class CreateChargeAction implements ActionInterface, ApiAwareInterface { @@ -48,12 +51,12 @@ public function execute($request) } try { - \Stripe::setApiKey($this->keys->getSecretKey()); + Stripe::setApiKey($this->keys->getSecretKey()); - $charge = \Stripe_Charge::create($model->toUnsafeArray()); + $charge = Charge::create($model->toUnsafeArray()); $model->replace($charge->__toArray(true)); - } catch (\Stripe_CardError $e) { + } catch (Error\Card $e) { $model->replace($e->getJsonBody()); } } diff --git a/Action/Api/CreateCustomerAction.php b/Action/Api/CreateCustomerAction.php index a701ddd..a933d6c 100644 --- a/Action/Api/CreateCustomerAction.php +++ b/Action/Api/CreateCustomerAction.php @@ -9,6 +9,10 @@ use Payum\Stripe\Keys; use Payum\Stripe\Request\Api\CreateCharge; use Payum\Stripe\Request\Api\ObtainToken; +use Stripe\Customer; +use Stripe\Error; +use Stripe\Stripe; + class CreateCustomerAction extends GatewayAwareAction implements ApiAwareInterface { @@ -46,12 +50,12 @@ public function execute($request) } try { - \Stripe::setApiKey($this->keys->getSecretKey()); + Stripe::setApiKey($this->keys->getSecretKey()); - $charge = \Stripe_Customer::create($model->toUnsafeArray()); + $charge = Customer::create($model->toUnsafeArray()); $model->replace($charge->__toArray(true)); - } catch (\Stripe_CardError $e) { + } catch (Error\Card $e) { $model->replace($e->getJsonBody()); } } diff --git a/StripeCheckoutGatewayFactory.php b/StripeCheckoutGatewayFactory.php index 8243f00..4203ae5 100644 --- a/StripeCheckoutGatewayFactory.php +++ b/StripeCheckoutGatewayFactory.php @@ -16,8 +16,8 @@ class StripeCheckoutGatewayFactory extends GatewayFactory */ protected function populateConfig(ArrayObject $config) { - if (!class_exists('Stripe')) { - throw new \LogicException('You must install "stripe/stripe-php" library.'); + if (!class_exists('\Stripe\Stripe')) { + throw new \LogicException('You must install "stripe/stripe-php:~2.0|~3.0" library.'); } $config->defaults(array( diff --git a/composer.json b/composer.json index 123dbd9..ffc41f9 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ ], "require": { "payum/core": "~1.0", - "stripe/stripe-php": "~1.0" + "stripe/stripe-php": "~2.0|~3.0" }, "require-dev": { "phpunit/phpunit": "~4.0",