Skip to content

Commit

Permalink
Merge pull request #17 from wirecard/TPWDCEE-760
Browse files Browse the repository at this point in the history
Tpwdcee 760
  • Loading branch information
jpy authored Mar 12, 2018
2 parents fce3acd + 0591714 commit 8d98bbf
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 45 deletions.
12 changes: 8 additions & 4 deletions catalog/controller/extension/payment/wirecard.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ControllerExtensionPaymentWirecard extends Controller
{
protected $data = array();

private $pluginVersion = '2.0.0';
private $pluginVersion = '2.0.1';

private $prefix = 'wirecard';

Expand Down Expand Up @@ -78,7 +78,7 @@ public function index()
$data['send_order'] = $this->language->get('send_order');
$data['error_init'] = $this->language->get('error_init');

$data['wcp_ratepay'] = $this->loadRatePay();
$data['wcp_ratepay'] = $this->loadRatePay($prefix);

// Set Action URI
$data['action'] = $this->url->link('extension/payment/' . $prefix . '/init', '', 'SSL');
Expand All @@ -98,11 +98,15 @@ public function index()
*
* @return string
*/
public function loadRatePay()
public function loadRatePay($prefix)
{
if ($this->config->get('payment_'.$prefix.'_provider') !== 'ratepay') {
return;
}

$customerId = $this->config->get('customerId');

if(isset($_SESSION['wcpConsumerDeviceId'])) {
if (isset($_SESSION['wcpConsumerDeviceId'])) {
$consumerDeviceId = $_SESSION['wcpConsumerDeviceId'];
} else {
$timestamp = microtime();
Expand Down
1 change: 0 additions & 1 deletion catalog/controller/extension/payment/wirecard_eps.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public function index() {

$data['error_init'] = $this->language->get('error_init');

$data['wcp_ratepay'] = $this->loadRatePay();
// Set Action URI
$data['action'] = $this->url->link('extension/payment/'.$prefix.'/init', '', 'SSL');

Expand Down
2 changes: 0 additions & 2 deletions catalog/controller/extension/payment/wirecard_idl.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ public function index() {

$data['error_init'] = $this->language->get('error_init');

$data['wcp_ratepay'] = $this->loadRatePay();

// Set Action URI
$data['action'] = $this->url->link('extension/payment/'.$prefix.'/init', '', 'SSL');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function index() {
$data['send_order'] = $this->language->get('send_order');
$data['error_init'] = $this->language->get('error_init');

$data['wcp_ratepay'] = $this->loadRatePay();
$data['wcp_ratepay'] = $this->loadRatePay($prefix);
// Set Action URI
$data['action'] = $this->url->link('extension/payment/'.$prefix.'/init', '', 'SSL');

Expand Down
2 changes: 1 addition & 1 deletion catalog/controller/extension/payment/wirecard_invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function index() {
$data['send_order'] = $this->language->get('send_order');
$data['error_init'] = $this->language->get('error_init');

$data['wcp_ratepay'] = $this->loadRatePay();
$data['wcp_ratepay'] = $this->loadRatePay($prefix);
// Set Action URI
$data['action'] = $this->url->link('extension/payment/'.$prefix.'/init', '', 'SSL');

Expand Down
42 changes: 24 additions & 18 deletions catalog/model/extension/payment/wirecard_installment.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,17 @@ class ModelExtensionPaymentWirecardInstallment extends ModelExtensionPaymentWire
*/
public function getMethod($address, $total)
{

if ($this->cart->hasShipping()) {
$this->load->model('account/address');

$payment_address = $this->model_account_address->getAddress($this->session->data['payment_address']['address_id']);
$shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address']['address_id']);
if (isset($this->session->data['guest'])) {
$payment_address = $this->model_account_address->getAddress($this->session->data['guest']['shipping_address']);
$shipping_address = $this->model_account_address->getAddress($this->session->data['guest']['shipping_address']);
} else {
$payment_address = $this->model_account_address->getAddress($this->session->data['payment_address']['address_id']);
$shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address']['address_id']);
}

$fields = array(
'firstname',
Expand All @@ -75,24 +81,24 @@ public function getMethod($address, $total)
}
}

$min_amount = $this->config->get('payment_'.$this->prefix.$this->payment_type.'_minAmount');
if ( ! empty($min_amount) && $total < $min_amount) {
return FALSE;
}
$min_amount = $this->config->get('payment_'.$this->prefix.$this->payment_type.'_minAmount');
if ( ! empty($min_amount) && $total < $min_amount) {
return FALSE;
}

$max_amount = $this->config->get('payment_'.$this->prefix.$this->payment_type.'_maxAmount');
if ( ! empty($max_amount) && $total > $max_amount) {
return FALSE;
}
$max_amount = $this->config->get('payment_'.$this->prefix.$this->payment_type.'_maxAmount');
if ( ! empty($max_amount) && $total > $max_amount) {
return FALSE;
}

$currencies = $this->config->get('payment_'.$this->prefix.$this->payment_type.'_currency');
if ( ! empty($currencies) && ! in_array($this->session->data['currency'], $currencies)) {
return FALSE;
}
$country_ids = $this->config->get('payment_'.$this->prefix.$this->payment_type.'_country');
if ( ! empty($country_ids) && ! in_array($this->session->data['payment_address']['country_id'], $country_ids)) {
return FALSE;
}
$currencies = $this->config->get('payment_'.$this->prefix.$this->payment_type.'_currency');
if ( ! empty($currencies) && ! in_array($this->session->data['currency'], $currencies)) {
return FALSE;
}
$country_ids = $this->config->get('payment_'.$this->prefix.$this->payment_type.'_country');
if ( ! empty($country_ids) && ! in_array($this->session->data['payment_address']['country_id'], $country_ids)) {
return FALSE;
}

return parent::getMethod($address, $total);
}
Expand Down
42 changes: 24 additions & 18 deletions catalog/model/extension/payment/wirecard_invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@ public function getMethod($address, $total)
if ($this->cart->hasShipping()) {
$this->load->model('account/address');

$payment_address = $this->model_account_address->getAddress($this->session->data['payment_address']['address_id']);
$shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address']['address_id']);
if (isset($this->session->data['guest'])) {
$payment_address = $this->model_account_address->getAddress($this->session->data['guest']['shipping_address']);
$shipping_address = $this->model_account_address->getAddress($this->session->data['guest']['shipping_address']);
} else {
$payment_address = $this->model_account_address->getAddress($this->session->data['payment_address']['address_id']);
$shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address']['address_id']);
}

$fields = array(
'firstname',
'lastname',
Expand All @@ -74,24 +80,24 @@ public function getMethod($address, $total)
}
}

$min_amount = $this->config->get($this->prefix.$this->payment_type.'_minAmount');
if ( ! empty($min_amount) && $total < $min_amount) {
return FALSE;
}
$min_amount = $this->config->get($this->prefix.$this->payment_type.'_minAmount');
if ( ! empty($min_amount) && $total < $min_amount) {
return FALSE;
}

$max_amount = $this->config->get($this->prefix.$this->payment_type.'_maxAmount');
if ( ! empty($max_amount) && $total > $max_amount) {
return FALSE;
}
$max_amount = $this->config->get($this->prefix.$this->payment_type.'_maxAmount');
if ( ! empty($max_amount) && $total > $max_amount) {
return FALSE;
}

$currencies = $this->config->get($this->prefix.$this->payment_type.'_currency');
if ( ! empty($currencies) && ! in_array($this->session->data['currency'], $currencies)) {
return FALSE;
}
$country_ids = $this->config->get($this->prefix.$this->payment_type.'_country');
if ( ! empty($country_ids) && ! in_array($this->session->data['payment_address']['country_id'], $country_ids)) {
return FALSE;
}
$currencies = $this->config->get($this->prefix.$this->payment_type.'_currency');
if ( ! empty($currencies) && ! in_array($this->session->data['currency'], $currencies)) {
return FALSE;
}
$country_ids = $this->config->get($this->prefix.$this->payment_type.'_country');
if ( ! empty($country_ids) && ! in_array($this->session->data['payment_address']['country_id'], $country_ids)) {
return FALSE;
}

return parent::getMethod($address, $total);
}
Expand Down

0 comments on commit 8d98bbf

Please sign in to comment.