59 lines
1.5 KiB
PHP
Executable File
59 lines
1.5 KiB
PHP
Executable File
<?php
|
|
|
|
class ModelExtensionPaymentPayanyway extends Model {
|
|
/**
|
|
* @param array<string, mixed> $address
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function getMethod(array $address) {
|
|
$this->load->language('extension/payment/payanyway');
|
|
|
|
if (!$this->isModuleEnabled() ||
|
|
!$this->isCurrencySupported() ||
|
|
!$this->isGeoZoneValid($address)
|
|
) {
|
|
return array();
|
|
}
|
|
|
|
return array(
|
|
'code' => 'payanyway',
|
|
'title' => $this->language->get('text_title'),
|
|
'terms' => '',
|
|
'sort_order' => $this->config->get('payment_payanyway_sort_order'),
|
|
);
|
|
}
|
|
|
|
/** @return bool */
|
|
private function isModuleEnabled() {
|
|
return (bool)$this->config->get('payment_payanyway_status');
|
|
}
|
|
|
|
/** @return bool */
|
|
private function isCurrencySupported() {
|
|
$shopCurrency = isset($this->session->data['currency']) ? $this->session->data['currency'] : '';
|
|
|
|
return $shopCurrency === $this->config->get('payment_payanyway_currency');
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $address
|
|
* @return bool
|
|
*/
|
|
private function isGeoZoneValid(array $address) {
|
|
$geoZoneId = (int)$this->config->get('payment_payanyway_geo_zone_id');
|
|
|
|
if ($geoZoneId === 0) {
|
|
return true;
|
|
}
|
|
|
|
$query = $this->db->query(
|
|
"SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone
|
|
WHERE geo_zone_id = '" . $geoZoneId . "'
|
|
AND country_id = '" . (int)$address['country_id'] . "'
|
|
AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')"
|
|
);
|
|
|
|
return $query->num_rows > 0;
|
|
}
|
|
}
|