/** * Returns the countries related payment ID array. * * If PayPal is the selected payment method, any Currencies not supported * will be removed from the Currency array. * Returns the Payment IDs allowed for the given Country ID. * Note that the Payment IDs are used for both the keys and values * of the array returned, like: * array( * payment_id => payment_id, * [...] * ) * @global ADONewConnection $objDatabase Database connection object * @param integer $countryId The country ID * @param array $arrCurrencies The currencies array, by reference * @return array Array of Payment IDs */ static function getCountriesRelatedPaymentIdArray($countryId, $arrCurrencies) { global $objDatabase; if (is_null(self::$arrPayments)) { self::init(); } if (isset($_SESSION['shop']['paymentId'])) { $payment_id = $_SESSION['shop']['paymentId']; $processor_id = self::getPaymentProcessorId($payment_id); if ($processor_id == 2) { foreach ($arrCurrencies as $index => $arrCurrency) { if (!\PayPal::isAcceptedCurrencyCode($arrCurrency['code'])) { unset($arrCurrencies[$index]); } } } } $arrPaymentId = array(); $query = "\n SELECT DISTINCT `payment`.`id`\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_rel_countries` AS `country`\n INNER JOIN `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_zones` AS `zone`\n ON `country`.`zone_id`=`zone`.`id`\n INNER JOIN `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_rel_payment` AS `rel_payment`\n ON `zone`.`id`=`rel_payment`.`zone_id`\n INNER JOIN `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_payment` AS `payment`\n ON `payment`.`id`=`rel_payment`.`payment_id`\n WHERE `country`.`country_id`=" . intval($countryId) . "\n AND `payment`.`active`=1\n AND `zone`.`active`=1"; $objResult = $objDatabase->Execute($query); while ($objResult && !$objResult->EOF) { if (isset(self::$arrPayments[$objResult->fields['id']]) && (self::$arrPayments[$objResult->fields['id']]['processor_id'] != 2 || count($arrCurrencies))) { $paymentId = $objResult->fields['id']; // the processor with the id 3 is postfinance and 11 is postfinance mobile // if it is one of them, it should only be able to order when it is Switzerland if (in_array(self::$arrPayments[$paymentId]['processor_id'], array(3, 11)) && \Cx\Core\Country\Controller\Country::getAlpha2ById($countryId) != 'CH') { $objResult->MoveNext(); continue; } $arrPaymentId[$paymentId] = $paymentId; } $objResult->MoveNext(); } return $arrPaymentId; }