1
1
<?php
2
+
2
3
namespace Tartan \Larapay \Adapter ;
3
4
4
5
use SoapFault ;
11
12
*/
12
13
class Mellat extends AdapterAbstract implements AdapterInterface
13
14
{
14
- protected $ WSDL = 'https://bpm.shaparak.ir/pgwchannel/services/pgw?wsdl ' ;
15
+ protected $ WSDL = 'https://bpm.shaparak.ir/pgwchannel/services/pgw?wsdl ' ;
15
16
protected $ endPoint = 'https://bpm.shaparak.ir/pgwchannel/startpay.mellat ' ;
16
17
17
- protected $ testWSDL = 'http://banktest.ir/gateway/mellat/ws?wsdl ' ;
18
+ protected $ testWSDL = 'http://banktest.ir/gateway/mellat/ws?wsdl ' ;
18
19
protected $ testEndPoint = 'http://banktest.ir/gateway/mellat/gate ' ;
19
20
20
21
protected $ reverseSupport = true ;
@@ -26,7 +27,7 @@ class Mellat extends AdapterAbstract implements AdapterInterface
26
27
*/
27
28
protected function requestToken ()
28
29
{
29
- if ($ this ->getTransaction ()->checkForRequestToken () == false ) {
30
+ if ($ this ->getTransaction ()->checkForRequestToken () == false ) {
30
31
throw new Exception ('larapay::larapay.could_not_request_payment ' );
31
32
}
32
33
@@ -66,9 +67,9 @@ protected function requestToken()
66
67
67
68
if ($ response [0 ] == 0 ) {
68
69
$ this ->getTransaction ()->setGatewayToken ($ response [1 ]); // update transaction reference id
70
+
69
71
return $ response [1 ];
70
- }
71
- else {
72
+ } else {
72
73
throw new Exception ($ response [0 ]);
73
74
}
74
75
} else {
@@ -83,15 +84,15 @@ protected function requestToken()
83
84
* @return mixed
84
85
* @throws Exception
85
86
*/
86
- protected function generateForm ()
87
+ protected function generateForm ()
87
88
{
88
89
$ refId = $ this ->requestToken ();
89
90
90
91
return view ('larapay::mellat-form ' , [
91
92
'endPoint ' => $ this ->getEndPoint (),
92
93
'refId ' => $ refId ,
93
94
'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 ),
95
96
]);
96
97
}
97
98
@@ -100,9 +101,9 @@ protected function generateForm ()
100
101
* @throws Exception
101
102
* @throws \Tartan\Larapay\Adapter\Exception
102
103
*/
103
- protected function verifyTransaction ()
104
+ protected function verifyTransaction ()
104
105
{
105
- if ($ this ->getTransaction ()->checkForVerify () == false ) {
106
+ if ($ this ->getTransaction ()->checkForVerify () == false ) {
106
107
throw new Exception ('larapay::larapay.could_not_verify_payment ' );
107
108
}
108
109
@@ -114,7 +115,7 @@ protected function verifyTransaction ()
114
115
'ResCode ' ,
115
116
'SaleOrderId ' ,
116
117
'SaleReferenceId ' ,
117
- 'CardHolderInfo '
118
+ 'CardHolderInfo ' ,
118
119
]);
119
120
120
121
$ sendParams = [
@@ -123,7 +124,7 @@ protected function verifyTransaction ()
123
124
'userPassword ' => $ this ->password ,
124
125
'orderId ' => intval ($ this ->SaleOrderId ), // same as SaleOrderId
125
126
'saleOrderId ' => intval ($ this ->SaleOrderId ),
126
- 'saleReferenceId ' => intval ($ this ->SaleReferenceId )
127
+ 'saleReferenceId ' => intval ($ this ->SaleReferenceId ),
127
128
];
128
129
129
130
$ this ->getTransaction ()->setCardNumber ($ this ->CardHolderInfo );
@@ -134,15 +135,16 @@ protected function verifyTransaction ()
134
135
Log::debug ('bpVerifyRequest call ' , $ sendParams );
135
136
136
137
//$response = $soapClient->__soapCall('bpVerifyRequest', $sendParams);
137
- $ response = $ soapClient ->bpVerifyRequest ($ sendParams );
138
+ $ response = $ soapClient ->bpVerifyRequest ($ sendParams );
138
139
139
140
if (isset ($ response ->return )) {
140
141
Log::info ('bpVerifyRequest response ' , ['return ' => $ response ->return ]);
141
142
142
- if ($ response ->return != '0 ' ) {
143
+ if ($ response ->return != '0 ' ) {
143
144
throw new Exception ($ response ->return );
144
145
} else {
145
146
$ this ->getTransaction ()->setVerified ();
147
+
146
148
return true ;
147
149
}
148
150
} else {
@@ -160,9 +162,9 @@ protected function verifyTransaction ()
160
162
* @throws Exception
161
163
* @throws \Tartan\Larapay\Adapter\Exception
162
164
*/
163
- public function inquiryTransaction ()
165
+ public function inquiryTransaction ()
164
166
{
165
- if ($ this ->getTransaction ()->checkForInquiry () == false ) {
167
+ if ($ this ->getTransaction ()->checkForInquiry () == false ) {
166
168
throw new Exception ('larapay::larapay.could_not_inquiry_payment ' );
167
169
}
168
170
@@ -174,7 +176,7 @@ public function inquiryTransaction ()
174
176
'ResCode ' ,
175
177
'SaleOrderId ' ,
176
178
'SaleReferenceId ' ,
177
- 'CardHolderInfo '
179
+ 'CardHolderInfo ' ,
178
180
]);
179
181
180
182
$ sendParams = [
@@ -183,7 +185,7 @@ public function inquiryTransaction ()
183
185
'userPassword ' => $ this ->password ,
184
186
'orderId ' => intval ($ this ->SaleOrderId ), // same as SaleOrderId
185
187
'saleOrderId ' => intval ($ this ->SaleOrderId ),
186
- 'saleReferenceId ' => intval ($ this ->SaleReferenceId )
188
+ 'saleReferenceId ' => intval ($ this ->SaleReferenceId ),
187
189
];
188
190
189
191
$ this ->getTransaction ()->setCardNumber ($ this ->CardHolderInfo );
@@ -193,14 +195,15 @@ public function inquiryTransaction ()
193
195
194
196
Log::debug ('bpInquiryRequest call ' , $ sendParams );
195
197
//$response = $soapClient->__soapCall('bpInquiryRequest', $sendParams);
196
- $ response = $ soapClient ->bpInquiryRequest ($ sendParams );
198
+ $ response = $ soapClient ->bpInquiryRequest ($ sendParams );
197
199
198
200
if (isset ($ response ->return )) {
199
201
Log::info ('bpInquiryRequest response ' , ['return ' => $ response ->return ]);
200
- if ($ response ->return != '0 ' ) {
202
+ if ($ response ->return != '0 ' ) {
201
203
throw new Exception ($ response ->return );
202
204
} else {
203
205
$ this ->getTransaction ()->setVerified ();
206
+
204
207
return true ;
205
208
}
206
209
} else {
@@ -235,7 +238,7 @@ protected function settleTransaction()
235
238
'ResCode ' ,
236
239
'SaleOrderId ' ,
237
240
'SaleReferenceId ' ,
238
- 'CardHolderInfo '
241
+ 'CardHolderInfo ' ,
239
242
]);
240
243
241
244
$ sendParams = [
@@ -244,7 +247,7 @@ protected function settleTransaction()
244
247
'userPassword ' => $ this ->password ,
245
248
'orderId ' => intval ($ this ->SaleOrderId ), // same as orderId
246
249
'saleOrderId ' => intval ($ this ->SaleOrderId ),
247
- 'saleReferenceId ' => intval ($ this ->SaleReferenceId )
250
+ 'saleReferenceId ' => intval ($ this ->SaleReferenceId ),
248
251
];
249
252
250
253
try {
@@ -257,8 +260,9 @@ protected function settleTransaction()
257
260
if (isset ($ response ->return )) {
258
261
Log::info ('bpSettleRequest response ' , ['return ' => $ response ->return ]);
259
262
260
- if ($ response ->return == '0 ' || $ response ->return == '45 ' ) {
263
+ if ($ response ->return == '0 ' || $ response ->return == '45 ' ) {
261
264
$ this ->getTransaction ()->setAfterVerified ();
265
+
262
266
return true ;
263
267
} else {
264
268
throw new Exception ($ response ->return );
@@ -278,7 +282,7 @@ protected function settleTransaction()
278
282
* @throws Exception
279
283
* @throws \Tartan\Larapay\Adapter\Exception
280
284
*/
281
- protected function reverseTransaction ()
285
+ protected function reverseTransaction ()
282
286
{
283
287
if ($ this ->reverseSupport == false || $ this ->getTransaction ()->checkForReverse () == false ) {
284
288
throw new Exception ('larapay::larapay.could_not_reverse_payment ' );
@@ -292,7 +296,7 @@ protected function reverseTransaction ()
292
296
'ResCode ' ,
293
297
'SaleOrderId ' ,
294
298
'SaleReferenceId ' ,
295
- 'CardHolderInfo '
299
+ 'CardHolderInfo ' ,
296
300
]);
297
301
298
302
$ sendParams = [
@@ -301,7 +305,7 @@ protected function reverseTransaction ()
301
305
'userPassword ' => $ this ->password ,
302
306
'orderId ' => intval ($ this ->SaleOrderId ), // same as orderId
303
307
'saleOrderId ' => intval ($ this ->SaleOrderId ),
304
- 'saleReferenceId ' => intval ($ this ->SaleReferenceId )
308
+ 'saleReferenceId ' => intval ($ this ->SaleReferenceId ),
305
309
];
306
310
307
311
try {
@@ -313,9 +317,10 @@ protected function reverseTransaction ()
313
317
314
318
Log::info ('bpReversalRequest response ' , ['return ' => $ response ->return ]);
315
319
316
- if (isset ($ response ->return )){
320
+ if (isset ($ response ->return )) {
317
321
if ($ response ->return == '0 ' || $ response ->return == '45 ' ) {
318
322
$ this ->getTransaction ()->setRefunded ();
323
+
319
324
return true ;
320
325
} else {
321
326
throw new Exception ($ response ->return );
@@ -338,6 +343,7 @@ public function canContinueWithCallbackParameters(): bool
338
343
if ($ this ->ResCode === "0 " || $ this ->ResCode === 0 ) {
339
344
return true ;
340
345
}
346
+
341
347
return false ;
342
348
}
343
349
@@ -346,6 +352,7 @@ public function getGatewayReferenceId(): string
346
352
$ this ->checkRequiredParameters ([
347
353
'RefId ' ,
348
354
]);
355
+
349
356
return $ this ->RefId ;
350
357
}
351
358
0 commit comments