$this->load->model('payment/pp_payflow_iframe');
$this->load->model('checkout/order');
$this->model_payment_pp_payflow_iframe->log('POST: ' . print_r($this->request->post, 1));
$order_id = $this->model_payment_pp_payflow_iframe->getOrderId($this->request->post['SECURETOKENID']);
if ($order_id) {
$order_info = $this->model_checkout_order->getOrder($order_id);
$urlParams = array(
'TENDER' => 'C',
'TRXTYPE' => 'I',
'ORIGID' => $this->request->post['PNREF'],
);
$response_params = $this->model_payment_pp_payflow_iframe->call($urlParams);
if ($order_info['order_status_id'] == 0 && $response_params['RESULT'] == '0' && $this->request->post['RESULT'] == 0) {
$this->model_checkout_order->confirm($order_id, $this->config->get('pp_payflow_iframe_order_status_id'));
if ($this->request->post['TYPE'] == 'S') {
$complete = 1;
} else {
$complete = 0;
}
$data = array(
'secure_token_id' => $this->request->post['SECURETOKENID'],
'transaction_reference' => $this->request->post['PNREF'],
'transaction_type' => $this->request->post['TYPE'],
'complete' => $complete,
);
$this->model_payment_pp_payflow_iframe->updateOrder($data);
$data = array(
'order_id' => $order_id,
'type' => $this->request->post['TYPE'],
'transaction_reference' => $this->request->post['PNREF'],
'amount' => $this->request->post['AMT'],
);
$this->model_payment_pp_payflow_iframe->addTransaction($data);
}
}
$this->response->setOutput('Ok');