$this->load->language('payment/pp_pro_iframe');
$this->load->model('payment/pp_pro_iframe');
$json = array();
if (isset($this->request->post['order_id'])) {
$paypal_order = $this->model_payment_pp_pro_iframe->getOrder($this->request->post['order_id']);
$call_data = array();
$call_data['METHOD'] = 'DoReauthorization';
$call_data['AUTHORIZATIONID'] = $paypal_order['authorization_id'];
$call_data['AMT'] = number_format($paypal_order['total'], 2);
$call_data['CURRENCYCODE'] = $paypal_order['currency_code'];
$result = $this->model_payment_pp_pro_iframe->call($call_data);
if ($result['ACK'] != 'Failure' && $result['ACK'] != 'FailureWithWarning') {
$this->model_payment_pp_pro_iframe->updateAuthorizationId($paypal_order['paypal_iframe_order_id'], $result['AUTHORIZATIONID']);
$transaction = array(
'paypal_iframe_order_id' => $paypal_order['paypal_iframe_order_id'],
'transaction_id' => '',
'parent_transaction_id' => $paypal_order['authorization_id'],
'note' => '',
'msgsubid' => '',
'receipt_id' => '',
'payment_type' => 'instant',
'payment_status' => $result['PAYMENTSTATUS'],
'transaction_entity' => 'auth',
'pending_reason' => $result['PENDINGREASON'],
'amount' => '-' . '',
'debug_data' => json_encode($result),
);
$this->model_payment_pp_pro_iframe->addTransaction($transaction);
$transaction['created'] = date("Y-m-d H:i:s");
$json['data'] = $transaction;
$json['error'] = false;
$json['msg'] = 'Ok';
} else {
$json['error'] = true;
$json['msg'] = (isset($result['L_SHORTMESSAGE0']) ? $result['L_SHORTMESSAGE0'] : $this->language->get('error_general'));
}
} else {
$json['error'] = true;
$json['msg'] = $this->language->get('error_missing_data');
}
$this->response->setOutput(json_encode($json));