Example #1
0
 public function __construct($message, $code = 0)
 {
     if ($code !== 0) {
         $error_label = self::$translation_object->l('This call to Twenga Web Services failed and returned an HTTP status of %d. That means:', basename(__FILE__, '.php')) . "\n";
         $error_label = sprintf($error_label, $code);
         if ($message === '' || empty($message) || $message === NULL) {
             switch ($code) {
                 case 11:
                     $message .= self::$translation_object->l('The function you tried to access does not exist', basename(__FILE__, '.php'));
                     break;
                 case 12:
                     $message .= self::$translation_object->l('A required field is empty', basename(__FILE__, '.php'));
                     break;
                 case 13:
                     $message .= self::$translation_object->l('The type of the parameter that has been sent is different from parameter expected type', basename(__FILE__, '.php'));
                     break;
                 case 21:
                     $message .= self::$translation_object->l('Hash key is not valid', basename(__FILE__, '.php'));
                     break;
                 case 24:
                     $message .= self::$translation_object->l('Hash key is required', basename(__FILE__, '.php'));
                     break;
                 case 31:
                     $message .= self::$translation_object->l('No order found. Please check parameters you sent', basename(__FILE__, '.php'));
                     break;
                 case 401:
                     $message .= self::$translation_object->l('Authentication is required.', basename(__FILE__, '.php'));
                     break;
                 case 403:
                     $message .= self::$translation_object->l('Authentication failed.', basename(__FILE__, '.php'));
                     break;
                 case 404:
                     $message .= self::$translation_object->l('Invalid url.', basename(__FILE__, '.php'));
                     break;
                 case 500:
                     $message .= self::$translation_object->l('The server encountered an internal server error', basename(__FILE__, '.php'));
                     break;
                 case 503:
                     $message .= self::$translation_object->l('The server is unavailable for the moment', basename(__FILE__, '.php'));
                     break;
                 default:
                     $message .= self::$translation_object->l('This call to PrestaShop Web Services returned an unexpected HTTP status of:', basename(__FILE__, '.php')) . $code;
             }
         }
         $message = self::$translation_object->l('Error #', basename(__FILE__, '.php')) . $code . " : \n" . $error_label . $message . '';
     }
     parent::__construct($message, $code);
 }
 private function _getFrontEndMessage($code)
 {
     switch ($code) {
         case -10001:
         case 'NO_VALID_SHOP':
             return self::$translation_object->l('Web service login or TS-ID invalid', TSBPException::$translate_key);
             break;
         case -10002:
         case 'LIMIT_CANCELLED':
             return self::$translation_object->l('The shop\'s credit limit has been suspended by Trusted Shops', TSBPException::$translate_key);
             break;
         case -10003:
         case 'DUPLICATE_ORDER_NUMBER':
             return self::$translation_object->l('Order number already used', TSBPException::$translate_key);
             break;
         case -10004:
         case 'UNSUPPORTED_TS_PRODUCT':
             return self::$translation_object->l('Unsupported Buyer Protection product', TSBPException::$translate_key);
             break;
         case -10005:
         case 'INACTIVE_PAYMENT_TYPE':
             return self::$translation_object->l('Inactive payment method', TSBPException::$translate_key);
             break;
         case -10006:
         case 'UNSUPPORTED_PAYMENT_TYPE':
             return self::$translation_object->l('Unsupported payment method', TSBPException::$translate_key);
             break;
         case -10007:
         case 'CURRENCY_MISMATCH':
             return self::$translation_object->l('The currency of the Buyer Protection product does not match with the currency of the shopping basket', TSBPException::$translate_key);
             break;
         case -10008:
         case 'UNSUPPORTED_CURRENCY':
             return self::$translation_object->l('This currency is not supported in this shop', TSBPException::$translate_key);
             break;
         case -10009:
         case 'UNSUPPORTED_EXCHANGE_RATE':
             return self::$translation_object->l('This exchange rate is not supported', TSBPException::$translate_key);
             break;
         case -10010:
         case 'NOT_PERSISTENT_PAYMENT_TYPE':
             return self::$translation_object->l('This payment method is not supported', TSBPException::$translate_key);
             break;
         case -10011:
         case 'NO_LIMIT':
             return self::$translation_object->l('No credit limit available for this certificate', TSBPException::$translate_key);
             break;
         case -10012:
         case 'PAST_DELIVERY_DATE':
             return self::$translation_object->l('The delivery date is in the past', TSBPException::$translate_key);
             break;
         case -10013:
         case 'TOO_OLD_ORDER':
             return self::$translation_object->l('The guarantee is for a purchase that was made over 3 days ago', TSBPException::$translate_key);
             break;
         case -10014:
         case 'EMAIL_MALFORMED':
             return self::$translation_object->l('The email address contains an error', TSBPException::$translate_key);
             break;
         case -10015:
         case 'ORDER_ID_EMPTY':
             return self::$translation_object->l('No order number was assigned', TSBPException::$translate_key);
             break;
         case -10016:
         case 'CUSTOMER_ID_EMPTY':
             return self::$translation_object->l('No customer number was assigned', TSBPException::$translate_key);
             break;
         case -10017:
         case 'LIMIT_OVERFLOW':
             return self::$translation_object->l('The credit limit for this certificate has been exceeded', TSBPException::$translate_key);
             break;
         case -10018:
         case 'EMAIL_EMPTY':
             return self::$translation_object->l('No email address was assigned', TSBPException::$translate_key);
             break;
         case -10019:
         case 'WRONG_TS_PRODUCT':
             return self::$translation_object->l('Non-applicable Buyer Protection product', TSBPException::$translate_key);
             break;
         case -11001:
         case 'INVALID_SECURITY_TOKEN':
             return self::$translation_object->l('Invalid security token', TSBPException::$translate_key);
             break;
         case -11111:
         case 'SYSTEM_EXCEPTION':
             return self::$translation_object->l('General system error, please contact Trusted Shops', TSBPException::$translate_key);
             break;
         default:
             return self::$translation_object->l('An error occurred.', TSBPException::$translate_key);
             break;
     }
 }
 public function setSmarty($smarty)
 {
     self::$smarty = $smarty;
 }