$this->load->model('payment/pp_payflow_iframe');
$this->load->language('payment/pp_payflow_iframe');
$json = array();
if (isset($this->request->post['transaction_reference']) && isset($this->request->post['amount'])) {
$transaction = $this->model_payment_pp_payflow_iframe->getTransaction($this->request->post['transaction_reference']);
if ($transaction) {
$call_data = array(
'TRXTYPE' => 'C',
'TENDER' => 'C',
'ORIGID' => $transaction['transaction_reference'],
'AMT' => $this->request->post['amount'],
);
$result = $this->model_payment_pp_payflow_iframe->call($call_data);
if ($result['RESULT'] == 0) {
$json['success'] = $this->language->get('text_refund_issued');
$data = array(
'order_id' => $transaction['order_id'],
'type' => 'C',
'transaction_reference' => $result['PNREF'],
'amount' => $this->request->post['amount'],
);
$this->model_payment_pp_payflow_iframe->addTransaction($data);
} else {
$json['error'] = $result['RESPMSG'];
}
} else {
$json['error'] = $this->language->get('error_missing_order');
}
} else {
$json['error'] = $this->language->get('error_missing_data');
}
$this->response->setOutput(json_encode($json));