forked from mewebstudio/pos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_payment_response.php
160 lines (149 loc) · 5.91 KB
/
_payment_response.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
use Mews\Pos\Exceptions\HashMismatchException;
use Mews\Pos\Gateways\AbstractGateway;
use Symfony\Component\HttpFoundation\RedirectResponse;
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())
) {
echo new RedirectResponse($baseUrl);
exit();
}
if (AbstractGateway::TX_POST_PAY === $transaction) {
$order = $session->get('post_order');
} else {
$order = $session->get('order');
}
if (!$order) {
throw new Exception('Sipariş bulunamadı, session sıfırlanmış olabilir.');
}
$pos->prepare($order, $transaction);
try {
doPayment($pos, $transaction, $card);
} catch (HashMismatchException $e) {
dd($e);
}
$response = $pos->getResponse();
if ($pos->isSuccess()) {
// siparis iptal ve iade islemlerde kullanilir
$session->set('ref_ret_num', $response['ref_ret_num']);
}
$session->set('last_response', $response);
?>
<div class="result">
<h3 class="text-center text-<?= $pos->isSuccess() ? 'success' : 'danger'; ?>">
<?php if (AbstractGateway::TX_PAY === $transaction || AbstractGateway::TX_POST_PAY === $transaction) : ?>
<?= $pos->isSuccess() ? 'Payment is successful!' : 'Payment is not successful!'; ?>
<?php elseif (AbstractGateway::TX_PRE_PAY === $transaction) : ?>
<?= $pos->isSuccess() ? 'Pre Authorization is successful!' : 'Pre Authorization is not successful!'; ?>
<?php endif; ?>
</h3>
<hr>
<dl class="row">
<dt class="col-sm-3">Status:</dt>
<dd class="col-sm-9"><?= $response['status']; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">Order ID:</dt>
<dd class="col-sm-9"><?= $response['order_id'] ?: '-'; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">AuthCode:</dt>
<dd class="col-sm-9"><?= $response['auth_code'] ?: '-'; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">RetRefNum (iade, iptal, durum soruglama icin kullnilacak numara):</dt>
<dd class="col-sm-9"><?= $response['ref_ret_num'] ?: '-'; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">ProcReturnCode:</dt>
<dd class="col-sm-9"><?= $response['proc_return_code'] ?: '-'; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">Transaction ID:</dt>
<dd class="col-sm-9"><?= $response['trans_id'] ?: '-'; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">Error Code:</dt>
<dd class="col-sm-9"><?= $response['error_code'] ?: '-'; ?></dd>
</dl>
<dl class="row">
<dt class="col-sm-3">Status Detail:</dt>
<dd class="col-sm-9"><?= $response['status_detail'] ?: '-'; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">Error Message:</dt>
<dd class="col-sm-9"><?= $response['error_message'] ?: '-'; ?></dd>
</dl>
<?php if (AbstractGateway::MODEL_NON_SECURE !== $pos->getAccount()->getModel()): ?>
<dl class="row">
<dt class="col-sm-3">mdStatus:</dt>
<dd class="col-sm-9"><?= $response['md_status'] ?: '-'; ?></dd>
</dl>
<hr>
<hr>
<dl class="row">
<dt class="col-sm-3">Md Error Message:</dt>
<dd class="col-sm-9"><?= $response['md_error_message'] ?: '-'; ?></dd>
</dl>
<hr>
<dl class="row">
<dt class="col-sm-3">Transaction Security:</dt>
<dd class="col-sm-9"><?= $response['transaction_security']; ?></dd>
</dl>
<?php endif ?>
<hr>
<dl class="row">
<dt class="col-sm-12">All Data Dump:</dt>
<dd class="col-sm-12">
<pre><?php dump($response); ?></pre>
</dd>
</dl>
<hr>
<div class="text-right">
<?php if ($pos->isSuccess()) : ?>
<?php if (AbstractGateway::TX_PRE_PAY === $transaction) : ?>
<a href="<?= $bankTestsUrl ?>/regular/post-auth.php" class="btn btn-lg btn-primary">Finish provisioning
></a>
<?php endif; ?>
<?php if (AbstractGateway::TX_PAY === $transaction) : ?>
<a href="<?= $bankTestsUrl ?>/regular/cancel.php" class="btn btn-lg btn-danger">Cancel payment</a>
<?php endif; ?>
<a href="<?= $bankTestsUrl ?>/regular/status.php" class="btn btn-lg btn-default">Payment Status</a>
<?php endif; ?>
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
</div>
</div>
<script>
if (window.opener && window.opener !== window) {
// you are in a popup
// send result data to parent window
window.opener.parent.postMessage(`<?= json_encode($response); ?>`);
} else if (window.parent) {
// you are in iframe
// send result data to parent window
window.parent.postMessage(`<?= json_encode($response); ?>`);
}
</script>
<?php require __DIR__.'/_footer.php'; ?>