alegra / omnipay-iyzico

Iyzico支付网关用于Omnipay支付处理库

v0.0.23 2021-06-14 06:40 UTC

README

Build Status Total Downloads Latest Stable Version License

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文件夹中的示例。此文件夹仅用于显示示例,不是用于生产使用。
  • 在/exampless文件夹中首先
composer install

购买示例

  • 您可以在/exampless文件夹中检查purchase.php文件。
  • force3ds参数包含在参数中。它显示卡的状态。如果您测试直接购买,则应发送0值。它是字符串类型。如果您不发送此force3ds参数,系统将检查卡的状态。系统使用iyzico-installmentInfo函数。
<?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());
}

3D购买示例

  • 您可以在/exampless文件夹中检查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\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());
}

完成购买示例

  • 您可以在/exampless文件夹中检查completePurchase.php文件。
  • 请求参数是从3D支付请求的结果数据中创建的。
<?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());
}

取消示例

  • 您可以在/exampless文件夹中检查cancel.php文件。
<?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());
}

退款示例

  • 您可以在/exampless文件夹中检查refund.php文件。
<?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());
}

购买交易详情示例

  • 您可以在/exampless文件夹中检查purchaseInfo.php文件。
<?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());
}

分期详情示例

  • 您可以在/exampless文件夹中检查installmentInfo.php文件。
<?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

系统向Iyzico API发送请求。它显示请求信息。

许可

GNU通用公共许可证v3.0

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.