Skip to content

Commit

Permalink
examples - created createPostPayOrder method
Browse files Browse the repository at this point in the history
  • Loading branch information
nuryagdym committed Oct 15, 2023
1 parent 8ee7233 commit 79f2034
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 146 deletions.
41 changes: 41 additions & 0 deletions examples/_common-codes/regular/post-auth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

use Mews\Pos\PosInterface;

require '_config.php';

$templateTitle = 'Post Auth Order (ön provizyonu tamamlama)';

function createPostPayOrder(PosInterface $pos, \Symfony\Component\HttpFoundation\Session\SessionInterface $session, string $ip): array
{
// PRE_PAY işlem sonucunda dönen $pos->getResponse() verisi
$lastResponse = $session->get('last_response');

if (!$lastResponse) {
throw new \LogicException('ödeme verisi bulunamadı, önce PRE_PAY ödemesi yapınız');
}

$postAuth = [
'id' => $lastResponse['order_id'],
'amount' => $lastResponse['amount'],
'currency' => $lastResponse['currency'] ?? PosInterface::CURRENCY_TRY,
'ip' => filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ? $ip : '127.0.0.1',
];

if (get_class($pos) === \Mews\Pos\Gateways\PosNetV1Pos::class || get_class($pos) === \Mews\Pos\Gateways\PosNet::class) {
$postAuth['installment'] = $lastResponse['installment'];
$postAuth['ref_ret_num'] = $lastResponse['ref_ret_num'];
}

return $postAuth;
}

$order = createPostPayOrder($pos, $session, $ip);
dump($order);


$session->set('post_order', $order);
$transaction = PosInterface::TX_POST_PAY;
$card = null;

require '../../_templates/_payment_response.php';
1 change: 1 addition & 0 deletions examples/_common-codes/regular/refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

function createRefundOrder(PosInterface $pos, \Symfony\Component\HttpFoundation\Session\SessionInterface $session, string $ip): array
{
// başarılı ödeme sonucu dönen $pos->getResponse() verisi
$lastResponse = $session->get('last_response');

if (!$lastResponse) {
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 @@ -8,6 +8,7 @@

function createStatusOrder(PosInterface $pos, \Symfony\Component\HttpFoundation\Session\SessionInterface $session, string $ip): array
{
// başarılı ödeme sonucunda dönen $pos->getResponse() verisi
$lastResponse = $session->get('last_response');

if (!$lastResponse) {
Expand Down
18 changes: 1 addition & 17 deletions examples/akbank/regular/post-auth.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
<?php

use Mews\Pos\PosInterface;

require '_config.php';

$templateTitle = 'Post Auth Order (ön provizyonu tamamlama)';

$ord = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', PosInterface::CURRENCY_TRY));

$order = [
'id' => $ord['id'],
];

$session->set('post_order', $order);
$transaction = PosInterface::TX_POST_PAY;
$card = null;

require '../../_templates/_payment_response.php';
require '../../_common-codes/regular/post-auth.php';
14 changes: 1 addition & 13 deletions examples/finansbank-payfor/regular/post-auth.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
<?php

use Mews\Pos\PosInterface;

require '_config.php';

$templateTitle = 'Post Auth Order (ön provizyonu tamamlama)';

$order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', PosInterface::CURRENCY_TRY));

$session->set('post_order', $order);
$transaction = PosInterface::TX_POST_PAY;
$card = null;

require '../../_templates/_payment_response.php';
require '../../_common-codes/regular/post-auth.php';
22 changes: 1 addition & 21 deletions examples/garanti/regular/post-auth.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
<?php

use Mews\Pos\PosInterface;

require '_config.php';

$templateTitle = 'Post Auth Order (ön provizyonu tamamlama)';

$order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', PosInterface::CURRENCY_TRY));

$order = [
'id' => $order['id'],
'amount' => $order['amount'],
'currency' => $order['currency'],
'ip' => $order['ip'],
'ref_ret_num' => '829603332856',
];

$session->set('post_order', $order);
$transaction = PosInterface::TX_POST_PAY;
$card = null;

require '../../_templates/_payment_response.php';
require '../../_common-codes/regular/post-auth.php';
14 changes: 1 addition & 13 deletions examples/interpos/regular/post-auth.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
<?php

use Mews\Pos\PosInterface;

require '_config.php';

$templateTitle = 'Post Auth Order (ön provizyonu tamamlama)';

$order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', PosInterface::CURRENCY_TRY));

$session->set('post_order', $order);
$transaction = PosInterface::TX_POST_PAY;
$card = null;

require '../../_templates/_payment_response.php';
require '../../_common-codes/regular/post-auth.php';
21 changes: 1 addition & 20 deletions examples/payflex-cp-v4/regular/post-auth.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
<?php

use Mews\Pos\PosInterface;

require '_config.php';

$templateTitle = 'Post Auth Order (ön provizyonu tamamlama)';

$order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', PosInterface::CURRENCY_TRY));

$order = [
'id' => $order['id'],
'amount' => $order['amount'],
'currency' => $order['currency'],
'ip' => $order['ip'],
];

$session->set('post_order', $order);
$transaction = PosInterface::TX_POST_PAY;
$card = null;

require '../../_templates/_payment_response.php';
require '../../_common-codes/regular/post-auth.php';
21 changes: 1 addition & 20 deletions examples/payflex-mpi-v4/regular/post-auth.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
<?php

use Mews\Pos\PosInterface;

require '_config.php';

$templateTitle = 'Post Auth Order (ön provizyonu tamamlama)';

$order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', PosInterface::CURRENCY_TRY));

$order = [
'id' => $order['id'],
'amount' => $order['amount'],
'currency' => $order['currency'],
'ip' => $order['ip'],
];

$session->set('post_order', $order);
$transaction = PosInterface::TX_POST_PAY;
$card = null;

require '../../_templates/_payment_response.php';
require '../../_common-codes/regular/post-auth.php';
22 changes: 1 addition & 21 deletions examples/posnet-v1/regular/post-auth.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
<?php

use Mews\Pos\PosInterface;

require '_config.php';

$templateTitle = 'Post Auth Order (ön provizyonu tamamlama)';

$order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', PosInterface::CURRENCY_TRY));

$order = [
'id' => $order['id'],
'amount' => $order['amount'],
'currency' => $order['currency'],
'installment' => $order['installment'],
'ref_ret_num' => '018711533790000181',
];

$session->set('post_order', $order);
$transaction = PosInterface::TX_POST_PAY;
$card = null;

require '../../_templates/_payment_response.php';
require '../../_common-codes/regular/post-auth.php';
22 changes: 1 addition & 21 deletions examples/ykb/regular/post-auth.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
<?php

use Mews\Pos\PosInterface;

require '_config.php';

$templateTitle = 'Post Auth Order (ön provizyonu tamamlama)';

$order = $session->get('order') ?: getNewOrder($baseUrl, $ip, $request->get('currency', PosInterface::CURRENCY_TRY));

$order = [
'id' => $order['id'],
'amount' => $order['amount'],
'currency' => $order['currency'],
'installment' => $order['installment'],
'ref_ret_num' => '018711533790000181',
];

$session->set('post_order', $order);
$transaction = PosInterface::TX_POST_PAY;
$card = null;

require '../../_templates/_payment_response.php';
require '../../_common-codes/regular/post-auth.php';

0 comments on commit 79f2034

Please sign in to comment.