dipnot/ptt-akilliesnaf-php

Unofficial PHP wrapper for PTT Akıllı Esnaf API

1.0.1 2022-07-23 10:59 UTC

This package is auto-updated.

Last update: 2024-10-23 15:45:00 UTC


README

Latest Stable Version Total Downloads

PTT Akıllı Esnaf API Wrapper for PHP

Unofficial PHP wrapper for PTT Akıllı Esnaf API

We got a lot of help from the sample codes.

Only covers threeDSecure (Ortak Ödeme Sayfası) and inquiry (Ödeme Sorgulama)

threeDPayment (3D ile Ödeme), void (İptal), refund (İade) or history (İşlem Listeleme) are not our goal currently. We would be happy to see your contributions!

Dependencies

  • PHP 5.6.36 or higher
  • ext-curl
  • ext-json

Installation

You can install via Composer.

composer require dipnot/ptt-akilliesnaf-php

Usage

You can see the full example in examples folder.

Config

All request are needs a Config.

use Dipnot\PttAkilliEsnaf\Config;

$config = new Config(true); // Don't forget to change it to "false" in production :)
$config->setClientId("1000000032");
$config->setApiUser("Entegrasyon_01");
$config->setApiPass("gkk4l2*TY112");

Making a threeDPayment request

use Dipnot\PttAkilliEsnaf\Enum\Currency;
use Dipnot\PttAkilliEsnaf\Request\ThreeDPaymentRequest;

// $config = ...;

$orderId = "ORDERCODE" . time();

$threeDPaymentRequest = new ThreeDPaymentRequest($config);
$threeDPaymentRequest->setCallbackUrl("http://localhost/ptt-akilliesnaf-php/examples/callback.php");
$threeDPaymentRequest->setOrderId($orderId);
$threeDPaymentRequest->setAmount(1000);
$threeDPaymentRequest->setCurrency(Currency::TL);
$threeDPaymentRequest->setInstallmentCount(1);

try {
    $request = $threeDPaymentRequest->execute();
    
    ?>
    <h1>Response:</h1>
    <?php
    echo "<pre>";
    print_r($request->getResponse());
    echo "</pre>";
    ?>

    <hr />

    <h1>Payment iframe:</h1>
    <iframe src="<?= $request->getIframeUrl() ?>" width="1010" height="480"></iframe>
    <?php
} catch(Exception $e) {
    echo $e->getMessage();
}

Making an inquiry request

use Dipnot\PttAkilliEsnaf\Request\InquiryRequest;

// $config = ...;

$orderId = "SAMPLEORDERCODE";

$inquiryRequest = new InquiryRequest($config);
$inquiryRequest->setOrderId($orderId);

try {
    $request = $inquiryRequest->execute();
    ?>

    <h1>Response:</h1>
    <?php
    echo "<pre>";
    print_r($request->getResponse());
    echo "</pre>";
} catch(Exception $e) {
    echo $e->getMessage();
}

Test cards

While developing the package, the test cards in the official documentation were not working. So we contacted the authorities and got the following values for testing.

License

License: MIT