/**
* used to void an authorised payment
*/
if(isset($this->request->post['order_id']) && $this->request->post['order_id'] != '') {
$this->load->model('payment/pp_express');
$paypal_order = $this->model_payment_pp_express->getOrder($this->request->post['order_id']);
$call_data = array();
$call_data['METHOD'] = 'DoVoid';
$call_data['AUTHORIZATIONID'] = $paypal_order['authorization_id'];
$result = $this->model_payment_pp_express->call($call_data);
if($result['ACK'] != 'Failure' && $result['ACK'] != 'FailureWithWarning') {
$transaction = array(
'paypal_order_id' => $paypal_order['paypal_order_id'],
'transaction_id' => '',
'parent_transaction_id' => $paypal_order['authorization_id'],
'note' => '',
'msgsubid' => '',
'receipt_id' => '',
'payment_type' => 'void',
'payment_status' => 'Void',
'pending_reason' => '',
'transaction_entity' => 'auth',
'amount' => '',
'debug_data' => json_encode($result),
);
$this->model_payment_pp_express->addTransaction($transaction);
$this->model_payment_pp_express->updateOrder('Complete', $this->request->post['order_id']);
unset($transaction['debug_data']);
$transaction['created'] = date("Y-m-d H:i:s");
$json['data'] = $transaction;
$json['error'] = false;
$json['msg'] = 'Transaction void';
} else {
$json['error'] = true;
$json['msg'] = (isset($result['L_SHORTMESSAGE0']) ? $result['L_SHORTMESSAGE0'] : 'There was an error');
}
} else {
$json['error'] = true;
$json['msg'] = 'Missing data';
}
$this->response->setOutput(json_encode($json));