notice() public static method

public static notice ( $m, $context = [] )
Exemplo n.º 1
0
 public function paymentAction()
 {
     $gateway = $this->getModule()->getGateway();
     if (!$gateway->supportsPurchase()) {
         \Pimcore\Logger::error("OmniPay Gateway payment [" . $this->getModule()->getName() . "] does not support purchase");
         throw new \CoreShop\Exception("Gateway doesn't support purchase!");
     }
     $params = $this->getGatewayParams();
     $response = $gateway->purchase($params)->send();
     if ($response instanceof \Omnipay\Common\Message\ResponseInterface) {
         if ($response->getTransactionReference()) {
             $this->cart->setCustomIdentifier($response->getTransactionReference());
         } else {
             $this->cart->setCustomIdentifier($params['transactionId']);
         }
         $this->cart->save();
         try {
             if ($response->isSuccessful()) {
                 \Pimcore\Logger::notice("OmniPay Gateway payment [" . $this->getModule()->getName() . "]: Gateway successfully responded redirect!");
                 $this->redirect($params['returnUrl']);
             } else {
                 if ($response->isRedirect()) {
                     if ($response instanceof \Omnipay\Common\Message\RedirectResponseInterface) {
                         \Pimcore\Logger::notice("OmniPay Gateway payment [" . $this->getModule()->getName() . "]: response is a redirect. RedirectMethod: " . $response->getRedirectMethod());
                         if ($response->getRedirectMethod() === "GET") {
                             $this->redirect($response->getRedirectUrl());
                         } else {
                             $this->view->response = $response;
                             $this->_helper->viewRenderer('payment/post', null, true);
                         }
                     }
                 } else {
                     throw new \CoreShop\Exception($response->getMessage());
                 }
             }
         } catch (\Exception $e) {
             \Pimcore\Logger::error("OmniPay Gateway payment [" . $this->getModule()->getName() . "] Error: " . $e->getMessage());
         }
     }
 }
Exemplo n.º 2
0
 /**
  * @return bool
  */
 public function checkValidity()
 {
     $sane = true;
     if ($this->type == "asset" && !empty($this->id)) {
         $el = Asset::getById($this->id);
         if (!$el instanceof Asset) {
             $sane = false;
             Logger::notice("Detected insane relation, removing reference to non existent asset with id [" . $this->id . "]");
             $this->id = null;
             $this->type = null;
         }
     }
     if (!($poster = Asset::getById($this->poster))) {
         $sane = false;
         Logger::notice("Detected insane relation, removing reference to non existent asset with id [" . $this->id . "]");
         $this->poster = null;
     }
     return $sane;
 }
Exemplo n.º 3
0
 /**
  * @return bool
  */
 public function checkValidity()
 {
     $sane = true;
     if ($this->id) {
         $el = Element\Service::getElementById($this->type, $this->id);
         if (!$el instanceof Element\ElementInterface) {
             $sane = false;
             Logger::notice("Detected insane relation, removing reference to non existent " . $this->type . " with id [" . $this->id . "]");
             $this->id = null;
             $this->type = null;
             $this->o = null;
             $this->subtype = null;
         }
     }
     return $sane;
 }
Exemplo n.º 4
0
 /**
  * This Action can be called via Frontend
  * @throws \CoreShop\Exception
  * @throws \CoreShop\Exception\ObjectUnsupportedException
  */
 public function paymentReturnAction()
 {
     $requestData = $this->parseRequestData();
     $this->disableLayout();
     $this->disableViewAutoRender();
     \Pimcore\Logger::notice('OmniPay paymentReturn [Postfinance]. TransactionID: ' . $requestData['transaction'] . ', Status: ' . $requestData['status']);
     $redirectUrl = '';
     if ($requestData['status'] === 5) {
         if (!empty($requestData['transaction'])) {
             $cart = \CoreShop\Model\Cart::findByCustomIdentifier($requestData['transaction']);
             if ($cart instanceof \CoreShop\Model\Cart) {
                 \Pimcore\Logger::notice('OmniPay paymentReturn [Postfinance]: create order with: ' . $requestData['transaction']);
                 $order = $cart->createOrder(\CoreShop\Model\Order\State::getById(\CoreShop\Model\Configuration::get("SYSTEM.ORDERSTATE.PAYMENT")), $this->getModule(), $cart->getTotal(), $this->view->language);
                 $payments = $order->getPayments();
                 foreach ($payments as $p) {
                     $dataBrick = new \Pimcore\Model\Object\Objectbrick\Data\CoreShopPaymentOmnipay($p);
                     $dataBrick->setTransactionId($requestData['transaction']);
                     $p->save();
                 }
                 $redirectUrl = Pimcore\Tool::getHostUrl() . $this->getModule()->getConfirmationUrl($order);
             } else {
                 \Pimcore\Logger::notice('OmniPay paymentReturn [Postfinance]: Cart with identifier' . $requestData['transaction'] . 'not found');
                 $redirectUrl = Pimcore\Tool::getHostUrl() . $this->getModule()->getErrorUrl('cart with identifier' . $requestData['transaction'] . 'not found');
             }
         } else {
             \Pimcore\Logger::notice('OmniPay paymentReturn [Postfinance]: No valid transaction id given');
             $redirectUrl = Pimcore\Tool::getHostUrl() . $this->getModule()->getErrorUrl('no valid transaction id given');
         }
     } else {
         \Pimcore\Logger::notice('OmniPay paymentReturn [Postfinance]: Error Status: ' . $requestData['status']);
         $redirectUrl = Pimcore\Tool::getHostUrl() . $this->getModule()->getErrorUrl('Postfinance returned with an error. Error Status: ' . $requestData['status']);
     }
     $this->redirect($redirectUrl);
     exit;
 }
Exemplo n.º 5
0
 /**
  * @return bool
  */
 public function checkValidity()
 {
     $sane = true;
     if (is_array($this->data) && $this->data["internal"]) {
         if ($this->data["internalType"] == "document") {
             $doc = Document::getById($this->data["internalId"]);
             if (!$doc) {
                 $sane = false;
                 Logger::notice("Detected insane relation, removing reference to non existent document with id [" . $this->getDocumentId() . "]");
                 $new = Document\Tag::factory($this->getType(), $this->getName(), $this->getDocumentId());
                 $this->data = $new->getData();
             }
         } elseif ($this->data["internalType"] == "asset") {
             $asset = Asset::getById($this->data["internalId"]);
             if (!$asset) {
                 $sane = false;
                 Logger::notice("Detected insane relation, removing reference to non existent asset with id [" . $this->getDocumentId() . "]");
                 $new = Document\Tag::factory($this->getType(), $this->getName(), $this->getDocumentId());
                 $this->data = $new->getData();
             }
         }
     }
     return $sane;
 }