Example #1
0
 private function callAPI($request, $URL, $SerializeOption = null)
 {
     $response = null;
     $isError = false;
     $reqObject = $request;
     try {
         switch (X_PAYPAL_REQUEST_DATA_FORMAT) {
             case "JSON":
                 $request = JSONEncoder::Encode($request);
                 $response = parent::callWebService($request, $URL);
                 break;
             case "SOAP11":
                 $request = SoapEncoder::Encode($request, $SerializeOption);
                 $response = parent::call($request, $URL);
                 break;
             case "XML":
                 $request = XMLEncoder::Encode($request, $SerializeOption);
                 $response = parent::callWebService($request, $URL);
                 break;
         }
         if (X_PAYPAL_RESPONSE_DATA_FORMAT == 'XML' || X_PAYPAL_RESPONSE_DATA_FORMAT == 'JSON') {
             switch (X_PAYPAL_RESPONSE_DATA_FORMAT) {
                 case "JSON":
                     $strObjName = get_class($reqObject);
                     $strObjName = str_replace('Request', 'Response', $strObjName);
                     $response = JSONEncoder::Decode($response, $isError, $strObjName);
                     break;
                 case "XML":
                     $response = XMLEncoder::Decode($response, $isError);
                     break;
             }
             if ($isError) {
                 $this->isSuccess = 'Failure';
                 $this->setLastError($response);
                 $response = null;
             } else {
                 $this->isSuccess = 'Success';
             }
         }
     } catch (Exception $ex) {
         throw new FatalException('Error occurred in callAPI method');
     }
     return $response;
 }
Example #2
0
 private function callAPI($request, $URL, $SerializeOption = null)
 {
     $response = null;
     $isError = false;
     $reqObject = $request;
     try {
         // REQUEST_DATA_FORMAT: JSON
         $request = JSONEncoder::Encode($request);
         $response = parent::callWebService($request, $URL, '');
         // RESPONSE_DATA_FORMAT: JSON
         $strObjName = get_class($reqObject);
         $strObjName = str_replace('Request', 'Response', $strObjName);
         $response = JSONEncoder::Decode($response, $isError, $strObjName);
         // Si hay algun error con el encoder
         if ($isError) {
             $this->isSuccess = 'Failure';
             $this->setLastError($response);
             $response = null;
         } else {
             $this->isSuccess = 'Success';
         }
     } catch (Exception $ex) {
         die('Error occurred in callAPI method');
     }
     return $response;
 }