tcgunel/omnipay-paynet 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tcgunel/omnipay-paynet

最新稳定版本:v2.0.0

Composer 安装命令:

composer require tcgunel/omnipay-paynet

包简介

Omnipay extension for Paynet

README 文档

README

License

Omnipay Paynet Gateway

Omnipay gateway for Paynet - REST JSON API. All available methods of Paynet implemented for easy usage.

Requirements

PHP Package
^8.0 v1.0.0

Installation

composer require tcgunel/omnipay-paynet

Usage

Gateway Initialization

use Omnipay\Omnipay;

$gateway = Omnipay::create('Paynet');

$gateway->setSecretKey('YOUR_BASE64_ENCODED_SECRET_KEY');
$gateway->setTestMode(true); // Use test environment

Authentication

Paynet uses Basic Authentication with a base64-encoded secret key. Set this via setSecretKey().

  • Test URL: https://pts-api.paynet.com.tr
  • Live URL: https://api.paynet.com.tr

Methods

Payment Services

Direct Sale (Non-3D)

$response = $gateway->purchase([
    'amount'        => '150.00',
    'transactionId' => 'ORDER-12345',
    'installment'   => 1,
    'card'          => [
        'firstName'   => 'Test',
        'lastName'    => 'User',
        'number'      => '4155650100416111',
        'expiryMonth' => '01',
        'expiryYear'  => '2030',
        'cvv'         => '123',
        'email'       => 'test@example.com',
        'phone'       => '5551234567',
    ],
])->send();

if ($response->isSuccessful()) {
    $transactionRef = $response->getTransactionReference(); // xact_id
}

3D Secure Sale

// Step 1: Initiate 3D Secure
$response = $gateway->purchase3d([
    'amount'        => '250.00',
    'transactionId' => 'ORDER-3D-12345',
    'installment'   => 3,
    'returnUrl'     => 'https://example.com/payment/callback',
    'card'          => [
        'firstName'   => 'Test',
        'lastName'    => 'User',
        'number'      => '4155650100416111',
        'expiryMonth' => '01',
        'expiryYear'  => '2030',
        'cvv'         => '123',
        'email'       => 'test@example.com',
        'phone'       => '5551234567',
    ],
])->send();

if ($response->isRedirect()) {
    $htmlContent = $response->getHtmlContent();
    // Render $htmlContent to redirect user to 3D Secure page
}
// Step 2: Complete 3D Secure (after callback)
$response = $gateway->completePurchase([
    'sessionId' => $_POST['session_id'],
    'tokenId'   => $_POST['token_id'],
])->send();

if ($response->isSuccessful()) {
    $transactionRef = $response->getTransactionReference(); // xact_id
    $orderNumber    = $response->getTransactionId();        // reference_no
}

Cancel (Void)

$response = $gateway->void([
    'xactId' => 'PAY-TXN-00001',
])->send();

if ($response->isSuccessful()) {
    echo $response->getMessage();
}

Refund

$response = $gateway->refund([
    'xactId' => 'PAY-TXN-00001',
    'amount' => '50.00',
])->send();

if ($response->isSuccessful()) {
    echo $response->getMessage();
}

Query Services

Installment Query (BIN Based)

$response = $gateway->installmentQuery([
    'bin'           => '415565',
    'amount'        => '100.00',
    'addCommission' => true,
])->send();

if ($response->isSuccessful()) {
    $installments = $response->getInstallments();
    $bankInfo     = $response->getBankInfo();
    $tdsRequired  = $response->isTdsRequired();

    foreach ($installments as $inst) {
        echo "Taksit: {$inst['instalment']}, Toplam: {$inst['total_amount']}\n";
    }
}

API Endpoints

Method Endpoint Description
purchase /v2/transaction/payment Direct (non-3D) sale
purchase3d /v2/transaction/tds_initial 3D Secure sale initiation
completePurchase /v2/transaction/tds_charge Complete 3D Secure payment
void /v1/transaction/reversed_request Cancel (void) a transaction
refund /v1/transaction/reversed_request Refund a transaction
installmentQuery /v1/ratio/Get Query installment rates by BIN

Test Credentials

Contact Paynet for sandbox credentials. Test environment is available at https://pts-api.paynet.com.tr.

Set testMode to true to use the test environment:

$gateway->setTestMode(true);

Tests

composer test

For Windows:

vendor\bin\paratest.bat

License

MIT

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固