Skip to content

Commit e0c9764

Browse files
committed
fixed some incompatibility with PHP strict_types
1 parent 46e3feb commit e0c9764

File tree

16 files changed

+126
-125
lines changed

16 files changed

+126
-125
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ composer require tartan/laravel-online-payment
5454

5555
```php
5656
Tartan\Larapay\LarapayServiceProvider::class,
57+
Tartan\Log\XLogServiceProvider::class,
5758
```
5859
3. Add package alias to your app aliases:
5960

6061
```php
6162
'Larapay' => Tartan\Larapay\Facades\Larapay::class,
63+
'XLog' => Tartan\Log\Facades\XLog::class,
6264
```
6365
4. Publish package assets and configs
6466

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
"require": {
1818
"php": ">=7.0.0",
1919
"ext-soap" : "*",
20-
"illuminate/contracts": "~5.6.0|^6.0|^7.0",
20+
"ext-json": "*",
21+
"illuminate/contracts": "~5.6.0|^6.0|^7.0",
2122
"illuminate/database": "~5.6.0|^6.0|^7.0",
2223
"illuminate/http": "~5.6.0|^6.0|^7.0",
2324
"illuminate/routing": "~5.6.0|^6.0|^7.0",
2425
"illuminate/support": "~5.6.0|^6.0|^7.0",
2526
"illuminate/view": "~5.6.0|^6.0|^7.0",
2627
"tartan/laravel-xlog": "^1.0"
27-
},
28+
},
2829
"require-dev": {
2930
"mockery/mockery": "^1.0",
3031
"orchestra/testbench": "^3.8|^4.0|^5.0",

src/Adapter/AdapterAbstract.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use SoapClient;
66
use Tartan\Larapay\Transaction\TransactionInterface;
7-
use Illuminate\Support\Facades\Log;
7+
use Tartan\Log\Facades\XLog;
88

99
/**
1010
* Class AdapterAbstract
@@ -230,7 +230,7 @@ protected function getEndPoint(): string
230230
*/
231231
public function setSoapOptions(array $options = [])
232232
{
233-
Log::debug('soap options set', $options);
233+
XLog::debug('soap options set', $options);
234234
$this->soapOptions = $options;
235235
}
236236

src/Adapter/Mellat.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
2+
declare(strict_types=1);
23

34
namespace Tartan\Larapay\Adapter;
45

56
use SoapFault;
67
use Tartan\Larapay\Adapter\Mellat\Exception;
7-
use Illuminate\Support\Facades\Log;
8+
use Tartan\Log\Facades\XLog;
89

910
/**
1011
* Class Mellat
@@ -56,12 +57,12 @@ protected function requestToken()
5657
try {
5758
$soapClient = $this->getSoapClient();
5859

59-
Log::debug('bpPayRequest call', $sendParams);
60+
XLog::debug('bpPayRequest call', $sendParams);
6061

6162
$response = $soapClient->bpPayRequest($sendParams);
6263

6364
if (isset($response->return)) {
64-
Log::info('bpPayRequest response', ['return' => $response->return]);
65+
XLog::info('bpPayRequest response', ['return' => $response->return]);
6566

6667
$response = explode(',', $response->return);
6768

@@ -84,7 +85,7 @@ protected function requestToken()
8485
* @return mixed
8586
* @throws Exception
8687
*/
87-
protected function generateForm()
88+
protected function generateForm(): string
8889
{
8990
$refId = $this->requestToken();
9091

@@ -142,18 +143,18 @@ protected function verifyTransaction()
142143
'saleReferenceId' => intval($this->SaleReferenceId),
143144
];
144145

145-
$this->getTransaction()->setCardNumber($this->CardHolderInfo);
146+
$this->getTransaction()->setCardNumber(strval($this->CardHolderInfo));
146147

147148
try {
148149
$soapClient = $this->getSoapClient();
149150

150-
Log::debug('bpVerifyRequest call', $sendParams);
151+
XLog::debug('bpVerifyRequest call', $sendParams);
151152

152153
//$response = $soapClient->__soapCall('bpVerifyRequest', $sendParams);
153154
$response = $soapClient->bpVerifyRequest($sendParams);
154155

155156
if (isset($response->return)) {
156-
Log::info('bpVerifyRequest response', ['return' => $response->return]);
157+
XLog::info('bpVerifyRequest response', ['return' => $response->return]);
157158

158159
if ($response->return != '0') {
159160
throw new Exception($response->return);
@@ -203,17 +204,17 @@ public function inquiryTransaction()
203204
'saleReferenceId' => intval($this->SaleReferenceId),
204205
];
205206

206-
$this->getTransaction()->setCardNumber($this->CardHolderInfo);
207+
$this->getTransaction()->setCardNumber(strval($this->CardHolderInfo));
207208

208209
try {
209210
$soapClient = $this->getSoapClient();
210211

211-
Log::debug('bpInquiryRequest call', $sendParams);
212+
XLog::debug('bpInquiryRequest call', $sendParams);
212213
//$response = $soapClient->__soapCall('bpInquiryRequest', $sendParams);
213214
$response = $soapClient->bpInquiryRequest($sendParams);
214215

215216
if (isset($response->return)) {
216-
Log::info('bpInquiryRequest response', ['return' => $response->return]);
217+
XLog::info('bpInquiryRequest response', ['return' => $response->return]);
217218
if ($response->return != '0') {
218219
throw new Exception($response->return);
219220
} else {
@@ -268,12 +269,12 @@ protected function settleTransaction()
268269
try {
269270
$soapClient = $this->getSoapClient();
270271

271-
Log::debug('bpSettleRequest call', $sendParams);
272+
XLog::debug('bpSettleRequest call', $sendParams);
272273
//$response = $soapClient->__soapCall('bpSettleRequest', $sendParams);
273274
$response = $soapClient->bpSettleRequest($sendParams);
274275

275276
if (isset($response->return)) {
276-
Log::info('bpSettleRequest response', ['return' => $response->return]);
277+
XLog::info('bpSettleRequest response', ['return' => $response->return]);
277278

278279
if ($response->return == '0' || $response->return == '45') {
279280
$this->getTransaction()->setAfterVerified();
@@ -326,11 +327,11 @@ protected function reverseTransaction(): bool
326327
try {
327328
$soapClient = $this->getSoapClient();
328329

329-
Log::debug('bpReversalRequest call', $sendParams);
330+
XLog::debug('bpReversalRequest call', $sendParams);
330331
//$response = $soapClient->__soapCall('bpReversalRequest', $sendParams);
331332
$response = $soapClient->bpReversalRequest($sendParams);
332333

333-
Log::info('bpReversalRequest response', ['return' => $response->return]);
334+
XLog::info('bpReversalRequest response', ['return' => $response->return]);
334335

335336
if (isset($response->return)) {
336337
if ($response->return == '0' || $response->return == '45') {
@@ -368,7 +369,7 @@ public function getGatewayReferenceId(): string
368369
'RefId',
369370
]);
370371

371-
return $this->RefId;
372+
return strval($this->RefId);
372373
}
373374

374375
public function afterVerify(): bool

src/Adapter/Parsian.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Tartan\Larapay\Adapter;
46

57
use SoapFault;
68
use Tartan\Larapay\Adapter\Parsian\Exception;
7-
use Illuminate\Support\Facades\Log;
9+
use Tartan\Log\Facades\XLog;
810

911
/**
1012
* Class Parsian
@@ -68,11 +70,11 @@ protected function requestToken()
6870
$this->requestType = 'request';
6971
$soapClient = $this->getSoapClient();
7072

71-
Log::debug('SalePaymentRequest call', $sendParams);
73+
XLog::debug('SalePaymentRequest call', $sendParams);
7274

7375
$response = $soapClient->SalePaymentRequest(array("requestData" => $sendParams));
7476

75-
Log::debug('SalePaymentRequest response', $this->obj2array($response));
77+
XLog::debug('SalePaymentRequest response', $this->obj2array($response));
7678

7779
if (isset($response->SalePaymentRequestResult->Status, $response->SalePaymentRequestResult->Token)) {
7880
if ($response->SalePaymentRequestResult->Status == 0) {
@@ -152,11 +154,11 @@ protected function verifyTransaction(): bool
152154
$soapClient = $this->getSoapClient();
153155

154156

155-
Log::debug('ConfirmPayment call', $sendParams);
157+
XLog::debug('ConfirmPayment call', $sendParams);
156158

157159
$response = $soapClient->ConfirmPayment(array("requestData" => $sendParams));
158160

159-
Log::debug('ConfirmPayment response', $this->obj2array($response));
161+
XLog::debug('ConfirmPayment response', $this->obj2array($response));
160162

161163
if (isset($response->ConfirmPaymentResult)) {
162164
if ($response->ConfirmPaymentResult->Status == 0) {
@@ -201,11 +203,11 @@ protected function reverseTransaction(): bool
201203

202204
try {
203205
$soapClient = $this->getSoapClient();
204-
Log::debug('ReversalRequest call', $sendParams);
206+
XLog::debug('ReversalRequest call', $sendParams);
205207

206208
$response = $soapClient->ReversalRequest(array("requestData" => $sendParams));
207209

208-
Log::debug('ReversalRequest response', $this->obj2array($response));
210+
XLog::debug('ReversalRequest response', $this->obj2array($response));
209211

210212
if (isset($response->ReversalRequestResult->Status)) {
211213
if ($response->ReversalRequestResult->Status == 0) {
@@ -229,7 +231,7 @@ public function getGatewayReferenceId(): string
229231
'Token',
230232
]);
231233

232-
return $this->Token;
234+
return strval($this->Token);
233235
}
234236

235237

src/Adapter/Pasargad.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
namespace Tartan\Larapay\Adapter;
36

4-
use Illuminate\Support\Facades\Log;
7+
use Tartan\Log\Facades\XLog;
58
use Tartan\Larapay\Adapter\Pasargad\Helper;
69
use Tartan\Larapay\Adapter\Pasargad\RSAKeyType;
710
use Tartan\Larapay\Adapter\Pasargad\RSAProcessor;
@@ -142,11 +145,11 @@ protected function verifyTransaction(): bool
142145
$timeStamp = date("Y/m/d H:i:s");
143146

144147
$data = "#" . $merchantCode . "#" . $terminalCode . "#" . $invoiceNumber . "#" . $invoiceDate . "#" . $amount . "#" . $timeStamp . "#";
145-
Log::debug('pasargad generated sign string: ' . $data);
148+
XLog::debug('pasargad generated sign string: ' . $data);
146149
$data = sha1($data, true);
147150
$data = $processor->sign($data); // امضاي ديجيتال
148151
$sign = base64_encode($data); // base64_encode
149-
Log::debug('pasargad generated hash: ' . $sign);
152+
XLog::debug('pasargad generated hash: ' . $sign);
150153

151154
$parameters = compact(
152155
'terminalCode',
@@ -165,7 +168,7 @@ protected function verifyTransaction(): bool
165168
'invoiceDate' => $this->iD
166169
]);
167170

168-
Log::debug('pasargad verify parseXML result', $array);
171+
XLog::debug('pasargad verify parseXML result', $array);
169172

170173
if ($array['actionResult']['result'] != "True") {
171174
throw new Exception('larapay::larapay.verification_failed');
@@ -224,7 +227,7 @@ protected function reverseTransaction(): bool
224227
'invoiceDate' => $this->iD
225228
]);
226229

227-
Log::debug('pasargad refund parseXML result', $array);
230+
XLog::debug('pasargad refund parseXML result', $array);
228231

229232
if ($array['actionResult']['result'] != "True") {
230233
throw new Exception('larapay::larapay.reversed_failed');
@@ -288,6 +291,6 @@ public function getGatewayReferenceId(): string
288291
'tref',
289292
]);
290293

291-
return $this->tref;
294+
return strval($this->tref);
292295
}
293296
}

src/Adapter/Pasargad/Helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
namespace Tartan\Larapay\Adapter\Pasargad;
33

4-
use Illuminate\Support\Facades\Log;
4+
use Tartan\Log\Facades\XLog;
55

66
class Helper
77
{
@@ -80,7 +80,7 @@ public static function post2https($fields_arr, $url)
8080
//close connection
8181
curl_close($ch);
8282

83-
Log::debug('pasargad call result: '. $res);
83+
XLog::debug('pasargad call result: '. $res);
8484
return $res;
8585
}
8686
}

src/Adapter/Payir.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
2+
declare(strict_types=1);
23

34
namespace Tartan\Larapay\Adapter;
45

56
use Tartan\Larapay\Adapter\Zarinpal\Exception;
6-
use Illuminate\Support\Facades\Log;
77
use Tartan\Log\Facades\XLog;
88

99
/**
@@ -129,14 +129,14 @@ protected function verifyTransaction(): bool
129129
XLog::debug('PaymentVerification call', $sendParams);
130130
$result = Helper::post2https($sendParams, $this->endPointVerify);
131131
$response = json_decode($result);
132-
Log::info('PaymentVerification response', $this->obj2array($response));
132+
XLog::info('PaymentVerification response', $this->obj2array($response));
133133

134134

135135
if (isset($response->status, $response->amount)) {
136136

137137
if ($response->status == 1) {
138138
$this->getTransaction()->setVerified();
139-
$this->getTransaction()->setReferenceId($this->transId); // update transaction reference id
139+
$this->getTransaction()->setReferenceId(strval($this->transId)); // update transaction reference id
140140

141141
return true;
142142
} else {
@@ -175,6 +175,6 @@ public function getGatewayReferenceId(): string
175175
'transId',
176176
]);
177177

178-
return $this->transId;
178+
return strval($this->transId);
179179
}
180180
}

0 commit comments

Comments
 (0)