naimeken / omnipay-mobilexpress
适用于 Omnipay 支付处理库的 Mobilexpress 网关
v1.0.0
2024-03-26 01:17 UTC
Requires
- php: ^7.3 || ^8.0
- ext-dom: *
- ext-json: *
- ext-simplexml: *
- ext-soap: *
- omnipay/common: ^3
Requires (Dev)
README
Mobilexpress (Akbank, Alternatif Bank, Anadolu Bank, Deniz Bank, Finans Bank, Garanti, ING, Iyzico, İş Bankası, OdeaBank, Paratika, PayU, Şekerbank, Halkbank, ZiraatBank, TEB, VakıfBank, Türkiye Finans, YKB sanal pos) 网关,适用于 Omnipay 支付处理库
Omnipay 是一个适用于 PHP 7.3+ 的框架无关、多网关支付处理库。此包实现了 Omnipay 的 Gvp 在线支付网关支持。
- 您需要联系 Mobilexpress 以获取文档。
- 您可以从 https://test.mobilexpress.com.tr/checkout/v7/FastCheckoutService.asmx 检查 mobilexpress 服务。
- 您可以从 https://test.mobilexpress.com.tr/icerik/id/1247/Test-Kartlar?v=1 检查测试卡。
要求
- PHP >= 7.3.x,
- Omnipay V.3 仓库,
- PHPUnit 运行测试
自动加载
您必须安装 Omnipay V.3
composer require league/omnipay:^3
然后您必须安装 omnipay-mobilexpress 包
composer require alegra/omnipay-mobilexpress
payment-mobilexpress
的类遵循 PSR-4 命名约定,这意味着您可以轻松地在自己的自动加载器中集成payment-mobilexpress
类的加载。
基本用法
- 您可以使用 /examples 文件夹来执行示例。此文件夹仅用于显示示例,不适合生产使用。
- 在 /examples 文件夹中首先
composer install
授权示例
- 您可以在 /examples 文件夹中查看 authorize.php 文件。
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\MobilExpress\Gateway; use Examples\Helper; $gateway = new Gateway(); $helper = new Helper(); try { $params = $helper->getAuthorizeParams(); $response = $gateway->authorize($params)->send(); $result = [ 'status' => $response->isSuccessful() ?: 0, 'redirect' => $response->isRedirect() ?: 0, 'bankTransId' => $response->getTransactionReference(), 'mobileExpressTransId' => $response->getMobilExpressTransId(), 'message' => $response->getMessage(), 'requestParams' => $response->getServiceRequestParams(), 'response' => $response->getData() ]; print("<pre>" . print_r($result, true) . "</pre>"); } catch (Exception $e) { throw new \RuntimeException($e->getMessage()); }
捕获示例
- 您可以在 /examples 文件夹中查看 capture.php 文件。
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\MobilExpress\Gateway; use Examples\Helper; $gateway = new Gateway(); $helper = new Helper(); try { $params = $helper->getCaptureParams(); $response = $gateway->capture($params)->send(); $result = [ 'status' => $response->isSuccessful() ?: 0, 'redirect' => $response->isRedirect() ?: 0, 'bankTransId' => $response->getTransactionReference(), 'mobileExpressTransId' => $response->getMobilExpressTransId(), 'message' => $response->getMessage(), 'requestParams' => $response->getServiceRequestParams(), 'response' => $response->getData() ]; print("<pre>" . print_r($result, true) . "</pre>"); } catch (Exception $e) { throw new \RuntimeException($e->getMessage()); }
购买示例
- 您可以在 /examples 文件夹中查看 purchase.php 文件。
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\MobilExpress\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, 'bankTransId' => $response->getTransactionReference(), 'mobileExpressTransId' => $response->getMobilExpressTransId(), 'message' => $response->getMessage(), '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 文件。
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\MobilExpress\Gateway; use Examples\Helper; $gateway = new Gateway(); $helper = new Helper(); try { $params = $helper->getPurchase3DParams(); $response3d = $gateway->purchase($params)->send(); $result = [ 'status' => $response3d->isSuccessful() ?: 0, 'redirect' => $response3d->isRedirect() ?: 0, 'redirectUrl' => $response3d->getRedirectUrl(), 'redirectData' => $response3d->getRedirectData(), 'redirectMethod' => $response3d->getRedirectMethod(), 'mobileExpressTransId' => $response3d->getMobilExpressTransId(), 'message' => $response3d->getMessage(), 'requestParams' => $response3d->getServiceRequestParams(), 'response' => $response3d->getData() ]; print("<pre>" . print_r($result, true) . "</pre>"); } catch (Exception $e) { throw new \RuntimeException($e->getMessage()); }
完成购买示例
- 您可以在 /examples 文件夹中查看 completePurchase.php 文件。
- 请求参数是从 3d 支付请求的结果数据中创建的。
- 您可以在 3dVerification.php 中查看。它是 3DForm。
<?php $loader = require __DIR__ . '/vendor/autoload.php'; $loader->addPsr4('Examples\\', __DIR__); use Omnipay\MobilExpress\Gateway; use Examples\Helper; $gateway = new Gateway(); $helper = new Helper(); try { $params = $helper->getCompletePurchaseParams(); $response = $gateway->completePurchase($params)->send(); $result = [ 'status' => $response->isSuccessful() ?: 0, 'bankTransId' => $response->getTransactionReference(), 'mobileExpressTransId' => $response->getMobilExpressTransId(), 'message' => $response->getMessage(), '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\MobilExpress\Gateway; use Examples\Helper; $gateway = new Gateway(); $helper = new Helper(); try { $params = $helper->getRefundParams(); $response = $gateway->refund($params)->send(); $result = [ 'status' => $response->isSuccessful() ?: 0, 'redirect' => $response->isRedirect() ?: 0, 'message' => $response->getMessage(), '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\MobilExpress\Gateway; use Examples\Helper; $gateway = new Gateway(); $helper = new Helper(); try { $params = $helper->getVoidParams(); $response = $gateway->void($params)->send(); $result = [ 'status' => $response->isSuccessful() ?: 0, 'redirect' => $response->isRedirect() ?: 0, 'message' => $response->getMessage(), 'requestParams' => $response->getServiceRequestParams(), 'response' => $response->getData() ]; print("<pre>" . print_r($result, true) . "</pre>"); } catch (Exception $e) { throw new \RuntimeException($e->getMessage()); }
requestParams
系统向 mobilexpress api 发送请求。它显示请求信息。
许可
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.