oytunyuksel / omnipay-iyzico
Iyzico网关为Omnipay支付处理库
v0.0.24
2022-02-17 14:02 UTC
Requires
- ext-dom: *
- ext-json: *
- iyzico/iyzipay-php: ^2
- omnipay/common: ^3
Requires (Dev)
- omnipay/tests: ^3
README
Iyzico网关为Omnipay V3支付处理库
Omnipay 是一个不依赖于框架、多网关的PHP 7.3+支付处理库。此包实现了Omnipay对Iyzico在线支付网关的支持。
Iyzico API 文档
需求
- PHP >= 7.3.x,
- Omnipay V.3 仓库,
- PHPUnit 运行测试
自动加载
您必须安装 Omnipay V.3
composer require league/omnipay:^3
然后您必须安装 Omnipay-payu 包
composer require alegra/omnipay-iyzico
payment-iyzico
遵循 PSR-4 命名约定,这意味着您可以轻松地将payment-iyzico
类加载到自己的自动加载器中。
基本用法
- 您可以使用 /examples 文件夹来执行示例。此文件夹仅用于显示示例,不适合生产使用。
- 在 /examples 文件夹中首先
composer install
购买示例
- 您可以在 /examples 文件夹中检查 purchase.php 文件。
- force3ds 参数包含在参数中。它显示了卡的状态。如果您测试直接购买,应发送 0 值。它是字符串类型。如果您不发送此 force3ds 参数,系统将检查卡的状态。系统使用 iyzico-installmentInfo 函数。
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\Iyzico\Gateway; use Examples\Helper; $gateway = new Gateway(); $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()); }
3D购买示例
- 您可以在 /examples 文件夹中检查 purchase3d.php 文件。
- force3ds 参数包含在参数中。它显示了卡的状态。如果您测试 3D 购买,应发送 1 值。它是字符串类型。如果您不发送此 force3ds 参数,系统将检查卡的状态。系统使用 iyzico-installmentInfo 函数。
- 重定向数据将发送到您的返回 URL。您应在 purchase3d 请求中提供 returnUrl。
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\Iyzico\Gateway; use Examples\Helper; $gateway = new Gateway(); $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()); }
完成购买示例
- 您可以在 /examples 文件夹中检查 completePurchase.php 文件。
- 请求参数是从 3D 支付请求的结果中创建的。
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\Iyzico\Gateway; use Examples\Helper; $gateway = new Gateway(); $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()); }
取消示例
- 您可以在 /examples 文件夹中检查 cancel.php 文件。
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\Iyzico\Gateway; use Examples\Helper; $gateway = new Gateway(); $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()); }
退款示例
- 您可以在 /examples 文件夹中检查 refund.php 文件。
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\Iyzico\Gateway; use Examples\Helper; $gateway = new Gateway(); $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()); }
购买交易详情示例
- 您可以在 /examples 文件夹中检查 purchaseInfo.php 文件。
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\Iyzico\Gateway; use Examples\Helper; $gateway = new Gateway(); $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()); }
分期详情示例
- 您可以在 /examples 文件夹中检查 installmentInfo.php 文件。
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\Iyzico\Gateway; use Examples\Helper; $gateway = new Gateway(); $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
系统向 Iyzico API 发送请求。它显示了请求信息。
许可
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.