예제 #1
0
 /**
  * @static
  * @param $method
  * @return array
  */
 public static function fetchAllPClasses($method)
 {
     $message = '';
     $success = '';
     $results = array();
     $countries = self::getKlarnaCountries();
     $pc_type = KlarnaHandler::getKlarna_pc_type();
     if (empty($pc_type)) {
         return FALSE;
     } else {
         // delete the file directly
         if (file_exists($pc_type)) {
             unlink($pc_type);
         }
     }
     foreach ($countries as $country) {
         $active_country = "klarna_active_" . $country;
         if ($method->{$active_country}) {
             // country is CODE 3==> converting to 2 letter country
             //$country = self::convertCountryCode($method, $country);
             $lang = self::getLanguageForCountry($method, $country);
             $flagImg = JURI::root(TRUE) . '/administrator/components/com_virtuemart/assets/images/flag/' . strtolower($lang) . '.png';
             $flag = "<img src='" . $flagImg . "' />";
             try {
                 $settings = self::getCountryData($method, $country);
                 $klarna = new Klarna_virtuemart();
                 $klarna->config($settings['eid'], $settings['secret'], $settings['country'], $settings['language'], $settings['currency'], KlarnaHandler::getKlarnaMode($method, $settings['country_code_3']), VMKLARNA_PC_TYPE, $pc_type, TRUE);
                 $klarna->fetchPClasses($country);
                 $success .= shopFunctions::getCountryByID($settings['virtuemart_country_id']);
             } catch (Exception $e) {
                 $message .= $flag . " " . shopFunctions::getCountryByID($settings['virtuemart_country_id']) . ": " . $e->getMessage() . ' Error Code #' . $e->getCode() . '</span></br>';
             }
         }
     }
     $results['msg'] = $message;
     $results['notice'] = $success;
     return $results;
     //echo $notice;
 }
예제 #2
0
 public static function fetchPClasses($method)
 {
     $message = '';
     $success = '';
     $results = array();
     $countries = self::getKlarnaCountries();
     foreach ($countries as $country) {
         $active_country = "klarna_active_" . $country;
         if ($method->{$active_country}) {
             // country is CODE 3==> converting to 2 letter country
             //$country = self::convertCountryCode($method, $country);
             $lang = self::getLanguageForCountry($method, $country);
             $flagImg = JURI::root(true) . '/administrator/components/com_virtuemart/assets/images/flag/' . strtolower($lang) . '.png';
             $flag = "<img src='" . $flagImg . "' />";
             try {
                 $settings = self::getCountryData($method, $country);
                 $klarna = new Klarna_virtuemart();
                 $klarna->config($settings['eid'], $settings['secret'], $settings['country'], $settings['language'], $settings['currency'], KlarnaHandler::getKlarnaMode($method), VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type(), true);
                 // fetch pclass from file
                 $klarna->fetchPClasses($country);
                 $success .= '<span style="padding: 5px;">' . $flag . " " . shopFunctions::getCountryByID($settings['virtuemart_country_id']) . '</span>';
             } catch (Exception $e) {
                 $message .= '<br><span style="font-size: 15px;">' . $flag . " " . shopFunctions::getCountryByID($settings['virtuemart_country_id']) . ": " . $e->getMessage() . ' Error Code #' . $e->getCode() . '</span></br>';
             }
         }
     }
     $results['msg'] = $message;
     $results['notice'] = 'PClasses fetched for : ' . $success;
     return $results;
     //echo $notice;
 }