コード例 #1
0
ファイル: Error.php プロジェクト: Carlos110988/Conekta
 public static function errorHandler($resp, $code)
 {
     $resp = json_decode($resp, true);
     $message = isset($resp['message']) ? $resp['message'] : null;
     $message_to_purchaser = isset($resp['message_to_purchaser']) ? $resp['message_to_purchaser'] : null;
     $type = isset($resp['type']) ? $resp['type'] : null;
     $params = isset($resp['param']) ? $resp['param'] : null;
     if (isset($code) != true || $code == 0) {
         throw new Conekta_NoConnectionError(ConektaLANG::translate('error.requestor.connection', array('BASE' => Conekta::$apiBase), ConektaLANG::EN), ConektaLANG::translate('error.requestor.connection_purchaser', null, Conekta::$locale), $type, $code, $params);
     }
     switch ($code) {
         case 400:
             throw new Conekta_MalformedRequestError($message, $message_to_purchaser, $type, $code, $params);
         case 401:
             throw new Conekta_AuthenticationError($message, $message_to_purchaser, $type, $code, $params);
         case 402:
             throw new Conekta_ProcessingError($message, $message_to_purchaser, $type, $code, $params);
         case 404:
             throw new Conekta_ResourceNotFoundError($message, $message_to_purchaser, $type, $code, $params);
         case 422:
             throw new Conekta_ParameterValidationError($message, $message_to_purchaser, $type, $code, $params);
         case 500:
             throw new Conekta_ApiError($message, $message_to_purchaser, $type, $code, $params);
         default:
             throw new Conekta_Error($message, $message_to_purchaser, $type, $code, $params);
     }
 }
コード例 #2
0
ファイル: Resource.php プロジェクト: Carlos110988/Conekta
 public function instanceUrl()
 {
     $id = $this->id;
     if (!$id) {
         throw new Conekta_Error(ConektaLANG::translate('error.resource.id', array('RESOURCE' => get_class()), ConektaLANG::EN), ConektaLANG::translate('error.resource.id_purchaser', null, Conekta::$locale));
     }
     $class = get_class($this);
     $base = $this->classUrl($class);
     $extn = urlencode($id);
     return "{$base}/{$extn}";
 }
コード例 #3
0
ファイル: Subscription.php プロジェクト: Carlos110988/Conekta
 public function instanceUrl()
 {
     $id = $this->id;
     if (!$id) {
         throw new Conekta_Error(ConektaLANG::translate('error.resource.id', array('RESOURCE' => get_class()), ConektaLANG::EN), ConektaLANG::translate('error.resource.id_purchaser', null, Conekta::$locale));
     }
     $class = get_class($this);
     $base = '/subscription';
     $customerUrl = $this->customer->instanceUrl();
     return "{$customerUrl}{$base}";
 }
コード例 #4
0
ファイル: Lang.php プロジェクト: Carlos110988/Conekta
 protected static function readDirectory($directory)
 {
     if (!empty(self::$cache)) {
         return self::$cache;
     }
     $langs = array();
     if ($handle = opendir($directory)) {
         while ($lang = readdir($handle)) {
             if (strpos($lang, ".php") !== false) {
                 $langKey = str_replace('.php', '', $lang);
                 $langs[$langKey] = (include $directory . '/' . $lang);
             }
         }
         closedir($handle);
     }
     self::$cache = $langs;
     return $langs;
 }