Skip to content

Commit 55bdb2b

Browse files
authored
Merge pull request #1 from dipnot/dev
release: 1.0.0
2 parents 4c454af + 1847409 commit 55bdb2b

19 files changed

+1088
-2
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
composer.phar
2+
/vendor/
3+
.idea

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Dipnot
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 111 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,111 @@
1-
# ptt-akilliesnaf-php
2-
Unofficial PHP wrapper for PTT Akıllı Esnaf API
1+
2+
# PTT Akıllı Esnaf API Wrapper for PHP
3+
[![Latest Stable Version](https://poser.pugx.org/dipnot/ptt-akilliesnaf-php/v)](https://packagist.org/packages/dipnot/ptt-akilliesnaf-php) [![Total Downloads](https://poser.pugx.org/dipnot/ptt-akilliesnaf-php/downloads)](https://packagist.org/packages/dipnot/ptt-akilliesnaf-php)
4+
5+
Unofficial PHP wrapper for [PTT Akıllı Esnaf API](https://akilliesnaf.ptt.gov.tr/developer/)
6+
7+
We got a lot of help from the [sample codes](https://akilliesnaf.ptt.gov.tr/developer/#acik-kaynak).
8+
9+
Only covers `threeDSecure` (Ortak Ödeme Sayfası) and `inquiry` (Ödeme Sorgulama)
10+
11+
`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!
12+
13+
## Dependencies
14+
- PHP 5.6.36 or higher
15+
- ext-curl
16+
- ext-json
17+
18+
19+
## Installation
20+
You can install via [Composer](https://getcomposer.org/).
21+
22+
composer require dipnot/ptt-akilliesnaf-php
23+
24+
## Usage
25+
You can see the full example in [examples](https://github.com/dipnot/ptt-akilliesnaf-php/tree/main/examples) folder.
26+
### Config
27+
All request are needs a Config.
28+
```php
29+
use Dipnot\PttAkilliEsnaf\Config;
30+
31+
$config = new Config(true); // Don't forget to change it to "false" in production :)
32+
$config->setClientId("1000000032");
33+
$config->setApiUser("Entegrasyon_01");
34+
$config->setApiPass("gkk4l2*TY112");
35+
```
36+
37+
### Making a `threeDPayment` request
38+
```php
39+
use Dipnot\PttAkilliEsnaf\Enum\Currency;
40+
use Dipnot\PttAkilliEsnaf\Request\ThreeDPaymentRequest;
41+
42+
// $config = ...;
43+
44+
$orderId = "ORDERCODE" . time();
45+
46+
$threeDPaymentRequest = new ThreeDPaymentRequest($config);
47+
$threeDPaymentRequest->setCallbackUrl("http://localhost/ptt-akilliesnaf-php/examples/callback.php");
48+
$threeDPaymentRequest->setOrderId($orderId);
49+
$threeDPaymentRequest->setAmount(1000);
50+
$threeDPaymentRequest->setCurrency(Currency::TL);
51+
$threeDPaymentRequest->setInstallmentCount(1);
52+
53+
try {
54+
$request = $threeDPaymentRequest->execute();
55+
56+
?>
57+
<h1>Response:</h1>
58+
<?php
59+
echo "<pre>";
60+
print_r($request->getResponse());
61+
echo "</pre>";
62+
?>
63+
64+
<hr />
65+
66+
<h1>Payment iframe:</h1>
67+
<iframe src="<?= $request->getIframeUrl() ?>" width="1010" height="480"></iframe>
68+
<?php
69+
} catch(Exception $e) {
70+
echo $e->getMessage();
71+
}
72+
```
73+
74+
### Making an `inquiry` request
75+
```php
76+
use Dipnot\PttAkilliEsnaf\Request\InquiryRequest;
77+
78+
// $config = ...;
79+
80+
$orderId = "SAMPLEORDERCODE";
81+
82+
$inquiryRequest = new InquiryRequest($config);
83+
$inquiryRequest->setOrderId($orderId);
84+
85+
try {
86+
$request = $inquiryRequest->execute();
87+
?>
88+
89+
<h1>Response:</h1>
90+
<?php
91+
echo "<pre>";
92+
print_r($request->getResponse());
93+
echo "</pre>";
94+
} catch(Exception $e) {
95+
echo $e->getMessage();
96+
}
97+
```
98+
99+
## Test cards
100+
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.
101+
102+
||Value|
103+
|--|--|
104+
|Card holder|Fill randomly|
105+
|Card number|4159560047417732|
106+
|Card expiry date (Month/Year)|08/24|
107+
|Card CVV|123|
108+
|3D Secure code|You can get it under the countdown timer on the 3D Secure page|
109+
110+
## License
111+
[![License: MIT](https://img.shields.io/badge/License-MIT-%232fdcff)](https://github.com/dipnot/ptt-akilliesnaf-php/blob/main/LICENSE)

composer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "dipnot/ptt-akilliesnaf-php",
3+
"description": "Unofficial PHP wrapper for PTT Akıllı Esnaf API",
4+
"type": "library",
5+
"license": "MIT",
6+
"homepage": "https://www.dipnot.com.tr/",
7+
"keywords": [
8+
"api",
9+
"composer",
10+
"php library",
11+
"payment system",
12+
"ptt akıllı esnaf"
13+
],
14+
"authors": [
15+
{
16+
"name": "Dipnot and Contributors",
17+
"homepage": "https://github.com/dipnot/ptt-akilliesnaf-php/contributors"
18+
}
19+
],
20+
"require": {
21+
"php": ">=5.6.36",
22+
"ext-curl": "*",
23+
"ext-json": "*"
24+
},
25+
"autoload": {
26+
"psr-4": {
27+
"Dipnot\\": "src/Dipnot/"
28+
}
29+
}
30+
}

composer.lock

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/_config.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
use Dipnot\PttAkilliEsnaf\Config;
3+
4+
require_once("./../vendor/autoload.php");
5+
6+
// We may need to see the errors
7+
ini_set("display_startup_errors", 1);
8+
ini_set("display_errors", 1);
9+
error_reporting(-1);
10+
11+
// @see https://akilliesnaf.ptt.gov.tr/developer/#ortam-ve-test-kart-bilgileri
12+
$config = new Config(true);
13+
$config->setClientId("1000000032");
14+
$config->setApiUser("Entegrasyon_01");
15+
$config->setApiPass("gkk4l2*TY112");
16+
return $config;

examples/callback.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
use Dipnot\PttAkilliEsnaf\Response\PaymentCallbackResponse;
3+
4+
require_once("./../vendor/autoload.php");
5+
6+
// Config
7+
$config = require_once("./_config.php");
8+
9+
$paymentStatusResponse = new PaymentCallbackResponse($config);
10+
$paymentStatusResponse->setData($_POST);
11+
$response = $paymentStatusResponse->execute();
12+
13+
if($response->isPaymentSucceed()) {
14+
?>
15+
<h1>Payment succeed</h1>
16+
<p>OrderId: <?= $response->getOrderId() ?></p>
17+
<p>BankResponseMessage: <?= $response->getBankResponseMessage() ?></p>
18+
<?php
19+
echo "<pre>";
20+
print_r($response->getData());
21+
echo "</pre>";
22+
} else {
23+
?>
24+
<h1>Payment failed</h1>
25+
<p>OrderId: <?= $response->getOrderId() ?></p>
26+
<p>BankResponseMessage: <?= $response->getBankResponseMessage() ?></p>
27+
<?php
28+
echo "<pre>";
29+
print_r($response->getData());
30+
echo "</pre>";
31+
}

examples/index.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
use Dipnot\PttAkilliEsnaf\Enum\Currency;
3+
use Dipnot\PttAkilliEsnaf\Request\ThreeDPaymentRequest;
4+
5+
require_once("./../vendor/autoload.php");
6+
7+
// Config
8+
$config = require_once("./_config.php");
9+
10+
$orderId = "ORDERCODE" . time();
11+
$threeDPaymentRequest = new ThreeDPaymentRequest($config);
12+
$threeDPaymentRequest->setCallbackUrl("http://localhost:8081/ptt-akilliesnaf-php/examples/callback.php");
13+
$threeDPaymentRequest->setOrderId($orderId);
14+
$threeDPaymentRequest->setAmount(1000);
15+
$threeDPaymentRequest->setCurrency(Currency::TL);
16+
$threeDPaymentRequest->setInstallmentCount(1);
17+
18+
try {
19+
$request = $threeDPaymentRequest->execute();
20+
?>
21+
22+
<h1>Response:</h1>
23+
<?php
24+
echo "<pre>";
25+
print_r($request->getResponse());
26+
echo "</pre>";
27+
?>
28+
29+
<hr />
30+
31+
<h1>Payment iframe:</h1>
32+
<p>Will redirect to <?= $request->getCallbackUrl() ?></p>
33+
<p>Test cards</p>
34+
<ul>
35+
<li>Card holder: Fill randomly</li>
36+
<li>Card number: 4159560047417732</li>
37+
<li>Card expiry date (Month/Year): 08/24</li>
38+
<li>Card CVV: 123</li>
39+
<li>3D Secure code: You can get it under the countdown timer on the 3D Secure page</li>
40+
</ul>
41+
<iframe src="<?= $request->getIframeUrl() ?>" width="1010" height="480"></iframe>
42+
<?php
43+
} catch(Exception $e) {
44+
echo $e->getMessage();
45+
}

examples/inquiry.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
use Dipnot\PttAkilliEsnaf\Request\InquiryRequest;
3+
4+
require_once("./../vendor/autoload.php");
5+
6+
// Config
7+
$config = require_once("./_config.php");
8+
9+
$orderId = "SAMPLEORDERCODE";
10+
$inquiryRequest = new InquiryRequest($config);
11+
$inquiryRequest->setOrderId($orderId);
12+
13+
try {
14+
$request = $inquiryRequest->execute();
15+
?>
16+
17+
<h1>Response:</h1>
18+
<?php
19+
echo "<pre>";
20+
print_r($request->getResponse());
21+
echo "</pre>";
22+
} catch(Exception $e) {
23+
echo $e->getMessage();
24+
}

0 commit comments

Comments
 (0)