diff --git a/composer.json b/composer.json index 89260f2..ce327cd 100644 --- a/composer.json +++ b/composer.json @@ -32,16 +32,19 @@ "psr-4": { "Omnipay\\PayU\\" : "src/" } }, "require": { + "php": "^7.2|^8", + "ext-curl": "*", "ext-json": "*", - "omnipay/common": "^2.5", + "omnipay/common": "^3", "openpayu/openpayu_php_sdk": "^2.2" }, "require-dev": { - "omnipay/tests": "^2.1", - "symfony/var-dumper": "^2.7", - "mockery/mockery": "^0.9.5", - "vlucas/phpdotenv": "^2.3", - "phpunit/phpunit": "3.7.*", - "phpstan/phpstan": "^0.12.42" + "omnipay/tests": "^4.1", + "symfony/var-dumper": "^5.3", + "mockery/mockery": "^1.4", + "vlucas/phpdotenv": "^5.3", + "phpunit/phpunit": "^9", + "phpstan/phpstan": "^0.12.9", + "php-http/guzzle7-adapter": "^1.0" } } diff --git a/examples/test-finish.php b/examples/test-finish.php index a018f60..4627353 100644 --- a/examples/test-finish.php +++ b/examples/test-finish.php @@ -3,19 +3,22 @@ require '../vendor/autoload.php'; use Omnipay\PayU\GatewayFactory; +use Omnipay\PayU\Messages\CompletePurchaseResponse; -$dotenv = new Dotenv\Dotenv(__DIR__ . '/..'); +$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..'); $dotenv->load(); // default is official sandbox -$posId = isset($_ENV['POS_ID']) ? $_ENV['POS_ID'] : '300046'; -$secondKey = isset($_ENV['SECOND_KEY']) ? $_ENV['SECOND_KEY'] : '0c017495773278c50c7b35434017b2ca'; -$oAuthClientSecret = isset($_ENV['OAUTH_CLIENT_SECRET']) ? $_ENV['OAUTH_CLIENT_SECRET'] : 'c8d4b7ac61758704f38ed5564d8c0ae0'; +$posId = isset($_ENV['POS_ID']) ? $_ENV['POS_ID'] : '300746'; +$secondKey = isset($_ENV['SECOND_KEY']) ? $_ENV['SECOND_KEY'] : 'b6ca15b0d1020e8094d9b5f8d163db54'; +$oAuthClientSecret = isset($_ENV['OAUTH_CLIENT_SECRET']) ? $_ENV['OAUTH_CLIENT_SECRET'] : '2ee86a66e5d97e3fadc400c9f19b065d'; +$posAuthKey = isset($_ENV['POS_AUTH_KEY']) ? $_ENV['POS_AUTH_KEY'] : '300746'; -$gateway = GatewayFactory::createInstance($posId, $secondKey, $oAuthClientSecret, true); +$gateway = GatewayFactory::createInstance($posId, $secondKey, $oAuthClientSecret, true, $posAuthKey); try { $completeRequest = ['transactionReference' => 'J9R4JP3F2G160825GUEST000P01']; + /** @var CompletePurchaseResponse $response */ $response = $gateway->completePurchase($completeRequest); echo "Is Successful: " . $response->isSuccessful() . PHP_EOL; @@ -24,6 +27,8 @@ echo "PaymentId: " , $response->getTransactionReference() . PHP_EOL; echo "Data: " . var_export($response->getData(), true) . PHP_EOL; +} catch (OpenPayU_Exception $e) { + dump($e->getMessage()); } catch (Exception $e) { dump((string)$e); } diff --git a/examples/test-notification.php b/examples/test-notification.php index 88d9148..c1c5f1b 100644 --- a/examples/test-notification.php +++ b/examples/test-notification.php @@ -5,14 +5,16 @@ use Omnipay\PayU\GatewayFactory; use Symfony\Component\HttpFoundation\Request; -$dotenv = new Dotenv\Dotenv(__DIR__ . '/..'); +$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..'); $dotenv->load(); // default is official sandbox -$posId = isset($_ENV['POS_ID']) ? $_ENV['POS_ID'] : '300046'; -$secondKey = isset($_ENV['SECOND_KEY']) ? $_ENV['SECOND_KEY'] : '0c017495773278c50c7b35434017b2ca'; -$oAuthClientSecret = isset($_ENV['OAUTH_CLIENT_SECRET']) ? $_ENV['OAUTH_CLIENT_SECRET'] : 'c8d4b7ac61758704f38ed5564d8c0ae0'; -$posAuthKey = isset($_ENV['POS_AUTH_KEY']) ? $_ENV['POS_AUTH_KEY'] : null; // Official sandbox does not provide signature key +$posId = isset($_ENV['POS_ID']) ? $_ENV['POS_ID'] : '300746'; +$secondKey = isset($_ENV['SECOND_KEY']) ? $_ENV['SECOND_KEY'] : 'b6ca15b0d1020e8094d9b5f8d163db54'; +$oAuthClientSecret = isset($_ENV['OAUTH_CLIENT_SECRET']) ? $_ENV['OAUTH_CLIENT_SECRET'] : '2ee86a66e5d97e3fadc400c9f19b065d'; +$posAuthKey = isset($_ENV['POS_AUTH_KEY']) ? $_ENV['POS_AUTH_KEY'] : '300746'; + +$gateway = GatewayFactory::createInstance($posId, $secondKey, $oAuthClientSecret, true, $posAuthKey); $content = '{"order":{"orderId":"NN18KW7XJG160830GUEST000P01","extOrderId":"57c56b16d22e1","orderCreateDate":"2016-08-30T13:16:39.641+02:00","notifyUrl":"http://52.58.177.216/online-payments/uuid/notify","customerIp":"80.188.133.34","merchantPosId":"300293","description":"Shopping at myStore.com","currencyCode":"PLN","totalAmount":"15000","status":"PENDING","products":[{"name":"Lenovo ThinkPad Edge E540","unitPrice":"15000","quantity":"1"}]},"localReceiptDateTime":"2016-08-30T13:17:14.502+02:00","properties":[{"name":"PAYMENT_ID","value":"72829425"}]}'; $httpRequest = Request::create('/notify', 'POST', [], [], [], [], $content); diff --git a/examples/test.php b/examples/test.php index bad80ec..b19bb94 100644 --- a/examples/test.php +++ b/examples/test.php @@ -2,18 +2,19 @@ require '../vendor/autoload.php'; -use Guzzle\Http\Exception\ClientErrorResponseException; use Omnipay\PayU\GatewayFactory; +use Omnipay\PayU\Messages\PurchaseResponse; -$dotenv = new Dotenv\Dotenv(__DIR__ . '/..'); +$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..'); $dotenv->load(); // default is official sandbox -$posId = isset($_ENV['POS_ID']) ? $_ENV['POS_ID'] : '300046'; -$secondKey = isset($_ENV['SECOND_KEY']) ? $_ENV['SECOND_KEY'] : '0c017495773278c50c7b35434017b2ca'; -$oAuthClientSecret = isset($_ENV['OAUTH_CLIENT_SECRET']) ? $_ENV['OAUTH_CLIENT_SECRET'] : 'c8d4b7ac61758704f38ed5564d8c0ae0'; +$posId = isset($_ENV['POS_ID']) ? $_ENV['POS_ID'] : '300746'; +$secondKey = isset($_ENV['SECOND_KEY']) ? $_ENV['SECOND_KEY'] : 'b6ca15b0d1020e8094d9b5f8d163db54'; +$oAuthClientSecret = isset($_ENV['OAUTH_CLIENT_SECRET']) ? $_ENV['OAUTH_CLIENT_SECRET'] : '2ee86a66e5d97e3fadc400c9f19b065d'; +$posAuthKey = isset($_ENV['POS_AUTH_KEY']) ? $_ENV['POS_AUTH_KEY'] : '300746'; -$gateway = GatewayFactory::createInstance($posId, $secondKey, $oAuthClientSecret, true); +$gateway = GatewayFactory::createInstance($posId, $secondKey, $oAuthClientSecret, true, $posAuthKey); try { $orderNo = uniqid(); @@ -53,6 +54,7 @@ ] ]; + /** @var PurchaseResponse $response */ $response = $gateway->purchase($purchaseRequest); echo "TransactionId: " . $response->getTransactionId() . PHP_EOL; @@ -62,7 +64,8 @@ // Payment init OK, redirect to the payment gateway echo $response->getRedirectUrl() . PHP_EOL; -} catch (ClientErrorResponseException $e) { +} catch (OpenPayU_Exception $e) { + dump($e->getMessage()); +} catch (Exception $e) { dump((string)$e); - dump($e->getResponse()->getBody(true)); -} \ No newline at end of file +} diff --git a/src/Gateway.php b/src/Gateway.php index b0edd00..3c8adde 100644 --- a/src/Gateway.php +++ b/src/Gateway.php @@ -3,86 +3,79 @@ namespace Omnipay\PayU; use Omnipay\Common\AbstractGateway; -use Omnipay\PayU\Messages\AccessTokenRequest; -use Omnipay\PayU\Messages\AccessTokenResponse; +use Omnipay\Common\Message\ResponseInterface; use Omnipay\PayU\Messages\CompletePurchaseRequest; use Omnipay\PayU\Messages\CompletePurchaseResponse; use Omnipay\PayU\Messages\Notification; use Omnipay\PayU\Messages\PurchaseRequest; use Omnipay\PayU\Messages\PurchaseResponse; +use OpenPayU_Configuration; +use OpenPayU_Exception; +use OpenPayU_Exception_Configuration; class Gateway extends AbstractGateway { - const URL_SANDBOX = 'https://secure.snd.payu.com'; - const URL_PRODUCTION = 'https://secure.payu.com'; + const ENV_TEST = 'sandbox'; + const ENV_PRODUCTION = 'secure'; /** * Get gateway display name */ - public function getName() + public function getName(): string { return 'PayU'; } /** - * @return AccessTokenResponse + * @param array $parameters + * @return $this|Gateway + * @throws OpenPayU_Exception_Configuration */ - public function getAccessToken() + public function initialize(array $parameters = []): self { - $request = parent::createRequest(AccessTokenRequest::class, [ - 'clientId' => $this->getParameter('posId'), - 'clientSecret' => $this->getParameter('clientSecret'), - 'apiUrl' => $this->getApiUrl() - ]); - $response = $request->send(); - - return $response; + parent::initialize($parameters); + + OpenPayU_Configuration::setEnvironment($this->getEnvironment()); + OpenPayU_Configuration::setOauthGrantType('client_credentials'); + OpenPayU_Configuration::setMerchantPosId($this->getParameter('posId')); + OpenPayU_Configuration::setSignatureKey($this->getParameter('secondKey')); + OpenPayU_Configuration::setOauthClientId($this->getParameter('posAuthKey')); + OpenPayU_Configuration::setOauthClientSecret($this->getParameter('clientSecret')); + + return $this; } /** - * @param array $parameters - * @return PurchaseResponse + * @param array $options + * @throws OpenPayU_Exception + * @return PurchaseResponse|ResponseInterface */ - public function purchase(array $parameters = []) + public function purchase(array $options = []): ResponseInterface { - $this->setAccessToken($this->getAccessToken()->getAccessToken()); - $request = parent::createRequest(PurchaseRequest::class, $parameters); - $response = $request->send(); + $request = $this->createRequest(PurchaseRequest::class, $options); - return $response; + return $request->send(); } /** - * @param array $parameters - * @return CompletePurchaseResponse + * @param array $options + * @throws OpenPayU_Exception + * @return CompletePurchaseResponse|ResponseInterface */ - public function completePurchase(array $parameters = []) + public function completePurchase(array $options = []): ResponseInterface { - $this->setAccessToken($this->getAccessToken()->getAccessToken()); - $request = self::createRequest(CompletePurchaseRequest::class, $parameters); - $response = $request->send(); + $request = $this->createRequest(CompletePurchaseRequest::class, $options); - return $response; + return $request->send(); } - public function acceptNotification() + public function acceptNotification(): Notification { return new Notification($this->httpRequest, $this->httpClient, $this->getParameter('secondKey')); } - /** - * @return string - */ - private function getApiUrl() - { - if ($this->getTestMode()) { - return self::URL_SANDBOX; - } else { - return self::URL_PRODUCTION; - } - } - - public function getDefaultParameters() + /** @return array */ + public function getDefaultParameters(): array { return [ 'posId' => '', @@ -96,7 +89,7 @@ public function getDefaultParameters() /** * @param string $secondKey */ - public function setSecondKey($secondKey) + public function setSecondKey(string $secondKey): void { $this->setParameter('secondKey', $secondKey); } @@ -104,7 +97,7 @@ public function setSecondKey($secondKey) /** * @param string $posId */ - public function setPosId($posId) + public function setPosId(string $posId): void { $this->setParameter('posId', $posId); } @@ -112,7 +105,7 @@ public function setPosId($posId) /** * @param string $clientSecret */ - public function setClientSecret($clientSecret) + public function setClientSecret(string $clientSecret): void { $this->setParameter('clientSecret', $clientSecret); } @@ -120,26 +113,17 @@ public function setClientSecret($clientSecret) /** * @param string|null $posAuthKey */ - public function setPosAuthKey($posAuthKey = null) + public function setPosAuthKey(string $posAuthKey = null): void { $this->setParameter('posAuthKey', $posAuthKey); } - public function initialize(array $parameters = []) - { - parent::initialize($parameters); - $this->setApiUrl($this->getApiUrl()); - - return $this; - } - - private function setApiUrl($apiUrl) + private function getEnvironment(): string { - $this->setParameter('apiUrl', $apiUrl); - } + if ($this->getTestMode()) { + return self::ENV_TEST; + } - private function setAccessToken($accessToken) - { - $this->setParameter('accessToken', $accessToken); + return self::ENV_PRODUCTION; } -} \ No newline at end of file +} diff --git a/src/Messages/AccessTokenRequest.php b/src/Messages/AccessTokenRequest.php deleted file mode 100644 index 4002135..0000000 --- a/src/Messages/AccessTokenRequest.php +++ /dev/null @@ -1,61 +0,0 @@ -setParameter('clientId', $clientId); - } - - /** - * @param string $clientSecret - */ - public function setClientSecret($clientSecret) - { - $this->setParameter('clientSecret', $clientSecret); - } - - public function sendData($data) - { - $authorizeUrl = $this->apiUrl . '/pl/standard/user/oauth/authorize'; - - $headers = [ - 'Accept' => 'application/json', - 'ContentType' => 'application/json', - ]; - $tokenData = $this->httpClient->post($authorizeUrl, $headers, $data)->send(); - - $response = new AccessTokenResponse($this, $tokenData->json()); - return $response; - } - - /** - * @return array - */ - public function getData() - { - return [ - 'grant_type' => 'client_credentials', - 'client_id' => $this->parameters->get('clientId'), - 'client_secret' => $this->parameters->get('clientSecret'), - ]; - } - - /** - * @param string $apiUrl - */ - public function setApiUrl($apiUrl) - { - $this->apiUrl = $apiUrl; - } -} \ No newline at end of file diff --git a/src/Messages/AccessTokenResponse.php b/src/Messages/AccessTokenResponse.php deleted file mode 100644 index ca406e2..0000000 --- a/src/Messages/AccessTokenResponse.php +++ /dev/null @@ -1,31 +0,0 @@ -data) - && isset($this->data['access_token']) - && is_string($this->data['access_token']) - && isset($this->data['token_type']) - && is_string($this->data['token_type']); - } - - /** - * @return string - */ - public function getAccessToken() - { - $completeToken = sprintf('%s %s', ucfirst($this->data['token_type']), $this->data['access_token']); - - return $completeToken; - } - -} \ No newline at end of file diff --git a/src/Messages/CompletePurchaseRequest.php b/src/Messages/CompletePurchaseRequest.php index 797059b..dfbc230 100644 --- a/src/Messages/CompletePurchaseRequest.php +++ b/src/Messages/CompletePurchaseRequest.php @@ -1,46 +1,43 @@ setParameter('accessToken', $accessToken); } - public function setApiUrl($apiUrl) - { - $this->setParameter('apiUrl', $apiUrl); - } - /** - * @return array + * @return array */ - public function getData() + public function getData(): array { return $this->getParameters(); } /** - * @param mixed $data The data to send - * @return ResponseInterface + * @param mixed $data The data to send + * @return ResponseInterface|CompletePurchaseResponse + * @throws OpenPayU_Exception + * @throws Exception */ - public function sendData($data) + public function sendData($data): ResponseInterface { - $headers = [ - 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'Authorization' => $data['accessToken'] - ]; - $url = $data['apiUrl'] . '/api/v2_1/orders/' . urlencode($this->getTransactionReference()); - $httpRequest = $this->httpClient->get($url, $headers); - $httpResponse = $httpRequest->send(); - - $response = new CompletePurchaseResponse($this, $httpResponse->json()); + $payUResponse = OpenPayU_Order::retrieve($this->getTransactionReference()); + + if (!$payUResponse) { + throw new Exception('Could not fetch order data'); + } + + $response = new CompletePurchaseResponse($this, $payUResponse->getResponse()); return $this->response = $response; } diff --git a/src/Messages/CompletePurchaseResponse.php b/src/Messages/CompletePurchaseResponse.php index 97c1386..ad0216b 100644 --- a/src/Messages/CompletePurchaseResponse.php +++ b/src/Messages/CompletePurchaseResponse.php @@ -9,7 +9,7 @@ class CompletePurchaseResponse extends AbstractResponse /** * @return boolean */ - public function isSuccessful() + public function isSuccessful(): bool { return 'COMPLETED' === $this->getCode(); } @@ -17,16 +17,16 @@ public function isSuccessful() /** * @return string|null */ - public function getTransactionId() + public function getTransactionId(): ?string { - if (isset($this->data['orders'][0]['extOrderId']) && !empty($this->data['orders'][0]['extOrderId'])) { - return (string) $this->data['orders'][0]['extOrderId']; + if (isset($this->data->orders[0]->extOrderId) && !empty($this->data->orders[0]->extOrderId)) { + return (string) $this->data->orders[0]->extOrderId; } return null; } - public function isCancelled() + public function isCancelled(): bool { return in_array($this->getCode(), ['CANCELED', 'REJECTED'], true); } @@ -35,10 +35,10 @@ public function isCancelled() * PAYMENT_ID is not present for transaction in state PENDING * @return null|string */ - public function getTransactionReference() + public function getTransactionReference(): ?string { - if (isset($this->data['orders'][0]['orderId']) && !empty($this->data['orders'][0]['orderId'])) { - return (string) $this->data['orders'][0]['orderId']; + if (isset($this->data->orders[0]->orderId) && !empty($this->data->orders[0]->orderId)) { + return (string) $this->data->orders[0]->orderId; } return null; @@ -49,12 +49,12 @@ public function getTransactionReference() * * @return string */ - public function getCode() + public function getCode(): string { - return $this->data['orders'][0]['status']; + return $this->data->orders[0]->status; } - public function isPending() + public function isPending(): bool { return in_array($this->getCode(), ['PENDING', 'WAITING_FOR_CONFIRMATION', 'NEW']); } @@ -62,18 +62,8 @@ public function isPending() /** * @return string|null */ - public function getPaymentReference() + public function getPaymentReference(): ?string { - if (isset($this->data['properties'])) { - $properties = $this->data['properties']; - $paymentIdProperty = array_filter($properties, function ($item) { - return $item['name'] === 'PAYMENT_ID'; - }); - if (isset($paymentIdProperty[0]['value'])) { - return (string)$paymentIdProperty[0]['value']; - } - }; - - return null; + return $this->getTransactionReference(); } -} \ No newline at end of file +} diff --git a/src/Messages/Notification.php b/src/Messages/Notification.php index c72f7d2..8060905 100644 --- a/src/Messages/Notification.php +++ b/src/Messages/Notification.php @@ -2,9 +2,8 @@ namespace Omnipay\PayU\Messages; -use Guzzle\Http\Client; -use Guzzle\Http\ClientInterface; use Omnipay\Common\Exception\InvalidRequestException; +use Omnipay\Common\Http\Client; use Omnipay\Common\Message\NotificationInterface; use OpenPayU_Util; use stdClass; @@ -21,7 +20,7 @@ class Notification implements NotificationInterface /** @var Request */ private $httpRequest; - /** @var Client|ClientInterface */ + /** @var Client */ private $httpClient; /** @var string */ @@ -74,10 +73,10 @@ public function __construct($httpRequest, $httpClient, $secondKey) /** * Gateway Reference * - * @return string A reference provided by the gateway to represent this transaction + * @return null|string A reference provided by the gateway to represent this transaction * @throws InvalidRequestException */ - public function getTransactionReference() + public function getTransactionReference(): ?string { if (isset($this->getData()->order->extOrderId) && !empty($this->getData()->order->extOrderId)) { return (string) $this->getData()->order->extOrderId; @@ -132,7 +131,7 @@ private function getSignature(Request $request) * @return string Transaction status, one of {@see STATUS_COMPLETED}, {@see #STATUS_PENDING} or {@see #STATUS_FAILED}. * @throws InvalidRequestException */ - public function getTransactionStatus() + public function getTransactionStatus(): string { if ($this->getData()) { $status = $this->getData()->order->status; diff --git a/src/Messages/PurchaseRequest.php b/src/Messages/PurchaseRequest.php index 49f527d..817719d 100644 --- a/src/Messages/PurchaseRequest.php +++ b/src/Messages/PurchaseRequest.php @@ -3,14 +3,17 @@ use Omnipay\Common\Message\AbstractRequest; use Omnipay\Common\Message\ResponseInterface; +use OpenPayU_Exception; +use OpenPayU_Order; +use OpenPayU_Result; class PurchaseRequest extends AbstractRequest { /** - * @return array + * @return array */ - public function getData() + public function getData(): array { return $this->getParameters(); } @@ -18,51 +21,28 @@ public function getData() /** * Send the request with specified data * - * @param mixed $data The data to send - * @return ResponseInterface + * @param array $data The data to send + * @return ResponseInterface|PurchaseResponse + * @throws OpenPayU_Exception */ - public function sendData($data) + public function sendData($data): ResponseInterface { - $headers = [ - 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'Authorization' => $data['accessToken'] - ]; - $apiUrl = $data['apiUrl'] . '/api/v2_1/orders'; if (isset($data['purchaseData']['extOrderId'])) { $this->setTransactionId($data['purchaseData']['extOrderId']); } - $httpRequest = $this->httpClient->post($apiUrl, $headers, json_encode($data['purchaseData'])); - $httpRequest->configureRedirects(true, 0); - $httpResponse = $httpRequest->send(); - $responseData = $httpResponse->json(); - $response = new PurchaseResponse($this, $responseData); + /** @var OpenPayU_Result $response */ + $response = OpenPayU_Order::create($data['purchaseData']); - return $this->response = $response; - } + $response = new PurchaseResponse($this, $response->getResponse()); - /** - * @param string $apiUrl - */ - public function setApiUrl($apiUrl) - { - $this->setParameter('apiUrl', $apiUrl); + return $this->response = $response; } /** - * @param array $data + * @param array $data */ - public function setPurchaseData($data) + public function setPurchaseData(array $data): void { $this->setParameter('purchaseData', $data); } - - /** - * @param string $accessToken - */ - public function setAccessToken($accessToken) - { - $this->setParameter('accessToken', $accessToken); - } - -} \ No newline at end of file +} diff --git a/src/Messages/PurchaseResponse.php b/src/Messages/PurchaseResponse.php index 3570c64..5f64c14 100644 --- a/src/Messages/PurchaseResponse.php +++ b/src/Messages/PurchaseResponse.php @@ -10,9 +10,9 @@ class PurchaseResponse extends AbstractResponse implements RedirectResponseInter /** * @return boolean */ - public function isSuccessful() + public function isSuccessful(): bool { - if ('SUCCESS' !== $this->data['status']['statusCode']) { + if ('SUCCESS' !== $this->data->status->statusCode) { return false; } $redirectUrl = $this->getRedirectUrl(); @@ -23,19 +23,19 @@ public function isSuccessful() /** * Gets the redirect target url. */ - public function getRedirectUrl() + public function getRedirectUrl(): ?string { - if (isset($this->data['redirectUri']) && is_string($this->data['redirectUri'])) { - return $this->data['redirectUri']; - } else { - return null; + if (isset($this->data->redirectUri) && is_string($this->data->redirectUri)) { + return $this->data->redirectUri; } + + return null; } /** * Get the required redirect method (either GET or POST). */ - public function getRedirectMethod() + public function getRedirectMethod(): string { return 'GET'; } @@ -43,7 +43,7 @@ public function getRedirectMethod() /** * Gets the redirect form data array, if the redirect method is POST. */ - public function getRedirectData() + public function getRedirectData(): ?array { return null; } @@ -51,10 +51,10 @@ public function getRedirectData() /** * @return string|null */ - public function getTransactionId() + public function getTransactionId(): ?string { - if (isset($this->data['extOrderId']) && !empty($this->data['extOrderId'])) { - return (string) $this->data['extOrderId']; + if (isset($this->data->extOrderId) && !empty($this->data->extOrderId)) { + return (string) $this->data->extOrderId; } if (isset($this->request->getParameters()['transactionId']) && !empty($this->request->getParameters()['transactionId'])) { return $this->request->getParameters()['transactionId']; @@ -65,18 +65,18 @@ public function getTransactionId() /** * PayU orderId - * @return string + * @return null|string */ - public function getTransactionReference() + public function getTransactionReference(): ?string { - if (isset($this->data['orderId']) && !empty($this->data['orderId'])) { - return (string) $this->data['orderId']; + if (isset($this->data->orderId) && !empty($this->data->orderId)) { + return (string) $this->data->orderId; } return null; } - public function isRedirect() + public function isRedirect(): bool { - return is_string($this->data['redirectUri']); + return is_string($this->data->redirectUri); } -} \ No newline at end of file +}