Skip to content

Commit

Permalink
issue #165 EstV3pos added callbackUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
nuryagdym committed Nov 18, 2023
1 parent f1a42a7 commit 0aa3372
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 13 deletions.
14 changes: 14 additions & 0 deletions examples/_templates/_payment_response.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
require_once '_config.php';
require '../../_templates/_header.php';

if ($pos instanceof \Mews\Pos\Gateways\EstV3Pos || $pos instanceof \Mews\Pos\Gateways\EstPos) {
/**
* Asseco'da callbackUrl == failUrl olarak tanimlidir.
* Eger kullanici 3D Auth sayfasinda islemini tamamlamadan tarayci sekmesini kapatirsa
* Asseco callbackUrl'a (yani failUrl'a) istek gonderir: https://github.com/mewebstudio/pos/issues/165
*/
$logger->info('payment response', [
'method' => $request->getMethod(),
'data_query' => $request->query->all(),
'data_request' => $request->request->all(),
]);
}


if (($request->getMethod() !== 'POST' && AbstractGateway::TX_POST_PAY !== $transaction)
// PayFlex-CP GET request ile cevapliyor
&& ($request->getMethod() === 'GET' && [] === $request->query->all())
Expand Down
1 change: 1 addition & 0 deletions src/Crypt/EstPosCrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function create3DHash(AbstractPosAccount $account, array $requestData, ?s
$txType,
$requestData['installment'],
$requestData['rand'],
$requestData['fail_url'], // callbackUrl
$account->getStoreKey(),
];

Expand Down
2 changes: 2 additions & 0 deletions src/DataMapper/EstPosRequestDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ public function create3DFormDataCommon(AbstractPosAccount $account, $order, stri
'oid' => $order->id,
'okUrl' => $order->success_url,
'failUrl' => $order->fail_url,
// musteri 3D onay sayfasinda islemleri tamamlamadan kapatirsa, banka bu sayfaya bir istek gonderecek.
'callbackUrl' => $order->fail_url,
'rnd' => $order->rand,
'lang' => $this->getLang($account, $order),
'currency' => $this->mapCurrency($order->currency),
Expand Down
4 changes: 2 additions & 2 deletions tests/Crypt/EstPosCryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testCreate3DHash()
'fail_url' => 'https://domain.com/fail_url',
'rand' => 'rand',
];
$expected = 'S7UxUAohxaxzl35WxHyDfuQx0sg=';
$expected = 'TN+2/D8lijFd+5zAUar6SH6EiRY=';

$actual = $this->crypt->create3DHash($this->threeDAccount, $order, 'Auth');
$this->assertEquals($expected, $actual);
Expand All @@ -73,7 +73,7 @@ public function testCreate3DHashFor3DPay()
'fail_url' => 'https://domain.com/fail_url',
'rand' => 'rand',
];
$expected = 'S7UxUAohxaxzl35WxHyDfuQx0sg=';
$expected = 'TN+2/D8lijFd+5zAUar6SH6EiRY=';

$actual = $this->crypt->create3DHash($this->threeDAccount, $requestData, 'Auth');
$this->assertEquals($expected, $actual);
Expand Down
18 changes: 11 additions & 7 deletions tests/DataMapper/EstPosRequestDataMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class EstPosRequestDataMapperTest extends TestCase
private $requestDataMapper;

private $order;

private $config;

protected function setUp(): void
Expand Down Expand Up @@ -67,7 +67,7 @@ protected function setUp(): void

$this->pos = PosFactory::createPosGateway($this->threeDAccount);
$this->pos->setTestMode(true);

$this->requestDataMapper = new EstPosRequestDataMapper(PosFactory::getGatewayCrypt(EstPos::class, new NullLogger()));
$this->card = CreditCardFactory::create($this->pos, '5555444433332222', '22', '01', '123', 'ahmet', AbstractCreditCard::CARD_TYPE_VISA);
}
Expand Down Expand Up @@ -314,13 +314,14 @@ public function testGet3DFormData()
$inputs = [
'clientid' => $account->getClientId(),
'storetype' => $account->getModel(),
'hash' => 'S7UxUAohxaxzl35WxHyDfuQx0sg=',
'hash' => 'TN+2/D8lijFd+5zAUar6SH6EiRY=',
'firmaadi' => $this->order['name'],
'Email' => $this->order['email'],
'amount' => $this->order['amount'],
'oid' => $this->order['id'],
'okUrl' => $this->order['success_url'],
'failUrl' => $this->order['fail_url'],
'callbackUrl' => $this->order['fail_url'],
'rnd' => $this->order['rand'],
'lang' => 'tr',
'currency' => 949,
Expand Down Expand Up @@ -393,18 +394,19 @@ public function testGet3DHostFormData()
$pos = PosFactory::createPosGateway($account);
$pos->setTestMode(true);
$pos->prepare($this->order, AbstractGateway::TX_PAY);

$gatewayURL = $this->config['banks'][$this->threeDAccount->getBank()]['urls']['gateway_3d_host']['test'];
$inputs = [
'clientid' => $account->getClientId(),
'storetype' => $account->getModel(),
'hash' => 'zQJGquP0/PXt6LeutjN1Qxq32Zg=',
'hash' => '4VS4GWS81j6YJWAuvJ0yEXvCsJM=',
'firmaadi' => $this->order['name'],
'Email' => $this->order['email'],
'amount' => $this->order['amount'],
'oid' => $this->order['id'],
'okUrl' => $this->order['success_url'],
'failUrl' => $this->order['fail_url'],
'callbackUrl' => $this->order['fail_url'],
'rnd' => $this->order['rand'],
'lang' => 'tr',
'currency' => '949',
Expand Down Expand Up @@ -522,6 +524,7 @@ public static function threeDFormDataProvider(): iterable
'oid' => 'order222',
'okUrl' => 'https://domain.com/success',
'failUrl' => 'https://domain.com/fail_url',
'callbackUrl' => 'https://domain.com/fail_url',
'rnd' => 'rand',
'lang' => 'tr',
'currency' => '949',
Expand All @@ -534,7 +537,7 @@ public static function threeDFormDataProvider(): iterable
'Ecom_Payment_Card_ExpDate_Month' => '01',
'Ecom_Payment_Card_ExpDate_Year' => '22',
'cv2' => '123',
'hash' => 'S7UxUAohxaxzl35WxHyDfuQx0sg=',
'hash' => 'TN+2/D8lijFd+5zAUar6SH6EiRY=',
],
],
];
Expand Down Expand Up @@ -563,6 +566,7 @@ public static function threeDFormDataProvider(): iterable
'oid' => 'order222',
'okUrl' => 'https://domain.com/success',
'failUrl' => 'https://domain.com/fail_url',
'callbackUrl' => 'https://domain.com/fail_url',
'rnd' => 'rand',
'lang' => 'tr',
'currency' => '949',
Expand All @@ -577,7 +581,7 @@ public static function threeDFormDataProvider(): iterable
'cv2' => '123',
'IMCKOD' => 'İmece Ürün Bilgisi',
'FDONEM' => 'Faizsiz Dönem Bilgisi',
'hash' => 'S7UxUAohxaxzl35WxHyDfuQx0sg=',
'hash' => 'TN+2/D8lijFd+5zAUar6SH6EiRY=',
],
],
];
Expand Down
11 changes: 7 additions & 4 deletions tests/DataMapper/EstV3PosRequestDataMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected function setUp(): void
'success_url' => 'https://domain.com/success',
'fail_url' => 'https://domain.com/fail_url',
'lang' => 'tr',
'rand' => microtime(),
'rand' => 'rand-21212',
];

$this->pos = PosFactory::createPosGateway($this->threeDAccount);
Expand Down Expand Up @@ -92,6 +92,7 @@ public function testGet3DFormData()
'oid' => $this->order['id'],
'okUrl' => $this->order['success_url'],
'failUrl' => $this->order['fail_url'],
'callbackUrl' => $this->order['fail_url'],
'rnd' => $this->order['rand'],
'hashAlgorithm' => 'ver3',
'lang' => 'tr',
Expand All @@ -100,7 +101,7 @@ public function testGet3DFormData()
'taksit' => '',
];

$hash = $this->requestDataMapper->getCrypt()->create3DHash($account, $inputs, $txType);
$hash = '7MGmDH2CY9jlFd4kVHwdvlyt07hIqkiBWVR8bkjAiaaRhK2XUHyvrDLqv0vlG6YY8bXChDkLfnDwVLi3Pvg5lQ==';
$inputs['hash'] = $hash;
$form = [
'gateway' => $gatewayURL,
Expand All @@ -123,7 +124,7 @@ public function testGet3DFormData()
$form['inputs']['cv2'] = $card->getCvv();

unset($form['inputs']['hash']);
$form['inputs']['hash'] = $this->requestDataMapper->getCrypt()->create3DHash($account, $form['inputs'], $txType);
$form['inputs']['hash'] = '7EgK2aMhS848ZMEkl2d0s1dFXlMhCy4LS5FFk+k/FbEmmVqBqx6TtQ1Yg7aW0KQa/5hrQODwBVT3SCUwfXHEsg==';

$this->assertEquals($form, $this->requestDataMapper->create3DFormData(
$this->pos->getAccount(),
Expand Down Expand Up @@ -163,6 +164,7 @@ public function testGet3DHostFormData()
'oid' => $this->order['id'],
'okUrl' => $this->order['success_url'],
'failUrl' => $this->order['fail_url'],
'callbackUrl' => $this->order['fail_url'],
'rnd' => $this->order['rand'],
'hashAlgorithm' => 'ver3',
'lang' => 'tr',
Expand All @@ -175,7 +177,8 @@ public function testGet3DHostFormData()
'method' => 'POST',
'inputs' => $inputs,
];
$form['inputs']['hash'] = $this->requestDataMapper->getCrypt()->create3DHash($account, $inputs, AbstractGateway::TX_PAY);

$form['inputs']['hash'] = 'pxvr9oG9G6v2AU/Lci3qs7OiBAwcvAaLotG5rorJVe31DJN/wlVDReWpqFSJojTLPs6pPiS1L1U+QkE0dJJBKw==';

$this->assertEquals($form, $this->requestDataMapper->create3DFormData(
$pos->getAccount(),
Expand Down

0 comments on commit 0aa3372

Please sign in to comment.