|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stl30\LaravelMobilpay\Http\Controllers; |
|
4
|
|
|
use \Exception; |
|
5
|
|
|
use Illuminate\Http\Request; |
|
6
|
|
|
use Illuminate\Support\Facades\Log; |
|
7
|
|
|
use Illuminate\Support\Facades\Validator; |
|
8
|
|
|
use Stl30\LaravelMobilpay\Mobilpay\Payment\Request\Mobilpay_Payment_Request_Abstract; |
|
9
|
|
|
use Stl30\LaravelMobilpay\Mobilpay\Payment\Request\Mobilpay_Payment_Request_Card; |
|
10
|
|
|
use Stl30\LaravelMobilpay\Mobilpay\Payment\Invoice; |
|
11
|
|
|
use Stl30\LaravelMobilpay\Mobilpay\Payment\Mobilpay_Payment_Address; |
|
12
|
|
|
use Stl30\LaravelMobilpay\Mobilpay\Payment\Request\Mobilpay_Payment_Request_Notify; |
|
13
|
|
|
use Stl30\LaravelMobilpay\Mobilpay\Payment\Mobilpay_Payment_Invoice; |
|
14
|
|
|
use Stl30\LaravelMobilpay\MobilpayTransaction; |
|
15
|
|
|
|
|
16
|
|
|
class LaravelMobilpayController extends Controller |
|
17
|
|
|
{ |
|
18
|
|
|
function getOrderId(){ |
|
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
return uniqid(time().'-',''); |
|
21
|
|
|
} |
|
22
|
|
|
function getOrderAmount(){ |
|
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
return 111; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function card() |
|
28
|
|
|
{ |
|
29
|
|
|
// |
|
30
|
|
|
return view('vendor.laravel-mobilpay.card'); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function addTransaction(Mobilpay_Payment_Request_Card $mobilpayRequestObject) |
|
34
|
|
|
{ |
|
35
|
|
|
$transaction = new MobilpayTransaction(); |
|
36
|
|
|
$transaction-> id_transaction = $mobilpayRequestObject-> orderId; |
|
37
|
|
|
$transaction-> request_status = 0; |
|
38
|
|
|
$transaction-> value = $mobilpayRequestObject-> invoice -> amount; |
|
39
|
|
|
$transaction-> currency = $mobilpayRequestObject-> invoice -> currency; |
|
40
|
|
|
$transaction-> details = $mobilpayRequestObject-> invoice -> details; |
|
41
|
|
|
$transaction-> request_object = json_encode($mobilpayRequestObject,true); |
|
42
|
|
|
return $transaction -> save(); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function updateTransaction(Mobilpay_Payment_Request_Abstract $mobilpayReturnObject, $orderStatus='possible error') |
|
46
|
|
|
{ |
|
47
|
|
|
$transaction = MobilpayTransaction::where('id_transaction','=',$mobilpayReturnObject -> orderId)->firstOrFail(); |
|
48
|
|
|
$transaction-> value = $mobilpayReturnObject-> invoice -> amount; |
|
|
|
|
|
|
49
|
|
|
$transaction-> currency = $mobilpayReturnObject-> invoice -> currency; |
|
|
|
|
|
|
50
|
|
|
$transaction-> details = $mobilpayReturnObject-> invoice -> details; |
|
|
|
|
|
|
51
|
|
|
$transaction-> request_status = 1; |
|
52
|
|
|
$transaction-> status = $orderStatus; |
|
53
|
|
|
$transaction-> client_name = $mobilpayReturnObject-> objPmNotify -> customer-> firstName; |
|
54
|
|
|
$transaction-> client_surname = $mobilpayReturnObject-> objPmNotify -> customer-> lastName; |
|
55
|
|
|
$transaction-> client_address = $mobilpayReturnObject-> objPmNotify -> customer-> address; |
|
56
|
|
|
$transaction-> client_email = $mobilpayReturnObject-> objPmNotify -> customer-> email; |
|
57
|
|
|
$transaction-> client_phone = $mobilpayReturnObject-> objPmNotify -> customer-> mobilePhone; |
|
58
|
|
|
$transaction-> return_request_object = json_encode($mobilpayReturnObject,true); |
|
59
|
|
|
return $transaction-> update(); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
function addAutomatedTransactionError($errorCode,$errorType,$errorMessage,Mobilpay_Payment_Request_Abstract $mobilpayReturnObject) { |
|
|
|
|
|
|
63
|
|
|
$transaction = new MobilpayTransaction(); |
|
64
|
|
|
$transaction-> id_transaction = 'error code:'.$errorCode.'>> error type:'.$errorType.'>> error message:'.$errorMessage; |
|
65
|
|
|
$transaction-> request_status = $errorType; |
|
66
|
|
|
$transaction-> request_object = json_encode($mobilpayReturnObject,true); |
|
67
|
|
|
$transaction-> status = $errorMessage; |
|
68
|
|
|
return $transaction -> save(); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public static function validatePaymentDetails(array $parameters=[]) |
|
72
|
|
|
{ |
|
73
|
|
|
$errorsText = ''; |
|
74
|
|
|
$paymentParameters = []; |
|
75
|
|
|
$requiredParameters = [ |
|
76
|
|
|
#must haves values |
|
77
|
|
|
'payment_amount' => 'value of payment', |
|
78
|
|
|
'payment_details' => 'payment details placeholder', |
|
79
|
|
|
'order_id' => '', |
|
80
|
|
|
'billing_type' => 'person',//or company |
|
81
|
|
|
]; |
|
82
|
|
|
foreach ($requiredParameters as $requiredName => $value){ |
|
83
|
|
View Code Duplication |
if(isset($parameters[$requiredName]) && $parameters[$requiredName] !== null){ |
|
|
|
|
|
|
84
|
|
|
$paymentParameters[$requiredName] = $parameters[$requiredName]; |
|
85
|
|
|
continue; |
|
86
|
|
|
} |
|
87
|
|
|
$errorsText .= '<br>Missing required parameter '.$requiredName; |
|
88
|
|
|
} |
|
89
|
|
|
if(strlen($errorsText)){ |
|
90
|
|
|
die($errorsText); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
$optionalParameters = [ |
|
94
|
|
|
#optional values |
|
95
|
|
|
'promotion_code' => '', |
|
96
|
|
|
#details on the cardholder address (optional) |
|
97
|
|
|
|
|
98
|
|
|
'billing_first_name' => '',//client first name |
|
99
|
|
|
'billing_last_name' => '',//client last name |
|
100
|
|
|
'billing_address' => '',//client adress |
|
101
|
|
|
'billing_email' => '',//client email |
|
102
|
|
|
'billing_mobile_phone' => '',//client phone/mobile |
|
103
|
|
|
'billing_fiscal_number' => '', |
|
104
|
|
|
'billing_identity_number' => '', |
|
105
|
|
|
'billing_country' => '', |
|
106
|
|
|
'billing_county' => '', |
|
107
|
|
|
'billing_city' => '', |
|
108
|
|
|
'billing_zip_code' => '', |
|
109
|
|
|
'billing_bank' => '', |
|
110
|
|
|
'billing_iban' => '', |
|
111
|
|
|
#details on the shipping address |
|
112
|
|
|
'shipping_type' => 'person',//or company |
|
113
|
|
|
'shipping_first_name' => '', |
|
114
|
|
|
'shipping_last_name' => '', |
|
115
|
|
|
'shipping_address' => '', |
|
116
|
|
|
'shipping_email' => '', |
|
117
|
|
|
'shipping_mobile_phone' => '', |
|
118
|
|
|
'shipping_fiscal_number' => '', |
|
119
|
|
|
'shipping_identity_number' => '', |
|
120
|
|
|
'shipping_country' => '', |
|
121
|
|
|
'shipping_county' => '', |
|
122
|
|
|
'shipping_city' => '', |
|
123
|
|
|
'shipping_zip_code' => '', |
|
124
|
|
|
'shipping_bank' => '', |
|
125
|
|
|
'shipping_iban' => '', |
|
126
|
|
|
]; |
|
127
|
|
|
|
|
128
|
|
|
foreach ($optionalParameters as $key => $Value) { |
|
129
|
|
View Code Duplication |
if(isset($parameters[$key]) && $parameters[$key] !== null){ |
|
|
|
|
|
|
130
|
|
|
$paymentParameters[$key]=$parameters[$key]; |
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
return $paymentParameters; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
public function cardRedirect(array $paymentParameters = array()) |
|
138
|
|
|
{ |
|
139
|
|
|
//DEBUG TO DELETE |
|
140
|
|
|
$paymentParameters['payment_amount'] = 111; |
|
141
|
|
|
$paymentParameters['payment_details'] = 'payment details'; |
|
142
|
|
|
$paymentParameters['order_id'] = uniqid(time().'-',''); |
|
143
|
|
|
$paymentParameters['billing_type'] = 'person'; |
|
144
|
|
|
|
|
145
|
|
|
$paymentParameters = self::validatePaymentDetails($paymentParameters); |
|
146
|
|
|
|
|
147
|
|
|
|
|
148
|
|
|
#for testing purposes, all payment requests will be sent to the sandbox server. Once your account will be active you must switch back to the live server https://secure.mobilpay.ro |
|
149
|
|
|
#in order to display the payment form in a different language, simply add the language identifier to the end of the paymentUrl, i.e https://secure.mobilpay.ro/en for English |
|
150
|
|
|
if(config('laravel-mobilpay.sandbox_active')){ |
|
151
|
|
|
$paymentUrl = config('laravel-mobilpay.sandbox_payment_link'); |
|
152
|
|
|
} |
|
153
|
|
|
else{ |
|
154
|
|
|
$paymentUrl = config('laravel-mobilpay.production_payment_link'); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
//$paymentUrl = 'https://secure.mobilpay.ro'; |
|
158
|
|
|
// this is the path on your server to the public certificate. You may download this from Admin -> Conturi de comerciant -> Detalii -> Setari securitate |
|
159
|
|
|
// $x509FilePath = 'i.e: /home/certificates/public.cer'; |
|
160
|
|
|
|
|
161
|
|
|
if(config('laravel-mobilpay.sandbox_active')){ |
|
162
|
|
|
$x509FilePath = config('laravel-mobilpay.sandbox_public_key'); |
|
163
|
|
|
} |
|
164
|
|
|
else{ |
|
165
|
|
|
$x509FilePath = config('laravel-mobilpay.production_public_key'); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
try |
|
169
|
|
|
{ |
|
170
|
|
|
srand((double) microtime() * 1000000); |
|
171
|
|
|
$objPmReqCard = new Mobilpay_Payment_Request_Card(); |
|
172
|
|
|
#merchant account signature - generated by mobilpay.ro for every merchant account |
|
173
|
|
|
#semnatura contului de comerciant - mergi pe www.mobilpay.ro Admin -> Conturi de comerciant -> Detalii -> Setari securitate |
|
174
|
|
|
$objPmReqCard->signature = config('laravel-mobilpay.merchant_account_signature'); |
|
175
|
|
|
#you should assign here the transaction ID registered by your application for this commercial operation |
|
176
|
|
|
#order_id should be unique for a merchant account |
|
177
|
|
|
$objPmReqCard->orderId = $paymentParameters['order_id']; |
|
178
|
|
|
#below is where mobilPay will send the payment result. This URL will always be called first; mandatory |
|
179
|
|
|
$objPmReqCard->confirmUrl = config('laravel-mobilpay.confirmUrl'); |
|
180
|
|
|
#below is where mobilPay redirects the client once the payment process is finished. Not to be mistaken for a "successURL" nor "cancelURL"; mandatory |
|
181
|
|
|
$objPmReqCard->returnUrl = config('laravel-mobilpay.returnUrl'); |
|
182
|
|
|
|
|
183
|
|
|
#detalii cu privire la plata: moneda, suma, descrierea |
|
184
|
|
|
#payment details: currency, amount, description |
|
185
|
|
|
$objPmReqCard->invoice = new Mobilpay_Payment_Invoice(); |
|
186
|
|
|
#payment currency in ISO Code format; permitted values are RON, EUR, USD, MDL; please note that unless you have mobilPay permission to |
|
187
|
|
|
#process a currency different from RON, a currency exchange will occur from your currency to RON, using the official BNR exchange rate from that moment |
|
188
|
|
|
#and the customer will be presented with the payment amount in a dual currency in the payment page, i.e N.NN RON (e.ee EUR) |
|
189
|
|
|
$objPmReqCard->invoice->currency = config('laravel-mobilpay.currency'); |
|
190
|
|
|
$objPmReqCard->invoice->amount = $paymentParameters['payment_amount']; |
|
191
|
|
|
#available installments number; if this parameter is present, only its value(s) will be available |
|
192
|
|
|
//$objPmReqCard->invoice->installments= '2,3'; |
|
193
|
|
|
#selected installments number; its value should be within the available installments defined above |
|
194
|
|
|
//$objPmReqCard->invoice->selectedInstallments= '3'; |
|
195
|
|
|
//platile ulterioare vor contine in request si informatiile despre token. Prima plata nu va contine linia de mai jos. |
|
196
|
|
|
// $objPmReqCard->invoice->tokenId = 'token_id'; |
|
197
|
|
|
$objPmReqCard->invoice->details = $paymentParameters['payment_details']; |
|
198
|
|
|
|
|
199
|
|
|
#detalii cu privire la adresa posesorului cardului |
|
200
|
|
|
#details on the cardholder address (optional) |
|
201
|
|
|
$billingAddress = new Mobilpay_Payment_Address(); |
|
202
|
|
|
$billingAddress->type = $paymentParameters['billing_type']; //should be "person" |
|
203
|
|
|
$billingAddress->firstName = isset($paymentParameters['billing_first_name'])??$paymentParameters['billing_first_name']; |
|
204
|
|
|
$billingAddress->lastName = isset($paymentParameters['billing_last_name'])??$paymentParameters['billing_last_name']; |
|
205
|
|
|
$billingAddress->address = isset($paymentParameters['billing_address'])??$paymentParameters['billing_address']; |
|
206
|
|
|
$billingAddress->email = isset($paymentParameters['billing_email'])??$paymentParameters['billing_email']; |
|
207
|
|
|
$billingAddress->mobilePhone = isset($paymentParameters['billing_mobile_phone'])??$paymentParameters['billing_mobile_phone']; |
|
208
|
|
|
$objPmReqCard->invoice->setBillingAddress($billingAddress); |
|
209
|
|
|
|
|
210
|
|
|
#detalii cu privire la adresa de livrare |
|
211
|
|
|
#details on the shipping address |
|
212
|
|
|
$shippingAddress = new Mobilpay_Payment_Address(); |
|
213
|
|
|
$shippingAddress->type = isset($paymentParameters['shipping_type'])??$paymentParameters['shipping_type']; |
|
214
|
|
|
$shippingAddress->firstName = isset($paymentParameters['shipping_first_name'])??$paymentParameters['shipping_first_name']; |
|
215
|
|
|
$shippingAddress->lastName = isset($paymentParameters['shipping_last_name'])??$paymentParameters['shipping_last_name']; |
|
216
|
|
|
$shippingAddress->address = isset($paymentParameters['shipping_address'])??$paymentParameters['shipping_address']; |
|
217
|
|
|
$shippingAddress->email = isset($paymentParameters['shipping_email'])??$paymentParameters['shipping_email']; |
|
218
|
|
|
$shippingAddress->mobilePhone = isset($paymentParameters['shipping_mobile_phone'])??$paymentParameters['shipping_mobile_phone']; |
|
219
|
|
|
$objPmReqCard->invoice->setShippingAddress($shippingAddress); |
|
220
|
|
|
|
|
221
|
|
|
#uncomment the line below in order to see the content of the request |
|
222
|
|
|
// TODO for debug |
|
223
|
|
|
// dd(__METHOD__,$objPmReqCard,$objPmReqCard->signature,$objPmReqCard->orderId,get_class($objPmReqCard->invoice)); |
|
224
|
|
|
// echo "<pre>";print_r($objPmReqCard);echo "</pre>"; |
|
225
|
|
|
$objPmReqCard->encrypt($x509FilePath); |
|
226
|
|
|
$this ->addTransaction($objPmReqCard); |
|
227
|
|
|
} |
|
228
|
|
|
catch(\Exception $e) |
|
|
|
|
|
|
229
|
|
|
{ |
|
230
|
|
|
|
|
231
|
|
|
} |
|
232
|
|
|
$exception = isset($e)?$e:null; |
|
233
|
|
|
// |
|
234
|
|
|
return view('vendor.laravel-mobilpay.cardRedirect')->with([ |
|
|
|
|
|
|
235
|
|
|
'objPmReqCard' => $objPmReqCard, |
|
|
|
|
|
|
236
|
|
|
'e' => $exception, |
|
237
|
|
|
'paymentUrl' => $paymentUrl |
|
238
|
|
|
]); |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
public function cardConfirm() |
|
242
|
|
|
{ |
|
243
|
|
|
|
|
244
|
|
|
$errorCode = 0; |
|
245
|
|
|
$errorType = Mobilpay_Payment_Request_Abstract::CONFIRM_ERROR_TYPE_NONE; |
|
246
|
|
|
$errorMessage = ''; |
|
|
|
|
|
|
247
|
|
|
$orderStatus = ''; |
|
|
|
|
|
|
248
|
|
|
if (strcasecmp($_SERVER['REQUEST_METHOD'], 'post') == 0) |
|
249
|
|
|
{ |
|
250
|
|
|
if(isset($_POST['env_key']) && isset($_POST['data'])) |
|
251
|
|
|
{ |
|
252
|
|
|
#calea catre cheia privata |
|
253
|
|
|
#cheia privata este generata de mobilpay, accesibil in Admin -> Conturi de comerciant -> Detalii -> Setari securitate |
|
254
|
|
|
$privateKeyFilePath = config('laravel-mobilpay.sandbox_public_key'); |
|
255
|
|
|
|
|
256
|
|
|
try |
|
257
|
|
|
{ |
|
258
|
|
|
$objPmReq = Mobilpay_Payment_Request_Abstract::factoryFromEncrypted($_POST['env_key'], $_POST['data'], $privateKeyFilePath); |
|
259
|
|
|
#uncomment the line below in order to see the content of the request |
|
260
|
|
|
//print_r($objPmReq); |
|
261
|
|
|
$rrn = $objPmReq->objPmNotify->rrn; |
|
|
|
|
|
|
262
|
|
|
// action = status only if the associated error code is zero |
|
263
|
|
|
if ($objPmReq->objPmNotify->errorCode == 0) { |
|
264
|
|
|
switch($objPmReq->objPmNotify->action) |
|
265
|
|
|
{ |
|
266
|
|
|
#orice action este insotit de un cod de eroare si de un mesaj de eroare. Acestea pot fi citite folosind $cod_eroare = $objPmReq->objPmNotify->errorCode; respectiv $mesaj_eroare = $objPmReq->objPmNotify->errorMessage; |
|
267
|
|
|
#pentru a identifica ID-ul comenzii pentru care primim rezultatul platii folosim $id_comanda = $objPmReq->orderId; |
|
268
|
|
|
case 'confirmed': |
|
269
|
|
|
#cand action este confirmed avem certitudinea ca banii au plecat din contul posesorului de card si facem update al starii comenzii si livrarea produsului |
|
270
|
|
|
//update DB, SET status = "confirmed/captured" |
|
271
|
|
|
$orderStatus = 'confirmed/captured'; |
|
272
|
|
|
$errorMessage = $objPmReq->objPmNotify->errorMessage; |
|
273
|
|
|
break; |
|
274
|
|
|
case 'confirmed_pending': |
|
275
|
|
|
#cand action este confirmed_pending inseamna ca tranzactia este in curs de verificare antifrauda. Nu facem livrare/expediere. In urma trecerii de aceasta verificare se va primi o noua notificare pentru o actiune de confirmare sau anulare. |
|
276
|
|
|
//update DB, SET status = "pending" |
|
277
|
|
|
$orderStatus = 'pending'; |
|
278
|
|
|
$errorMessage = $objPmReq->objPmNotify->errorMessage; |
|
279
|
|
|
break; |
|
280
|
|
|
case 'paid_pending': |
|
281
|
|
|
#cand action este paid_pending inseamna ca tranzactia este in curs de verificare. Nu facem livrare/expediere. In urma trecerii de aceasta verificare se va primi o noua notificare pentru o actiune de confirmare sau anulare. |
|
282
|
|
|
//update DB, SET status = "pending" |
|
283
|
|
|
$orderStatus = 'pending'; |
|
284
|
|
|
$errorMessage = $objPmReq->objPmNotify->errorMessage; |
|
285
|
|
|
break; |
|
286
|
|
|
case 'paid': |
|
287
|
|
|
#cand action este paid inseamna ca tranzactia este in curs de procesare. Nu facem livrare/expediere. In urma trecerii de aceasta procesare se va primi o noua notificare pentru o actiune de confirmare sau anulare. |
|
288
|
|
|
//update DB, SET status = "open/preauthorized" |
|
289
|
|
|
$orderStatus = 'open/preauthorized'; |
|
290
|
|
|
$errorMessage = $objPmReq->objPmNotify->errorMessage; |
|
291
|
|
|
break; |
|
292
|
|
|
case 'canceled': |
|
293
|
|
|
#cand action este canceled inseamna ca tranzactia este anulata. Nu facem livrare/expediere. |
|
294
|
|
|
//update DB, SET status = "canceled" |
|
295
|
|
|
$orderStatus = 'canceled'; |
|
296
|
|
|
$errorMessage = $objPmReq->objPmNotify->errorMessage; |
|
297
|
|
|
break; |
|
298
|
|
|
case 'credit': |
|
299
|
|
|
#cand action este credit inseamna ca banii sunt returnati posesorului de card. Daca s-a facut deja livrare, aceasta trebuie oprita sau facut un reverse. |
|
300
|
|
|
//update DB, SET status = "refunded" |
|
301
|
|
|
$orderStatus = 'refunded'; |
|
302
|
|
|
$errorMessage = $objPmReq->objPmNotify->errorMessage; |
|
303
|
|
|
break; |
|
304
|
|
|
default: |
|
305
|
|
|
$errorType = Mobilpay_Payment_Request_Abstract::CONFIRM_ERROR_TYPE_PERMANENT; |
|
306
|
|
|
$errorCode = Mobilpay_Payment_Request_Abstract::ERROR_CONFIRM_INVALID_ACTION; |
|
307
|
|
|
$orderStatus = $errorMessage = 'mobilpay_refference_action paramaters is invalid'; |
|
308
|
|
|
break; |
|
309
|
|
|
} |
|
310
|
|
|
} |
|
311
|
|
|
else { |
|
312
|
|
|
//update DB, SET status = "rejected" |
|
313
|
|
|
$orderStatus = 'rejected'; |
|
314
|
|
|
$errorMessage = $objPmReq->objPmNotify->errorMessage; |
|
315
|
|
|
} |
|
316
|
|
|
} |
|
317
|
|
|
catch(Exception $e) |
|
318
|
|
|
{ |
|
319
|
|
|
$errorType = Mobilpay_Payment_Request_Abstract::CONFIRM_ERROR_TYPE_TEMPORARY; |
|
320
|
|
|
$errorCode = $e->getCode(); |
|
321
|
|
|
$orderStatus = $errorMessage = $e->getMessage(); |
|
322
|
|
|
} |
|
323
|
|
|
} |
|
324
|
|
|
else |
|
325
|
|
|
{ |
|
326
|
|
|
$errorType = Mobilpay_Payment_Request_Abstract::CONFIRM_ERROR_TYPE_PERMANENT; |
|
327
|
|
|
$errorCode = Mobilpay_Payment_Request_Abstract::ERROR_CONFIRM_INVALID_POST_PARAMETERS; |
|
328
|
|
|
$orderStatus = $errorMessage = 'mobilpay.ro posted invalid parameters'; |
|
329
|
|
|
} |
|
330
|
|
|
} |
|
331
|
|
|
else |
|
332
|
|
|
{ |
|
333
|
|
|
$errorType = Mobilpay_Payment_Request_Abstract::CONFIRM_ERROR_TYPE_PERMANENT; |
|
334
|
|
|
$errorCode = Mobilpay_Payment_Request_Abstract::ERROR_CONFIRM_INVALID_POST_METHOD; |
|
335
|
|
|
$orderStatus = $errorMessage = 'invalid request metod for payment confirmation'; |
|
336
|
|
|
} |
|
337
|
|
|
|
|
338
|
|
|
|
|
339
|
|
|
if($errorCode == 0) |
|
340
|
|
|
{ |
|
341
|
|
|
if($this -> updateTransaction($objPmReq,$orderStatus) !== true){ |
|
342
|
|
|
Log::debug('Could not update transaction <<>> '.json_encode($objPmReq,true).' <<<>>> with orderStatus:'.$orderStatus); |
|
|
|
|
|
|
343
|
|
|
} |
|
344
|
|
|
else{ |
|
345
|
|
|
Log::debug('Update transaction success <<>> '.json_encode($objPmReq,true).' <<<>>> with orderStatus:'.$orderStatus); |
|
346
|
|
|
} |
|
347
|
|
|
Log::debug('No errors'); |
|
348
|
|
|
Log::debug(json_encode($errorMessage,true)); |
|
349
|
|
|
} |
|
350
|
|
|
else |
|
351
|
|
|
{ |
|
352
|
|
|
$objPmReq = (isset($objPmReq) && is_object($objPmReq))?$objPmReq:''; |
|
353
|
|
|
if($this -> addAutomatedTransactionError($errorCode,$errorType,$errorMessage,$objPmReq) !== true){ |
|
|
|
|
|
|
354
|
|
|
Log::debug('Could not addAutomatedTransactionError <<>> errortype:'.$errorType.'<<<>>> error code:'.$errorCode.'<<<<>>>'.json_encode($errorMessage,true)); |
|
355
|
|
|
} |
|
356
|
|
|
else{ |
|
357
|
|
|
Log::debug('addedAutomatedTransactionError <<>> errortype:'.$errorType.'<<<>>> error code:'.$errorCode.'<<<<>>>'.json_encode($errorMessage,true)); |
|
358
|
|
|
} |
|
359
|
|
|
Log::debug('With errors'); |
|
360
|
|
|
Log::debug('errortype:'.$errorType.'<<<>>> error code:'.$errorCode.'<<<<>>>'.json_encode($errorMessage,true)); |
|
361
|
|
|
} |
|
362
|
|
|
return; |
|
363
|
|
|
} |
|
364
|
|
|
|
|
365
|
|
|
public function cardReturn(Request $request) |
|
366
|
|
|
{ |
|
367
|
|
|
|
|
368
|
|
|
$orderStatus = 'eroare'; |
|
369
|
|
|
$orderId = (isset($request -> orderId) && $request -> orderId !== null)?$request -> orderId:''; |
|
370
|
|
|
$order = MobilpayTransaction::with('id_transaction','=',$request -> orderId)->first(); |
|
371
|
|
|
if($order !== null){ |
|
372
|
|
|
|
|
373
|
|
|
switch ($order->status){ |
|
374
|
|
|
case 'confirmed/captured': |
|
375
|
|
|
$orderStatus = 'succes'; |
|
376
|
|
|
break; |
|
377
|
|
|
case 'rejected': |
|
378
|
|
|
$orderStatus = 'rejected'; |
|
379
|
|
|
break; |
|
380
|
|
|
case 'pending': |
|
381
|
|
|
$orderStatus = 'pending'; |
|
382
|
|
|
break; |
|
383
|
|
|
default: |
|
384
|
|
|
$orderStatus = 'please contact us'; |
|
385
|
|
|
break; |
|
386
|
|
|
} |
|
387
|
|
|
|
|
388
|
|
|
|
|
389
|
|
|
} |
|
390
|
|
|
|
|
391
|
|
|
return view('vendor.laravel-mobilpay.cardReturn')->with([ |
|
|
|
|
|
|
392
|
|
|
'orderId' => $orderId, |
|
393
|
|
|
'orderStatus' => $orderStatus |
|
394
|
|
|
]); |
|
395
|
|
|
|
|
396
|
|
|
} |
|
397
|
|
|
} |
|
398
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.