Skip to content

Commit

Permalink
issue #160 integrate akode pos
Browse files Browse the repository at this point in the history
  • Loading branch information
nuryagdym committed Dec 10, 2023
1 parent 2c549ff commit bccbac3
Show file tree
Hide file tree
Showing 56 changed files with 3,728 additions and 42 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ Bu paket ile amaçlanan; ortak bir arayüz sınıfı ile, tüm Türk banka sanal

### Deskteklenen Payment Gateway'ler / Bankalar:

- **AKÖde**

Desktekleyen bankalar: Akbank

Desteklenen özellikler:
- NonSecure, 3DPay ve 3DHost ödeme
- Ödeme İptal ve İade
- Ödeme durum sorgulama
- Tarihçe sorgulama


- **EST POS** (Asseco/Payten)

Desktekleyen bankalar: Akbank, TEB, İşbank, Şekerbank, Halkbank ve Finansbank
Expand Down Expand Up @@ -115,10 +126,11 @@ Bu paket ile amaçlanan; ortak bir arayüz sınıfı ile, tüm Türk banka sanal
- 3D Secure modeliyle ödeme (`PosInterface::MODEL_3D_SECURE`)
- 3D Pay modeliyle ödeme (`PosInterface::MODEL_3D_PAY`)
- 3D Host modeliyle ödeme (`PosInterface::MODEL_3D_HOST`)
- Sipariş/Ödeme sorgulama (`PosInterface::TX_STATUS`)
- Sipariş/Ödeme durum sorgulama (`PosInterface::TX_STATUS`)
- Sipariş/Ödeme geçmişi sorgulama (`PosInterface::TX_HISTORY`)
- Sipariş/Para iadesi yapma (`PosInterface::TX_REFUND`)
- Sipariş iptal etme (`PosInterface::TX_CANCEL`)
- Farklı Para birimler ile ödeme desteği
- Tekrarlanan (Recurring) ödeme talimatları
- [PSR-3](https://www.php-fig.org/psr/psr-3/) logger desteği
- [PSR-18](https://www.php-fig.org/psr/psr-18/) HTTP Client desteği
Expand Down
9 changes: 9 additions & 0 deletions config/pos_production.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
'gateway_3d_host' => 'https://sanalpos.sanalakpos.com.tr/fim/est3Dgate',
],
],
'akode' => [
'name' => 'AKBANK T.A.S.',
'class' => Mews\Pos\Gateways\AkOdePos::class,
'gateway_endpoints' => [
'payment_api' => 'https://api.akodepos.com/api/Payment',
'gateway_3d' => 'https://api.akodepos.com/api/Payment/ProcessCardForm',
'gateway_3d_host' => 'https://api.akodepos.com/api/Payment/threeDSecure',
],
],
'finansbank' => [
'name' => 'QNB Finansbank',
'class' => Mews\Pos\Gateways\EstV3Pos::class,
Expand Down
9 changes: 9 additions & 0 deletions config/pos_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
'gateway_3d' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
],
],
'akode' => [
'name' => 'AKBANK T.A.S.',
'class' => Mews\Pos\Gateways\AkOdePos::class,
'gateway_endpoints' => [
'payment_api' => 'https://ent.akodepos.com/api/Payment',
'gateway_3d' => 'https://ent.akodepos.com/api/Payment/ProcessCardForm',
'gateway_3d_host' => 'https://ent.akodepos.com/api/Payment/threeDSecure',
],
],
'yapikredi' => [
'name' => 'Yapıkredi',
'class' => Mews\Pos\Gateways\PosNet::class,
Expand Down
1 change: 1 addition & 0 deletions examples/_common-codes/regular/cancel.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function createCancelOrder(PosInterface $pos, \Symfony\Component\HttpFoundation\
'currency' => $lastResponse['currency'] ?? PosInterface::CURRENCY_TRY,
'ref_ret_num' => $lastResponse['ref_ret_num'],
'ip' => filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ? $ip : '127.0.0.1',
'rand' => substr(md5(uniqid(time())), 0, 23), //AkOde
];

if (get_class($pos) === \Mews\Pos\Gateways\GarantiPos::class) {
Expand Down
3 changes: 3 additions & 0 deletions examples/_common-codes/regular/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
$session->set('order', $order);
$transaction = $request->get('tx', PosInterface::TX_PAY);

// examples'da post odeme butonu gostermek icin degeri kullanilir.
$session->set('tx', $transaction);

$card = createCard($pos, $request->request->all());

require '../../_templates/_payment_response.php';
1 change: 1 addition & 0 deletions examples/_common-codes/regular/post-auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function createPostPayOrder(PosInterface $pos, \Symfony\Component\HttpFoundation
'amount' => $lastResponse['amount'],
'currency' => $lastResponse['currency'] ?? PosInterface::CURRENCY_TRY,
'ip' => filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ? $ip : '127.0.0.1',
'rand' => substr(md5(uniqid(time())), 0, 23), //AkOde
];

if (get_class($pos) === \Mews\Pos\Gateways\PosNetV1Pos::class || get_class($pos) === \Mews\Pos\Gateways\PosNet::class) {
Expand Down
1 change: 1 addition & 0 deletions examples/_common-codes/regular/refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function createRefundOrder(PosInterface $pos, \Symfony\Component\HttpFoundation\
'currency' => $lastResponse['currency'] ?? PosInterface::CURRENCY_TRY,
'ref_ret_num' => $lastResponse['ref_ret_num'],
'ip' => filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ? $ip : '127.0.0.1',
'rand' => substr(md5(uniqid(time())), 0, 23), //AkOde
];

if (get_class($pos) === \Mews\Pos\Gateways\GarantiPos::class) {
Expand Down
1 change: 1 addition & 0 deletions examples/_common-codes/regular/status.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function createStatusOrder(PosInterface $pos, \Symfony\Component\HttpFoundation\
'id' => $lastResponse['order_id'], // MerchantOrderId
'currency' => $lastResponse['currency'] ?? PosInterface::CURRENCY_TRY,
'ip' => filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ? $ip : '127.0.0.1',
'rand' => substr(md5(uniqid(time())), 0, 23), //AkOde
];
if (get_class($pos) === \Mews\Pos\Gateways\KuveytPos::class) {
$statusOrder['remote_order_id'] = $lastResponse['remote_order_id']; // OrderId
Expand Down
2 changes: 1 addition & 1 deletion examples/_main_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function getNewOrder(
'fail_url' => $failUrl, // https://example.com/payment

// gateway'e gore zorunlu olan degerler
'rand' => md5(uniqid(time())), // EstPos, Garanti, PayFor, InterPos, VakifBank
'rand' => substr(md5(uniqid(time())), 0, 23), // AkOdePos, EstPos, Garanti, PayFor, InterPos, VakifBank
];

if ($lang) {
Expand Down
3 changes: 2 additions & 1 deletion examples/_templates/_header.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE HTML>
<html>
<html lang="tr">
<head>
<title><?= $templateTitle; ?></title>
<meta charset="UTF-8">
Expand Down Expand Up @@ -28,6 +28,7 @@
</div>
<nav class="collapse navbar-collapse" id="bs-navbar">
<ul class="nav navbar-nav">
<li> <a href="<?= $hostUrl ?>/akode/index.php">Ak Ode</a></li>
<li> <a href="<?= $hostUrl ?>/akbank/index.php">EST POS V3</a></li>
<li> <a href="<?= $hostUrl ?>/finansbank-payfor/index.php">PayFor (Finansbank)</a></li>
<li> <a href="<?= $hostUrl ?>/garanti/index.php">Garanti POS</a></li>
Expand Down
21 changes: 21 additions & 0 deletions examples/akode/3d-host/_config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

use Mews\Pos\PosInterface;

require '../_payment_config.php';

$baseUrl = $bankTestsUrl.'/3d-host/';
//account bilgileri kendi account bilgilerinizle degistiriniz
$account = \Mews\Pos\Factory\AccountFactory::createAkOdePosAccount(
'akode',
'1000000494',
'POS_ENT_Test_001',
'POS_ENT_Test_001!*!*',
);

$pos = getGateway($account, $eventDispatcher);

$transaction = PosInterface::TX_PAY;

$templateTitle = '3D Host Model Payment';
$paymentModel = PosInterface::MODEL_3D_HOST;
3 changes: 3 additions & 0 deletions examples/akode/3d-host/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require '../../_common-codes/3d-host/index.php';
4 changes: 4 additions & 0 deletions examples/akode/3d-host/response.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

$card = null;
require '../../_templates/_payment_response.php';
21 changes: 21 additions & 0 deletions examples/akode/3d-pay/_config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

use Mews\Pos\PosInterface;

require '../_payment_config.php';

$baseUrl = $bankTestsUrl.'/3d-pay/';
//account bilgileri kendi account bilgilerinizle degistiriniz
$account = \Mews\Pos\Factory\AccountFactory::createAkOdePosAccount(
'akode',
'1000000494',
'POS_ENT_Test_001',
'POS_ENT_Test_001!*!*',
);

$pos = getGateway($account, $eventDispatcher);

$transaction = $session->get('tx', PosInterface::TX_PAY);

$templateTitle = '3D Pay Model Payment';
$paymentModel = PosInterface::MODEL_3D_PAY;
3 changes: 3 additions & 0 deletions examples/akode/3d-pay/form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require '../../_common-codes/3d/form.php';
3 changes: 3 additions & 0 deletions examples/akode/3d-pay/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require '../../_common-codes/3d/index.php';
4 changes: 4 additions & 0 deletions examples/akode/3d-pay/response.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

$card = null;
require '../../_templates/_payment_response.php';
27 changes: 27 additions & 0 deletions examples/akode/_payment_config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use Mews\Pos\Entity\Card\CreditCardInterface;

require __DIR__.'/../_main_config.php';

$bankTestsUrl = $hostUrl.'/akode';
$posClass = \Mews\Pos\Gateways\AkOdePos::class;

$testCards = [
'visa1' => [
'number' => '4159560047417732',
'year' => '24',
'month' => '08',
'cvv' => '123',
'name' => 'John Doe',
'type' => CreditCardInterface::CARD_TYPE_VISA,
],
'master' => [
'number' => '5571135571135575',
'year' => '24',
'month' => '12',
'cvv' => '000',
'name' => 'John Doe',
'type' => CreditCardInterface::CARD_TYPE_VISA,
],
];
6 changes: 6 additions & 0 deletions examples/akode/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

$templateTitle = 'Ak Ode';
require './_payment_config.php';
require '../_templates/_header.php';
require '../_templates/_footer.php';
21 changes: 21 additions & 0 deletions examples/akode/regular/_config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

use Mews\Pos\PosInterface;

require '../_payment_config.php';

$baseUrl = $bankTestsUrl.'/regular/';
//account bilgileri kendi account bilgilerinizle degistiriniz
$account = \Mews\Pos\Factory\AccountFactory::createAkOdePosAccount(
'akode',
'1000000494',
'POS_ENT_Test_001',
'POS_ENT_Test_001!*!*',
);

$pos = getGateway($account, $eventDispatcher);

$transaction = $session->get('tx', PosInterface::TX_PAY);

$templateTitle = 'Regular Payment';
$paymentModel = PosInterface::MODEL_NON_SECURE;
3 changes: 3 additions & 0 deletions examples/akode/regular/cancel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require '../../_common-codes/regular/cancel.php';
3 changes: 3 additions & 0 deletions examples/akode/regular/form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require '../../_common-codes/regular/form.php';
26 changes: 26 additions & 0 deletions examples/akode/regular/history.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

use Mews\Pos\PosInterface;

$templateTitle = 'History Order';

require '_config.php';
require '../../_templates/_header.php';

$ord = $session->get('order');

$order = [
'id' => $ord ? $ord['id'] : '973009309',
'transactionDate' => new DateTime(), // odeme tarihi
'page' => 1, // optional, default: 1
'pageSize' => 10, // optional, default: 10
'rand' => substr(md5(uniqid(time())), 0, 23), //AkOde
];

$transaction = PosInterface::TX_HISTORY;
// History Order
$query = $pos->history($order);

$response = $query->getResponse();
require '../../_templates/_simple_response_dump.php';
require '../../_templates/_footer.php';
3 changes: 3 additions & 0 deletions examples/akode/regular/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require '../../_common-codes/3d/index.php';
3 changes: 3 additions & 0 deletions examples/akode/regular/post-auth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require '../../_common-codes/regular/post-auth.php';
3 changes: 3 additions & 0 deletions examples/akode/regular/refund.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require '../../_common-codes/regular/refund.php';
3 changes: 3 additions & 0 deletions examples/akode/regular/status.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require '../../_common-codes/regular/status.php';
13 changes: 12 additions & 1 deletion src/Crypt/AbstractCrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function hashFromParams(string $storeKey, array $data, string $hashParams
$paramsVal .= $this->recursiveFind($data, $paramKey);
}

$hashVal = $paramsVal.$storeKey;
$hashVal = $this->concatenateHashKey($storeKey, $paramsVal);

return $this->hashString($hashVal);
}
Expand All @@ -62,6 +62,17 @@ protected function hashString(string $str): string
return base64_encode(hash(static::HASH_ALGORITHM, $str, true));
}

/**
* @param string $hashKey
* @param string $hashString
*
* @return string
*/
protected function concatenateHashKey(string $hashKey, string $hashString): string
{
return $hashString.$hashKey;
}

/**
* @param array<string, mixed> $haystack (multidimensional) array
* @param string $needle key name that will be searched in the (multidimensional) array
Expand Down
Loading

0 comments on commit bccbac3

Please sign in to comment.