diff --git a/composer.json b/composer.json index 5e1c8c0..fac8d6b 100644 --- a/composer.json +++ b/composer.json @@ -20,16 +20,18 @@ "issues": "https://github.com/MetisFW/PayPal/issues" }, "require": { - "php": ">=5.6.0", - "nette/di": "^2.4", - "nette/application": "^2.4", - "paypal/rest-api-sdk-php": "^1.5" + "php": "^7.1", + "ext-curl": "*", + "ext-json": "*", + "nette/di": "^3.0", + "nette/application": "3.0", + "paypal/rest-api-sdk-php": "^1.14" }, "require-dev": { - "nette/bootstrap": "^2.4", - "nette/robot-loader": "^2.4", - "nette/tester": "^2.4", - "mockery/mockery": "^1.4" + "nette/bootstrap": "^3.0", + "tracy/tracy": "^2.6", + "nette/tester": "^2.2", + "mockery/mockery": "^1.2" }, "autoload": { "psr-0": { diff --git a/src/MetisFW/PayPal/DI/PayPalExtension.php b/src/MetisFW/PayPal/DI/PayPalExtension.php index 6ea341a..6c9a103 100644 --- a/src/MetisFW/PayPal/DI/PayPalExtension.php +++ b/src/MetisFW/PayPal/DI/PayPalExtension.php @@ -5,6 +5,7 @@ use Nette\Configurator; use Nette\DI\Compiler; use Nette\DI\CompilerExtension; +use Nette\DI\Config\Helpers; use Nette\Utils\Validators; class PayPalExtension extends CompilerExtension { @@ -19,26 +20,29 @@ class PayPalExtension extends CompilerExtension { public function loadConfiguration() { $builder = $this->getContainerBuilder(); - $config = $this->getConfig($this->defaults); + $config = Helpers::merge($this->getConfig(), $this->defaults); Validators::assertField($config, 'clientId'); Validators::assertField($config, 'secret'); Validators::assertField($config, 'sdkConfig', 'array'); - $builder->addDefinition($this->prefix('simplePaymentOperationFactory')) + $builder->addFactoryDefinition($this->prefix('simplePaymentOperationFactory')) ->setImplement('MetisFW\PayPal\Payment\SimplePaymentOperationFactory'); - $builder->addDefinition($this->prefix('plainPaymentOperationFactory')) + $builder->addFactoryDefinition($this->prefix('plainPaymentOperationFactory')) ->setImplement('MetisFW\PayPal\Payment\PlainPaymentOperationFactory'); $builder->addDefinition($this->prefix('credentials')) - ->setClass('PayPal\Auth\OAuthTokenCredential', array($config['clientId'], $config['secret'])); + ->setType('PayPal\Auth\OAuthTokenCredential') + ->setArguments(array($config['clientId'], $config['secret'])); $builder->addDefinition($this->prefix('apiContext')) - ->setClass('PayPal\Rest\ApiContext', array($this->prefix('@credentials'))); + ->setType('PayPal\Rest\ApiContext') + ->setArguments(array($this->prefix('@credentials'))); $paypal = $builder->addDefinition($this->prefix('PayPal')) - ->setClass('MetisFW\PayPal\PayPalContext', array($this->prefix('@apiContext'))) + ->setType('MetisFW\PayPal\PayPalContext') + ->setArguments(array($this->prefix('@apiContext'))) ->addSetup('setConfig', array($config['sdkConfig'])) ->addSetup('setCurrency', array($config['currency'])) ->addSetup('setGaTrackingEnabled', array($config['gaTrackingEnabled'])); @@ -48,9 +52,6 @@ public function loadConfiguration() { } } - /** - * @param Configurator $configurator - */ public static function register(Configurator $configurator) { $configurator->onCompile[] = function ($config, Compiler $compiler) { $compiler->addExtension('payPal', new PayPalExtension()); diff --git a/src/MetisFW/PayPal/Helpers/GaTracking.php b/src/MetisFW/PayPal/Helpers/GaTracking.php index 244e7d8..66608a8 100644 --- a/src/MetisFW/PayPal/Helpers/GaTracking.php +++ b/src/MetisFW/PayPal/Helpers/GaTracking.php @@ -3,13 +3,10 @@ namespace MetisFW\PayPal\Helpers; use Nette\Http\Url; -use Nette\SmartObject; use PayPal\Api\Payment; class GaTracking { - use SmartObject; - private function __construct() { // nothing } diff --git a/src/MetisFW/PayPal/PayPalContext.php b/src/MetisFW/PayPal/PayPalContext.php index e0542c2..563384a 100644 --- a/src/MetisFW/PayPal/PayPalContext.php +++ b/src/MetisFW/PayPal/PayPalContext.php @@ -2,13 +2,10 @@ namespace MetisFW\PayPal; -use Nette\SmartObject; use PayPal\Rest\ApiContext; class PayPalContext { - use SmartObject; - /** @var ApiContext */ private $apiContext; diff --git a/src/MetisFW/PayPal/Payment/BasePaymentOperation.php b/src/MetisFW/PayPal/Payment/BasePaymentOperation.php index 4bfb7e5..7e612ca 100644 --- a/src/MetisFW/PayPal/Payment/BasePaymentOperation.php +++ b/src/MetisFW/PayPal/Payment/BasePaymentOperation.php @@ -16,6 +16,10 @@ use PayPal\Exception\PayPalInvalidCredentialException; use PayPal\Exception\PayPalMissingCredentialException; +/** + * @method void onCancel(self $self) + * @method void onReturn(self $self, Payment $payment) + */ abstract class BasePaymentOperation implements PaymentOperation { use SmartObject; diff --git a/src/MetisFW/PayPal/UI/PaymentControl.php b/src/MetisFW/PayPal/UI/PaymentControl.php index 6534cfe..ccb1228 100644 --- a/src/MetisFW/PayPal/UI/PaymentControl.php +++ b/src/MetisFW/PayPal/UI/PaymentControl.php @@ -44,7 +44,6 @@ class PaymentControl extends Control { * @param PaymentOperation $operation */ public function __construct(PaymentOperation $operation) { - parent::__construct(); $this->operation = $operation; }