//cancel an active profile
$this->load->model('sale/recurring');
$this->load->model('payment/pp_express');
$this->language->load('sale/recurring');
$profile = $this->model_sale_recurring->getProfile($this->request->get['order_recurring_id']);
if($profile && !empty($profile['profile_reference'])) {
$result = $this->model_payment_pp_express->recurringCancel($profile['profile_reference']);
if(isset($result['PROFILEID'])) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "order_recurring_transaction` SET `order_recurring_id` = '" . (int)$profile['order_recurring_id'] . "', `created` = NOW(), `type` = '5'");
$this->db->query("UPDATE `" . DB_PREFIX . "order_recurring` SET `status` = 4 WHERE `order_recurring_id` = '" . (int)$profile['order_recurring_id'] . "' LIMIT 1");
$this->session->data['success'] = $this->language->get('success_cancelled');
} else {
$this->session->data['error'] = sprintf($this->language->get('error_not_cancelled'), $result['L_LONGMESSAGE0']);
}
} else {
$this->session->data['error'] = $this->language->get('error_not_found');
}
$this->redirect($this->url->link('sale/recurring/info', 'order_recurring_id=' . $this->request->get['order_recurring_id'].'&token='.$this->request->get['token'], 'SSL'));