alegra / omnipay-iyzico
Iyzico gateway for Omnipay payment processing library
Requires
- ext-dom: *
- ext-json: *
- iyzico/iyzipay-php: ^2
- omnipay/common: ^3
Requires (Dev)
- omnipay/tests: ^3
README
Iyzico gateway for Omnipay V3 payment processing library
Omnipay is a framework agnostic, multi-gateway payment processing library for PHP 7.3+. This package implements Iyzico Online Payment Gateway support for Omnipay.
Iyzico API documentation
Requirement
- PHP >= 7.3.x,
- Omnipay V.3 repository,
- PHPUnit to run tests
Autoload
You have to install omnipay V.3
composer require league/omnipay:^3
Then you have to install omnipay-payu package:
composer require alegra/omnipay-iyzico
payment-iyzico
follows the PSR-4 convention names for its classes, which means you can easily integratepayment-iyzico
classes loading in your own autoloader.
Basic Usage
- You can use /examples folder to execute examples. This folder is exists here only to show you examples, it is not for production usage.
- First in /examples folder:
composer install
Purchase Example
- You can check purchase.php file in /examples folder.
- force3ds parameter is included in the parameters. It shows the status of card. If you test direct purchase, you should send 0 value. It's type is string. If you don't send this force3ds parameter, system check status of card. System uses iyzico-installmentInfo function.
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\Iyzico\IyzicoGateway; use Examples\Helper; $gateway = new IyzicoGateway(); $helper = new Helper(); try { $params = $helper->getPurchaseParams(); $response = $gateway->purchase($params)->send(); $result = [ 'status' => $response->isSuccessful() ?: 0, 'redirect' => $response->isRedirect() ?: 0, 'message' => $response->getMessage(), 'transactionId' => $response->getTransactionReference(), 'requestParams' => $response->getServiceRequestParams(), 'response' => $response->getData() ]; print("<pre>" . print_r($result, true) . "</pre>"); } catch (Exception $e) { throw new \RuntimeException($e->getMessage()); }
Purchase 3d Example
- You can check purchase3d.php file in /examples folder.
- force3ds parameter is included in the parameters. It shows the status of card. If you test purchase 3d, you should send 1 value. It's type is string. If you don't send this force3ds parameter, system check status of card. System uses iyzico-installmentInfo function.
- Redirect data will come to your return url. You should give returnUrl in purchase3d request.
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\Iyzico\IyzicoGateway; use Examples\Helper; $gateway = new IyzicoGateway(); $helper = new Helper(); try { $params = $helper->getPurchase3dParams(); $response = $gateway->purchase($params)->send(); $result = [ 'status' => $response->isSuccessful() ?: 0, 'redirect' => $response->isRedirect() ?: 0, 'redirectUrl' => $response->getRedirectUrl() ?: null, 'redirectData' => $response->getRedirectData(), 'htmlData' => $response->getThreeDHtmlContent(), 'message' => $response->getMessage(), 'transactionId' => $response->getTransactionReference(), 'requestParams' => $response->getServiceRequestParams(), 'response' => $response->getData() ]; print("<pre>" . print_r($result, true) . "</pre>"); } catch (Exception $e) { throw new \RuntimeException($e->getMessage()); }
Complete Purchase Example
- You can check completePurchase.php file in /examples folder.
- Request parameters are created from the data you receive as a result of the 3d payment request.
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\Iyzico\IyzicoGateway; use Examples\Helper; $gateway = new IyzicoGateway(); $helper = new Helper(); try { $params = $helper->getCompletePurchaseParams(); $response = $gateway->completePurchase($params)->send(); $result = [ 'status' => $response->isSuccessful() ?: 0, 'message' => $response->getMessage(), 'transactionId' => $response->getTransactionReference(), 'requestParams' => $response->getServiceRequestParams(), 'response' => $response->getData() ]; print("<pre>" . print_r($result, true) . "</pre>"); } catch (Exception $e) { throw new \RuntimeException($e->getMessage()); }
Cancel Example
- You can check cancel.php file in /examples folder.
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\Iyzico\IyzicoGateway; use Examples\Helper; $gateway = new IyzicoGateway(); $helper = new Helper(); try { $params = $helper->getCancelPurchaseParams(); $response = $gateway->cancel($params)->send(); $result = [ 'status' => $response->isSuccessful() ?: 0, 'cancel' => $response->isCancelled() ?: 0, 'message' => $response->getMessage(), 'transactionId' => $response->getTransactionReference(), 'requestParams' => $response->getServiceRequestParams(), 'response' => $response->getData() ]; print("<pre>" . print_r($result, true) . "</pre>"); } catch (Exception $e) { throw new \RuntimeException($e->getMessage()); }
Refund Example
- You can check refund.php file in /examples folder.
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\Iyzico\IyzicoGateway; use Examples\Helper; $gateway = new IyzicoGateway(); $helper = new Helper(); try { $params = $helper->getRefundParams(); $response = $gateway->refund($params)->send(); $result = [ 'status' => $response->isSuccessful() ?: 0, 'message' => $response->getMessage(), 'transactionId' => $response->getTransactionReference(), 'requestParams' => $response->getServiceRequestParams(), 'response' => $response->getData() ]; print("<pre>" . print_r($result, true) . "</pre>"); } catch (Exception $e) { throw new \RuntimeException($e->getMessage()); }
Purchase Transaction Detail Example
- You can check purchaseInfo.php file in /examples folder.
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\Iyzico\IyzicoGateway; use Examples\Helper; $gateway = new IyzicoGateway(); $helper = new Helper(); try { $params = $helper->getPurchaseInfoParams(); $response = $gateway->purchaseInfo($params)->send(); $result = [ 'status' => $response->isSuccessful() ?: 0, 'message' => $response->getMessage(), 'transactionId' => $response->getTransactionReference(), 'requestParams' => $response->getServiceRequestParams(), 'response' => $response->getData() ]; print("<pre>" . print_r($result, true) . "</pre>"); } catch (Exception $e) { throw new \RuntimeException($e->getMessage()); }
Installment Detail Example
- You can check installmentInfo.php file in /examples folder.
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\Iyzico\IyzicoGateway; use Examples\Helper; $gateway = new IyzicoGateway(); $helper = new Helper(); try { $params = $helper->getInstallmentInfoParams(); $response = $gateway->installmentInfo($params)->send(); $result = [ 'status' => $response->isSuccessful() ?: 0, 'message' => $response->getMessage(), 'transactionId' => $response->getTransactionReference(), 'requestParams' => $response->getServiceRequestParams(), 'response' => $response->getData() ]; print("<pre>" . print_r($result, true) . "</pre>"); } catch (Exception $e) { throw new \RuntimeException($e->getMessage()); }
requestParams:
System send request to Iyzico api. It shows request information.
Licensing
GNU General Public Licence v3.0
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.