Skip to content

Commit

Permalink
param integration initial
Browse files Browse the repository at this point in the history
  • Loading branch information
mustapayev committed Dec 28, 2024
1 parent 9152706 commit 89e038d
Show file tree
Hide file tree
Showing 36 changed files with 1,924 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"symfony/var-dumper": "^5.1"
},
"suggest": {
"ext-soap": "KuveytPos ile iptal/iade gibi ödeme olmayan işlemleri yapacaksanız."
"ext-soap": "ParamPos kullanacaksanız veya KuveytPos ile iptal/iade gibi ödeme olmayan işlemleri yapacaksanız."
},
"config": {
"sort-packages": true,
Expand Down
7 changes: 7 additions & 0 deletions config/pos_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
'gateway_3d_host' => 'https://virtualpospaymentgatewaypre.akbank.com/payhosting',
],
],
'param-pos' => [
'name' => 'TURK Elektronik Para A.Ş',
'class' => Mews\Pos\Gateways\ParamPos::class,
'gateway_endpoints' => [
'payment_api' => 'https://testposws.param.com.tr/turkpos.ws/service_turkpos_prod.asmx',
],
],
'payten_v3_hash' => [
'name' => 'AKBANK T.A.S.',
'class' => Mews\Pos\Gateways\EstV3Pos::class,
Expand Down
3 changes: 3 additions & 0 deletions examples/_templates/_header.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<li class="nav-item">
<a class="nav-link <?= $posClass === \Mews\Pos\Gateways\AkbankPos::class ? 'active' : ''; ?>" href="<?= $hostUrl ?>/akbankpos/index.php">Akbank POS</a>
</li>
<li class="nav-item">
<a class="nav-link <?= $posClass === \Mews\Pos\Gateways\ParamPos::class ? 'active' : ''; ?>" href="<?= $hostUrl ?>/parampos/index.php">Param POS</a>
</li>
<li class="nav-item">
<a class="nav-link <?= $posClass === \Mews\Pos\Gateways\EstV3Pos::class ? 'active' : ''; ?>" href="<?= $hostUrl ?>/payten/index.php">Payten V3</a>
</li>
Expand Down
22 changes: 22 additions & 0 deletions examples/parampos/3d-host/_config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

use Mews\Pos\PosInterface;

require '../_payment_config.php';

$baseUrl = $bankTestsUrl.'/3d-host/';
//account bilgileri kendi account bilgilerinizle degistiriniz
$account = \Mews\Pos\Factory\AccountFactory::createAkbankPosAccount(
'akbank-pos',
'2023090417500272654BD9A49CF07574',
'2023090417500284633D137A249DBBEB',
'3230323330393034313735303032363031353172675f357637355f3273387373745f7233725f73323333383737335f323272383774767276327672323531355f',
PosInterface::LANG_TR
);

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

$transaction = PosInterface::TX_TYPE_PAY_AUTH;

$templateTitle = '3D Host Model Payment';
$paymentModel = PosInterface::MODEL_3D_HOST;
3 changes: 3 additions & 0 deletions examples/parampos/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';
3 changes: 3 additions & 0 deletions examples/parampos/3d-host/response.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require '../../_templates/_payment_secure_response.php';
22 changes: 22 additions & 0 deletions examples/parampos/3d-pay/_config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

use Mews\Pos\PosInterface;

require '../_payment_config.php';

$baseUrl = $bankTestsUrl.'/3d-pay/';
//account bilgileri kendi account bilgilerinizle degistiriniz
$account = \Mews\Pos\Factory\AccountFactory::createAkbankPosAccount(
'akbank-pos',
'2023090417500272654BD9A49CF07574',
'2023090417500284633D137A249DBBEB',
'3230323330393034313735303032363031353172675f357637355f3273387373745f7233725f73323333383737335f323272383774767276327672323531355f',
PosInterface::LANG_TR
);

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

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

$templateTitle = '3D Pay Model Payment';
$paymentModel = PosInterface::MODEL_3D_PAY;
3 changes: 3 additions & 0 deletions examples/parampos/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/parampos/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';
3 changes: 3 additions & 0 deletions examples/parampos/3d-pay/response.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require '../../_templates/_payment_secure_response.php';
22 changes: 22 additions & 0 deletions examples/parampos/3d/_config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

use Mews\Pos\PosInterface;

require '../_payment_config.php';

$baseUrl = $bankTestsUrl.'/3d/';
//account bilgileri kendi account bilgilerinizle degistiriniz
$account = \Mews\Pos\Factory\AccountFactory::createParamPosAccount(
'param-pos',
10738,
'Test',
'Test',
'0c13d406-873b-403b-9c09-a5766840d98c'
);

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

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

$templateTitle = '3D Model Payment';
$paymentModel = PosInterface::MODEL_3D_SECURE;
3 changes: 3 additions & 0 deletions examples/parampos/3d/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/parampos/3d/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/parampos/3d/response.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require '../../_templates/_payment_secure_response.php';
17 changes: 17 additions & 0 deletions examples/parampos/_payment_config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

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

$bankTestsUrl = $hostUrl.'/parampos';
$posClass = \Mews\Pos\Gateways\ParamPos::class;

$testCards = [
'visa1' => [
// OTP 123456
'number' => '4446763125813623',
'year' => '26',
'month' => '12',
'cvv' => '000',
'name' => 'John Doe',
],
];
6 changes: 6 additions & 0 deletions examples/parampos/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

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

use Mews\Pos\PosInterface;

require '../_payment_config.php';

$baseUrl = $bankTestsUrl.'/regular/';
//account bilgileri kendi account bilgilerinizle degistiriniz
$account = \Mews\Pos\Factory\AccountFactory::createAkbankPosAccount(
'akbank-pos',
'2023090417500272654BD9A49CF07574',
'2023090417500284633D137A249DBBEB',
'3230323330393034313735303032363031353172675f357637355f3273387373745f7233725f73323333383737335f323272383774767276327672323531355f',
PosInterface::LANG_TR
);

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

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

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

require '../../_common-codes/regular/custom_query.php';

function getCustomRequestData(): array
{
return [
[
'txnCode' => '1020',
'order' => [
'orderTrackId' => 'ae15a6c8-467e-45de-b24c-b98821a42667',
],
'payByLink' => [
'linkTxnCode' => '3000',
'linkTransferType' => 'SMS',
'mobilePhoneNumber' => '5321234567',
],
'transaction' => [
'amount' => 1.00,
'currencyCode' => 949,
'motoInd' => 0,
'installCount' => 1,
],
],
null,
];
}
3 changes: 3 additions & 0 deletions examples/parampos/regular/form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

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

require '../../_common-codes/regular/history.php';
3 changes: 3 additions & 0 deletions examples/parampos/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/parampos/regular/order_history.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require '../../_common-codes/regular/order_history.php';
3 changes: 3 additions & 0 deletions examples/parampos/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/parampos/regular/refund.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require '../../_common-codes/regular/refund.php';
84 changes: 84 additions & 0 deletions src/Crypt/ParamPosCrypt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

/**
* @license MIT
*/

namespace Mews\Pos\Crypt;

use Mews\Pos\Entity\Account\AbstractPosAccount;
use Mews\Pos\Exceptions\NotImplementedException;

class ParamPosCrypt extends AbstractCrypt
{
/**
* todo remove?
* {@inheritDoc}
*/
public function create3DHash(AbstractPosAccount $posAccount, array $formInputs): string
{
$hashData = [
$formInputs['clientid'],
$formInputs['oid'],
$formInputs['amount'],
$formInputs['okUrl'],
$formInputs['failUrl'],
$formInputs['islemtipi'],
$formInputs['taksit'],
$formInputs['rnd'],
$posAccount->getStoreKey(),
];

$hashStr = \implode(static::HASH_SEPARATOR, $hashData);

return $this->hashString($hashStr);
}

/**
* {@inheritdoc}
*/
public function check3DHash(AbstractPosAccount $posAccount, array $data): bool
{
if (null === $posAccount->getStoreKey()) {
throw new \LogicException('Account storeKey eksik!');
}

$actualHash = $this->hashFromParams($posAccount->getStoreKey(), $data, 'HASHPARAMS', ':');

if ($data['HASH'] === $actualHash) {
$this->logger->debug('hash check is successful');

return true;
}

$this->logger->error('hash check failed', [
'data' => $data,
'generated_hash' => $actualHash,
'expected_hash' => $data['HASH'],
]);

return false;
}

/**
* @inheritDoc
*/
public function createHash(AbstractPosAccount $posAccount, array $requestData): string
{
$map = [
$requestData['G']['CLIENT_CODE'],
$requestData['GUID'],
$requestData['Taksit'] ?? '',
$requestData['Islem_Tutar'],
$requestData['Toplam_Tutar'],
$requestData['Siparis_ID'],
$requestData['Hata_URL'] ?? '',
$requestData['Basarili_URL'] ?? '',
];

$hashStr = \implode(static::HASH_SEPARATOR, $map);
$hashStr = mb_convert_encoding($hashStr, 'ISO-8859-9');

return $this->hashString($hashStr, self::HASH_ALGORITHM);
}
}
Loading

0 comments on commit 89e038d

Please sign in to comment.