示例#1
0
 public function processRequest($reqObject, $method, $postData)
 {
     $this->log(self::LOG_LEVEL_DEBUG, "YMARKET_INCOMING_REQUEST", $reqObject . ":" . $method, print_r($postData, true));
     $arResult = array();
     if (!$this->isActive()) {
         $arResult = $this->processError(self::ERROR_STATUS_503, GetMessage("SALE_YMH_ERROR_OFF"));
     } elseif (!$this->checkAuth()) {
         $arResult = $this->processError(self::ERROR_STATUS_403, GetMessage("SALE_YMH_ERROR_FORBIDDEN"));
     } else {
         self::$isYandexRequest = true;
         $arPostData = $this->extractPostData($postData);
         DiscountCouponsManager::init(DiscountCouponsManager::MODE_EXTERNAL);
         switch ($reqObject) {
             case 'cart':
                 $arResult = $this->processCartRequest($arPostData);
                 break;
             case 'order':
                 if ($method == "accept") {
                     $arResult = $this->processOrderAcceptRequest($arPostData);
                 } elseif ($method == "status") {
                     $arResult = $this->processOrderStatusRequest($arPostData);
                 }
                 break;
             default:
                 $arResult = $this->processError(self::ERROR_STATUS_400, GetMessage("SALE_YMH_ERROR_UNKNOWN_REQ_OBJ"));
                 break;
         }
     }
     $this->log(self::LOG_LEVEL_DEBUG, "YMARKET_INCOMING_REQUEST_RESULT", $reqObject . ":" . $method, print_r($arResult, true));
     $arPreparedResult = $this->prepareResult($arResult);
     return $arPreparedResult;
 }