| Server IP : 103.161.17.216 / Your IP : 216.73.216.1 Web Server : nginx/1.18.0 System : Linux tipsysaigoncharming 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 7.4.3-4ubuntu2.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/app.houseland.info/application/controllers/gateways/ |
Upload File : |
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Paypal extends App_Controller
{
public function complete_purchase()
{
$invoiceid = $this->input->get('invoiceid');
$hash = $this->input->get('hash');
$attemptReference = $this->input->get('reference');
$online_payment_amount = $this->session->userdata('online_payment_amount');
$currency = $this->session->userdata('currency');
$this->session->unset_userdata('online_payment_amount');
$this->session->unset_userdata('currency');
$token = $this->input->get('token');
check_invoice_restrictions($invoiceid, $hash);
// Check if token is the same like the one in the database
$this->db->where('token', $token);
$this->db->where('id', $invoiceid);
$db_token = $this->db->get(db_prefix().'invoices')->row()->token;
if ($db_token != $token) {
set_alert('danger', _l('payment_getaway_token_not_found'));
redirect(site_url('invoice/' . $invoiceid . '/' . $hash));
}
$paypalResponse = $this->paypal_gateway->complete_purchase([
'token' => $db_token,
'amount' => $online_payment_amount,
'currency' => $currency,
]);
// Check if error exists in the response
if (isset($paypalResponse['L_ERRORCODE0'])) {
set_alert('warning', $paypalResponse['L_SHORTMESSAGE0'] . '<br />' . $paypalResponse['L_LONGMESSAGE0']);
log_activity('Paypal Payment Error [Error CODE: ' . $paypalResponse['L_ERRORCODE0'] . ' Message: ' . $paypalResponse['L_SHORTMESSAGE0'] . '<br />' . $paypalResponse['L_LONGMESSAGE0'] . ']');
redirect(site_url('invoice/' . $invoiceid . '/' . $hash));
} elseif (isset($paypalResponse['PAYMENTINFO_0_ACK']) && $paypalResponse['PAYMENTINFO_0_ACK'] === 'Success') {
$success = $this->paypal_gateway->addPayment(
[
'amount' => $online_payment_amount,
'invoiceid' => $invoiceid,
'transactionid' => $paypalResponse['PAYMENTINFO_0_TRANSACTIONID'],
'payment_attempt_reference' => $attemptReference,
]
);
if ($success) {
set_alert('success', _l('online_payment_recorded_success'));
} else {
set_alert('danger', _l('online_payment_recorded_success_fail_database'));
}
redirect(site_url('invoice/' . $invoiceid . '/' . $hash));
}
}
}