Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SAGEPAY SERVER] Recurring Payment Error #4977

Closed
PlumbPal opened this issue Oct 27, 2016 · 0 comments
Closed

[SAGEPAY SERVER] Recurring Payment Error #4977

PlumbPal opened this issue Oct 27, 2016 · 0 comments
Labels
Needs Testing Possibly fixed, needs to be tested/verified

Comments

@PlumbPal
Copy link

PlumbPal commented Oct 27, 2016

Hi,

the SagePay Server model has some errors when trying to purchase a recurring profile.
(/catalog/model/extension/payment/sagepay_server.php)
(/catalog/model/payment/sagepay_server.php) for OC < 2.2

PHP Notice: Undefined index: recurring_trial in /catalog/model/payment/sagepay_server.php on line 109
PHP Notice: Undefined index: recurring_price in /catalog/model/payment/sagepay_server.php on line 116
PHP Notice: Undefined index: recurring_cycle in /catalog/model/payment/sagepay_server.php on line 117
PHP Notice: Undefined index: recurring_frequency in /catalog/model/payment/sagepay_server.php on line 117
PHP Notice: Undefined index: recurring_duration in /catalog/model/payment/sagepay_server.php on line 119

It gets its data from system/library/cart.php which has the following for recurring payments:
'recurring_id' => $cart['recurring_id'],
'name' => $recurring_query->row['name'],
'frequency' => $recurring_query->row['frequency'],
'price' => $recurring_query->row['price'],
'cycle' => $recurring_query->row['cycle'],
'duration' => $recurring_query->row['duration'],
'trial' => $recurring_query->row['trial_status'],
'trial_frequency' => $recurring_query->row['trial_frequency'],
'trial_price' => $recurring_query->row['trial_price'],
'trial_cycle' => $recurring_query->row['trial_cycle'],
'trial_duration' => $recurring_query->row['trial_duration']

These don't match the "recurring_" variants listed in the errors above and also the current function is not getting the data from the ['recurring'] array inside $item.

For example

$item['recurring_trial'] 

should really be

$item['recurring']['trial']

To fix this, the addRecurringPayment function should be as follows :

public function addRecurringPayment($item, $vendor_tx_code) {

    $this->load->model('checkout/recurring');
    $this->load->language('payment/sagepay_server');

    //trial information
    if ($item['recurring']['trial'] == 1) {
        $trial_amt = $this->currency->format($this->tax->calculate($item['recurring']['trial_price'], $item['tax_class_id'], $this->config->get('config_tax')), false, false, false) * $item['quantity'] . ' ' . $this->currency->getCode();
        $trial_text = sprintf($this->language->get('text_trial'), $trial_amt, $item['recurring']['trial_cycle'], $item['recurring']['trial_frequency'], $item['recurring']['trial_duration']);
    } else {
        $trial_text = '';
    }

    $recurring_amt = $this->currency->format($this->tax->calculate($item['recurring']['price'], $item['tax_class_id'], $this->config->get('config_tax')), false, false, false) * $item['quantity'] . ' ' . $this->currency->getCode();
    $recurring_description = $trial_text . sprintf($this->language->get('text_recurring'), $recurring_amt, $item['recurring']['cycle'], $item['recurring']['frequency']);

    if ($item['recurring']['duration'] > 0) {
        $recurring_description .= sprintf($this->language->get('text_length'), $item['recurring']['duration']);
    }

    //create new recurring and set to pending status as no payment has been made yet.
    $recurring_id = $this->model_checkout_recurring->create($item, $this->session->data['order_id'], $recurring_description);
    $this->model_checkout_recurring->addReference($recurring_id, $vendor_tx_code);
}

Hope this helps :)

@danielkerr danielkerr changed the title SagePay Server Recurring Payment Error [sagepay server] Recurring Payment Error Jun 10, 2017
@danielkerr danielkerr added the Needs Testing Possibly fixed, needs to be tested/verified label Jun 10, 2017
@danielkerr danielkerr changed the title [sagepay server] Recurring Payment Error [SAGEPAY SERVER] Recurring Payment Error Jun 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Testing Possibly fixed, needs to be tested/verified
Projects
None yet
Development

No branches or pull requests

2 participants