From 79f20342d6e5fd17b091a50a274e7fd8a95b173c Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sun, 15 Oct 2023 17:44:19 +0200 Subject: [PATCH] examples - created createPostPayOrder method --- examples/_common-codes/regular/post-auth.php | 41 +++++++++++++++++++ examples/_common-codes/regular/refund.php | 1 + examples/_common-codes/regular/status.php | 1 + examples/akbank/regular/post-auth.php | 18 +------- .../finansbank-payfor/regular/post-auth.php | 14 +------ examples/garanti/regular/post-auth.php | 22 +--------- examples/interpos/regular/post-auth.php | 14 +------ examples/payflex-cp-v4/regular/post-auth.php | 21 +--------- examples/payflex-mpi-v4/regular/post-auth.php | 21 +--------- examples/posnet-v1/regular/post-auth.php | 22 +--------- examples/ykb/regular/post-auth.php | 22 +--------- 11 files changed, 51 insertions(+), 146 deletions(-) create mode 100644 examples/_common-codes/regular/post-auth.php diff --git a/examples/_common-codes/regular/post-auth.php b/examples/_common-codes/regular/post-auth.php new file mode 100644 index 00000000..66c9eb27 --- /dev/null +++ b/examples/_common-codes/regular/post-auth.php @@ -0,0 +1,41 @@ +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'; diff --git a/examples/_common-codes/regular/refund.php b/examples/_common-codes/regular/refund.php index 09f99089..70c1d478 100644 --- a/examples/_common-codes/regular/refund.php +++ b/examples/_common-codes/regular/refund.php @@ -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) { diff --git a/examples/_common-codes/regular/status.php b/examples/_common-codes/regular/status.php index 263bc32e..1b5f99b7 100644 --- a/examples/_common-codes/regular/status.php +++ b/examples/_common-codes/regular/status.php @@ -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) { diff --git a/examples/akbank/regular/post-auth.php b/examples/akbank/regular/post-auth.php index 99c4bd62..9cc72e09 100644 --- a/examples/akbank/regular/post-auth.php +++ b/examples/akbank/regular/post-auth.php @@ -1,19 +1,3 @@ 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'; diff --git a/examples/finansbank-payfor/regular/post-auth.php b/examples/finansbank-payfor/regular/post-auth.php index 7b5c4857..9cc72e09 100644 --- a/examples/finansbank-payfor/regular/post-auth.php +++ b/examples/finansbank-payfor/regular/post-auth.php @@ -1,15 +1,3 @@ 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'; diff --git a/examples/garanti/regular/post-auth.php b/examples/garanti/regular/post-auth.php index 4eea6eda..9cc72e09 100644 --- a/examples/garanti/regular/post-auth.php +++ b/examples/garanti/regular/post-auth.php @@ -1,23 +1,3 @@ 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'; diff --git a/examples/interpos/regular/post-auth.php b/examples/interpos/regular/post-auth.php index 7b5c4857..9cc72e09 100644 --- a/examples/interpos/regular/post-auth.php +++ b/examples/interpos/regular/post-auth.php @@ -1,15 +1,3 @@ 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'; diff --git a/examples/payflex-cp-v4/regular/post-auth.php b/examples/payflex-cp-v4/regular/post-auth.php index a3879b3e..9cc72e09 100644 --- a/examples/payflex-cp-v4/regular/post-auth.php +++ b/examples/payflex-cp-v4/regular/post-auth.php @@ -1,22 +1,3 @@ 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'; diff --git a/examples/payflex-mpi-v4/regular/post-auth.php b/examples/payflex-mpi-v4/regular/post-auth.php index a3879b3e..9cc72e09 100644 --- a/examples/payflex-mpi-v4/regular/post-auth.php +++ b/examples/payflex-mpi-v4/regular/post-auth.php @@ -1,22 +1,3 @@ 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'; diff --git a/examples/posnet-v1/regular/post-auth.php b/examples/posnet-v1/regular/post-auth.php index ad1bec46..9cc72e09 100644 --- a/examples/posnet-v1/regular/post-auth.php +++ b/examples/posnet-v1/regular/post-auth.php @@ -1,23 +1,3 @@ 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'; diff --git a/examples/ykb/regular/post-auth.php b/examples/ykb/regular/post-auth.php index ad1bec46..9cc72e09 100644 --- a/examples/ykb/regular/post-auth.php +++ b/examples/ykb/regular/post-auth.php @@ -1,23 +1,3 @@ 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';