Skip to content

Commit 382fe91

Browse files
committed
removed extra transaction check in LaraPay initalization
1 parent 63d9b11 commit 382fe91

File tree

2 files changed

+33
-30
lines changed

2 files changed

+33
-30
lines changed

src/Adapter/AdapterAbstract.php

-4
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ public function __construct(TransactionInterface $transaction, array $configs =
6565
{
6666
$this->transaction = $transaction;
6767

68-
if ($this->transaction->checkForRequestToken() == false) {
69-
throw new Exception('Due to checkForRequestToken() result, could not handle this transaction`s payment process');
70-
}
71-
7268
$this->setParameters($configs);
7369
$this->init();
7470
}

src/Adapter/Mellat.php

+33-26
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Tartan\Larapay\Adapter;
34

45
use SoapFault;
@@ -11,10 +12,10 @@
1112
*/
1213
class Mellat extends AdapterAbstract implements AdapterInterface
1314
{
14-
protected $WSDL = 'https://bpm.shaparak.ir/pgwchannel/services/pgw?wsdl';
15+
protected $WSDL = 'https://bpm.shaparak.ir/pgwchannel/services/pgw?wsdl';
1516
protected $endPoint = 'https://bpm.shaparak.ir/pgwchannel/startpay.mellat';
1617

17-
protected $testWSDL = 'http://banktest.ir/gateway/mellat/ws?wsdl';
18+
protected $testWSDL = 'http://banktest.ir/gateway/mellat/ws?wsdl';
1819
protected $testEndPoint = 'http://banktest.ir/gateway/mellat/gate';
1920

2021
protected $reverseSupport = true;
@@ -26,7 +27,7 @@ class Mellat extends AdapterAbstract implements AdapterInterface
2627
*/
2728
protected function requestToken()
2829
{
29-
if($this->getTransaction()->checkForRequestToken() == false) {
30+
if ($this->getTransaction()->checkForRequestToken() == false) {
3031
throw new Exception('larapay::larapay.could_not_request_payment');
3132
}
3233

@@ -66,9 +67,9 @@ protected function requestToken()
6667

6768
if ($response[0] == 0) {
6869
$this->getTransaction()->setGatewayToken($response[1]); // update transaction reference id
70+
6971
return $response[1];
70-
}
71-
else {
72+
} else {
7273
throw new Exception($response[0]);
7374
}
7475
} else {
@@ -83,15 +84,15 @@ protected function requestToken()
8384
* @return mixed
8485
* @throws Exception
8586
*/
86-
protected function generateForm ()
87+
protected function generateForm()
8788
{
8889
$refId = $this->requestToken();
8990

9091
return view('larapay::mellat-form', [
9192
'endPoint' => $this->getEndPoint(),
9293
'refId' => $refId,
9394
'submitLabel' => !empty($this->submit_label) ? $this->submit_label : trans("larapay::larapay.goto_gate"),
94-
'autoSubmit' => boolval($this->auto_submit)
95+
'autoSubmit' => boolval($this->auto_submit),
9596
]);
9697
}
9798

@@ -100,9 +101,9 @@ protected function generateForm ()
100101
* @throws Exception
101102
* @throws \Tartan\Larapay\Adapter\Exception
102103
*/
103-
protected function verifyTransaction ()
104+
protected function verifyTransaction()
104105
{
105-
if($this->getTransaction()->checkForVerify() == false) {
106+
if ($this->getTransaction()->checkForVerify() == false) {
106107
throw new Exception('larapay::larapay.could_not_verify_payment');
107108
}
108109

@@ -114,7 +115,7 @@ protected function verifyTransaction ()
114115
'ResCode',
115116
'SaleOrderId',
116117
'SaleReferenceId',
117-
'CardHolderInfo'
118+
'CardHolderInfo',
118119
]);
119120

120121
$sendParams = [
@@ -123,7 +124,7 @@ protected function verifyTransaction ()
123124
'userPassword' => $this->password,
124125
'orderId' => intval($this->SaleOrderId), // same as SaleOrderId
125126
'saleOrderId' => intval($this->SaleOrderId),
126-
'saleReferenceId' => intval($this->SaleReferenceId)
127+
'saleReferenceId' => intval($this->SaleReferenceId),
127128
];
128129

129130
$this->getTransaction()->setCardNumber($this->CardHolderInfo);
@@ -134,15 +135,16 @@ protected function verifyTransaction ()
134135
Log::debug('bpVerifyRequest call', $sendParams);
135136

136137
//$response = $soapClient->__soapCall('bpVerifyRequest', $sendParams);
137-
$response = $soapClient->bpVerifyRequest($sendParams);
138+
$response = $soapClient->bpVerifyRequest($sendParams);
138139

139140
if (isset($response->return)) {
140141
Log::info('bpVerifyRequest response', ['return' => $response->return]);
141142

142-
if($response->return != '0') {
143+
if ($response->return != '0') {
143144
throw new Exception($response->return);
144145
} else {
145146
$this->getTransaction()->setVerified();
147+
146148
return true;
147149
}
148150
} else {
@@ -160,9 +162,9 @@ protected function verifyTransaction ()
160162
* @throws Exception
161163
* @throws \Tartan\Larapay\Adapter\Exception
162164
*/
163-
public function inquiryTransaction ()
165+
public function inquiryTransaction()
164166
{
165-
if($this->getTransaction()->checkForInquiry() == false) {
167+
if ($this->getTransaction()->checkForInquiry() == false) {
166168
throw new Exception('larapay::larapay.could_not_inquiry_payment');
167169
}
168170

@@ -174,7 +176,7 @@ public function inquiryTransaction ()
174176
'ResCode',
175177
'SaleOrderId',
176178
'SaleReferenceId',
177-
'CardHolderInfo'
179+
'CardHolderInfo',
178180
]);
179181

180182
$sendParams = [
@@ -183,7 +185,7 @@ public function inquiryTransaction ()
183185
'userPassword' => $this->password,
184186
'orderId' => intval($this->SaleOrderId), // same as SaleOrderId
185187
'saleOrderId' => intval($this->SaleOrderId),
186-
'saleReferenceId' => intval($this->SaleReferenceId)
188+
'saleReferenceId' => intval($this->SaleReferenceId),
187189
];
188190

189191
$this->getTransaction()->setCardNumber($this->CardHolderInfo);
@@ -193,14 +195,15 @@ public function inquiryTransaction ()
193195

194196
Log::debug('bpInquiryRequest call', $sendParams);
195197
//$response = $soapClient->__soapCall('bpInquiryRequest', $sendParams);
196-
$response = $soapClient->bpInquiryRequest($sendParams);
198+
$response = $soapClient->bpInquiryRequest($sendParams);
197199

198200
if (isset($response->return)) {
199201
Log::info('bpInquiryRequest response', ['return' => $response->return]);
200-
if($response->return != '0') {
202+
if ($response->return != '0') {
201203
throw new Exception($response->return);
202204
} else {
203205
$this->getTransaction()->setVerified();
206+
204207
return true;
205208
}
206209
} else {
@@ -235,7 +238,7 @@ protected function settleTransaction()
235238
'ResCode',
236239
'SaleOrderId',
237240
'SaleReferenceId',
238-
'CardHolderInfo'
241+
'CardHolderInfo',
239242
]);
240243

241244
$sendParams = [
@@ -244,7 +247,7 @@ protected function settleTransaction()
244247
'userPassword' => $this->password,
245248
'orderId' => intval($this->SaleOrderId), // same as orderId
246249
'saleOrderId' => intval($this->SaleOrderId),
247-
'saleReferenceId' => intval($this->SaleReferenceId)
250+
'saleReferenceId' => intval($this->SaleReferenceId),
248251
];
249252

250253
try {
@@ -257,8 +260,9 @@ protected function settleTransaction()
257260
if (isset($response->return)) {
258261
Log::info('bpSettleRequest response', ['return' => $response->return]);
259262

260-
if($response->return == '0' || $response->return == '45') {
263+
if ($response->return == '0' || $response->return == '45') {
261264
$this->getTransaction()->setAfterVerified();
265+
262266
return true;
263267
} else {
264268
throw new Exception($response->return);
@@ -278,7 +282,7 @@ protected function settleTransaction()
278282
* @throws Exception
279283
* @throws \Tartan\Larapay\Adapter\Exception
280284
*/
281-
protected function reverseTransaction ()
285+
protected function reverseTransaction()
282286
{
283287
if ($this->reverseSupport == false || $this->getTransaction()->checkForReverse() == false) {
284288
throw new Exception('larapay::larapay.could_not_reverse_payment');
@@ -292,7 +296,7 @@ protected function reverseTransaction ()
292296
'ResCode',
293297
'SaleOrderId',
294298
'SaleReferenceId',
295-
'CardHolderInfo'
299+
'CardHolderInfo',
296300
]);
297301

298302
$sendParams = [
@@ -301,7 +305,7 @@ protected function reverseTransaction ()
301305
'userPassword' => $this->password,
302306
'orderId' => intval($this->SaleOrderId), // same as orderId
303307
'saleOrderId' => intval($this->SaleOrderId),
304-
'saleReferenceId' => intval($this->SaleReferenceId)
308+
'saleReferenceId' => intval($this->SaleReferenceId),
305309
];
306310

307311
try {
@@ -313,9 +317,10 @@ protected function reverseTransaction ()
313317

314318
Log::info('bpReversalRequest response', ['return' => $response->return]);
315319

316-
if (isset($response->return)){
320+
if (isset($response->return)) {
317321
if ($response->return == '0' || $response->return == '45') {
318322
$this->getTransaction()->setRefunded();
323+
319324
return true;
320325
} else {
321326
throw new Exception($response->return);
@@ -338,6 +343,7 @@ public function canContinueWithCallbackParameters(): bool
338343
if ($this->ResCode === "0" || $this->ResCode === 0) {
339344
return true;
340345
}
346+
341347
return false;
342348
}
343349

@@ -346,6 +352,7 @@ public function getGatewayReferenceId(): string
346352
$this->checkRequiredParameters([
347353
'RefId',
348354
]);
355+
349356
return $this->RefId;
350357
}
351358

0 commit comments

Comments
 (0)