/var/www/vhosts/ihelp.ro/httpdocs/src/Controller
NameSizeModeActions
Admin/-0755rm
Api/-0755rm
Async/-0755rm
Component/-0755rm
Dashboard/-0755rm
AjaxController.php9040644editdlrm
AppController.php60900644editdlrm
CartsController.bk.php302280644editdlrm
CartsController.php182420644editdlrm
CategoriesController.php48970644editdlrm
CausesController.php110500644editdlrm
DonationsController.php29690644editdlrm
ErrorController.php17710644editdlrm
OrdersController.php203170644editdlrm
PagesController.php23170644editdlrm
PaymentsController.php90470644editdlrm
ProductFavoritesController.php65950644editdlrm
ProductsController.php71350644editdlrm
ProposedCausesController.php11920644editdlrm
SearchController.php30430644editdlrm
ShowcaseController.php6690644editdlrm
UserAddressesController.php14820644editdlrm
UsersController.php228460644editdlrm
Edit: /var/www/vhosts/ihelp.ro/httpdocs/src/Controller/PaymentsController.php (9047B)
Authentication->addUnauthenticatedActions(['payment', 'returnPay', 'acceptPay', 'rejectPay']); } /** * payment method */ public function payment() { $orderUuid = $this->request->getQuery('orderId'); if (!empty($orderUuid)) { $this->loadModel('Orders'); $order = $this->Orders->find() ->contain(['Users', 'UserAddresses', 'UserAddresses.Cities']) ->where(['Orders.uuid' => $orderUuid, 'Orders.is_active' => TRUE, 'Orders.order_status_id IN ' => [STATUS_NEW, STATUS_AWP]]) ->first(); if (!empty($order)) { $this->Orders->setStatus($order->id, STATUS_AWP, __('Comanda este redirectionata catre plata.')); #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 if (PAYMENT_IS_LIVE) { $paymentUrl = 'https://secure.mobilpay.ro'; $x509FilePath = ROOT . DS . 'config' . DS . 'mobilpay' . DS . 'live' . DS . 'live.' . MOBILPAY_KEY . '.public.cer'; } else { $paymentUrl = 'http://sandboxsecure.mobilpay.ro'; $x509FilePath = ROOT . DS . 'config' . DS . 'mobilpay' . DS . 'sandbox' . DS . 'sandbox.' . MOBILPAY_KEY . '.public.cer'; } try { $objPmReqCard = new Card(); $objPmReqCard->signature = MOBILPAY_KEY; $objPmReqCard->orderId = $orderUuid; $objPmReqCard->confirmUrl = Router::url(['prefix' => 'Api', 'controller' => 'Ajax', 'action' => 'confirmPay'], true); $objPmReqCard->returnUrl = Router::url(['controller' => 'Payments', 'action' => 'returnPay'], true); $objPmReqCard->invoice = new Invoice(); $objPmReqCard->invoice->currency = 'RON'; $objPmReqCard->invoice->amount = $order->total; $objPmReqCard->invoice->details = __('Donatie iHelp #{0}', $orderUuid); $billingAddress = new Address(); $billingAddress->type = 'person'; // person | company $billingAddress->firstName = $order->user->first_name; $billingAddress->lastName = $order->user->last_name; $billingAddress->country = DEFAULT_COUNTRY_ISO_3; $billingAddress->county = $order->user_address->city->county_code; $billingAddress->city = $order->user_address->city->name; $billingAddress->zipCode = $order->user_address->postal_code; $billingAddress->address = $order->user_address->address; $billingAddress->email = $order->user->email; $billingAddress->mobilePhone = $order->user_address->phone; $objPmReqCard->invoice->setBillingAddress($billingAddress); $shippingAddress = new Address(); $shippingAddress->type = 'person'; // person | company $shippingAddress->firstName = $order->user->first_name; $shippingAddress->lastName = $order->user->last_name; $shippingAddress->country = DEFAULT_COUNTRY_ISO_3; $shippingAddress->city = $order->user_address->city->name; $shippingAddress->zipCode = $order->user_address->postal_code; $shippingAddress->address = $order->user_address->address; $shippingAddress->email = $order->user->email; $shippingAddress->mobilePhone = $order->user_address->phone; $objPmReqCard->invoice->setShippingAddress($shippingAddress); $objPmReqCard->encrypt($x509FilePath); } catch (Exception $e) { $this->Flash->error(__('Ne pare rău, a intervenit o eroare. Vă rugăm încercati din nou.')); $this->redirect(['controller' => 'Orders', 'action' => 'summary']); } $this->set(compact('order', 'paymentUrl', 'objPmReqCard')); } else { $this->Flash->error(__('Ne pare rău, a intervenit o eroare. Vă rugăm încercati din nou.')); $this->redirect(['controller' => 'Orders', 'action' => 'summary']); } } else { $this->Flash->error(__('Ne pare rău, a intervenit o eroare. Vă rugăm încercati din nou.')); $this->redirect(['controller' => 'Orders', 'action' => 'summary']); } $this->viewBuilder()->setLayout('ajax'); } /** * returnPay method */ public function returnPay() { $orderUuid = $this->request->getQuery('orderId'); if (!empty($orderUuid)) { $this->loadModel('Orders'); $order = $this->Orders->find() ->contain(['Users', 'UserAddresses', 'UserAddresses.Cities']) ->where(['Orders.uuid' => $orderUuid, 'Orders.is_active' => TRUE, 'Orders.order_status_id IN ' => [STATUS_AWP, STATUS_PPAY, STATUS_PAID, STATUS_RJCT]]) ->first(); if (!empty($order)) { if ($order->order_status_id == STATUS_AWP) { $this->Orders->setStatus($order->id, STATUS_PPAY, __('Plata in procesare.')); } elseif ($order->order_status_id == STATUS_PAID) { return $this->redirect(['controller' => 'Payments', 'action' => 'acceptPay', '?' => ['orderId' => $orderUuid]]); } elseif ($order->order_status_id == STATUS_RJCT) { return $this->redirect(['controller' => 'Payments', 'action' => 'rejectPay', '?' => ['orderId' => $orderUuid]]); } } else { $this->Flash->error(__('Ne pare rău, a intervenit o eroare. Vă rugăm încercati din nou.')); return $this->redirect(['controller' => 'Orders', 'action' => 'summary']); } } else { $this->Flash->error(__('Ne pare rău, a intervenit o eroare. Vă rugăm încercati din nou.')); return $this->redirect(['controller' => 'Orders', 'action' => 'summary']); } } /** * acceptPay method */ public function acceptPay() { $orderUuid = $this->request->getQuery('orderId'); if (!empty($orderUuid)) { $this->loadModel('Orders'); $order = $this->Orders->find() ->contain(['Users', 'UserAddresses', 'UserAddresses.Cities']) ->where(['Orders.uuid' => $orderUuid, 'Orders.is_active' => TRUE, 'Orders.order_status_id IN ' => [STATUS_PAID]]) ->first(); if (empty($order)) { $this->Flash->error(__('Ne pare rău, a intervenit o eroare. Vă rugăm încercati din nou.')); return $this->redirect(['controller' => 'Orders', 'action' => 'summary']); } } else { $this->Flash->error(__('Ne pare rău, a intervenit o eroare. Vă rugăm încercati din nou.')); return $this->redirect(['controller' => 'Orders', 'action' => 'summary']); } } /** * rejectPay method */ public function rejectPay() { $orderUuid = $this->request->getQuery('orderId'); if (!empty($orderUuid)) { $this->loadModel('Orders'); $order = $this->Orders->find() ->where(['Orders.uuid' => $orderUuid, 'Orders.is_active' => TRUE, 'Orders.order_status_id IN ' => [STATUS_RJCT]]) ->first(); if (empty($order)) { $this->Flash->error(__('Ne pare rău, a intervenit o eroare. Vă rugăm încercati din nou.')); return $this->redirect(['controller' => 'Orders', 'action' => 'summary']); } } else { $this->Flash->error(__('Ne pare rău, a intervenit o eroare. Vă rugăm încercati din nou.')); return $this->redirect(['controller' => 'Orders', 'action' => 'summary']); } } }