403Webshell
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/libraries/gateways/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/app.houseland.info/application/libraries/gateways/Paypal_gateway.php
<?php

defined('BASEPATH') or exit('No direct script access allowed');

use Omnipay\Omnipay;

class Paypal_gateway extends App_gateway
{
    public bool $processingFees = true;

    public function __construct()
    {
        /**
         * Call App_gateway __construct function
         */
        parent::__construct();
        /**
         * REQUIRED
         * Gateway unique id
         * The ID must be alpha/alphanumeric
         */
        $this->setId('paypal');

        /**
         * REQUIRED
         * Gateway name
         */
        $this->setName('Paypal');

        /**
         * Add gateway settings
        */
        $this->setSettings(
        [
            [
                'name'      => 'username',
                'encrypted' => true,
                'label'     => 'settings_paymentmethod_paypal_username',
                ],
            [
                'name'      => 'password',
                'encrypted' => true,
                'label'     => 'settings_paymentmethod_paypal_password',
                ],
            [
                'name'      => 'signature',
                'encrypted' => true,
                'label'     => 'settings_paymentmethod_paypal_signature',
                ],
             [
                'name'          => 'description_dashboard',
                'label'         => 'settings_paymentmethod_description',
                'type'          => 'textarea',
                'default_value' => 'Payment for Invoice {invoice_number}',
            ],
            [
                'name'          => 'currencies',
                'label'         => 'settings_paymentmethod_currencies',
                'default_value' => 'EUR,USD',
                ],
            [
                'name'          => 'test_mode_enabled',
                'type'          => 'yes_no',
                'default_value' => 1,
                'label'         => 'settings_paymentmethod_testing_mode',
                ],
            ]
        );
    }

    /**
     * REQUIRED FUNCTION
     * @param  array $data
     * @return mixed
     */
    public function process_payment($data)
    {
        // Process online for PayPal payment start
        $gateway = Omnipay::create('PayPal_Express');

        $gateway->setUsername($this->decryptSetting('username'));
        $gateway->setPassword($this->decryptSetting('password'));
        $gateway->setSignature($this->decryptSetting('signature'));

        $gateway->setTestMode($this->getSetting('test_mode_enabled'));

        $logoURL = payment_gateway_logo_url();

        if ($logoURL != '' && startsWith(site_url(), 'https://')) {
            $gateway->setlogoImageUrl(hooks()->apply_filters('paypal_logo_url', $logoURL));
        }

        $gateway->setbrandName(get_option('companyname'));

        $request_data = [
            'amount'      => number_format($data['amount'], 2, '.', ''),
            'returnUrl'   => site_url('gateways/paypal/complete_purchase?hash=' . $data['invoice']->hash . '&invoiceid=' . $data['invoiceid'] . '&reference=' . $data['payment_attempt']->reference),
            'cancelUrl'   => site_url('invoice/' . $data['invoiceid'] . '/' . $data['invoice']->hash),
            'currency'    => $data['invoice']->currency_name,
            'description' => str_replace('{invoice_number}', format_invoice_number($data['invoice']->id), $this->getSetting('description_dashboard')),
            ];

        try {
            $response = $gateway->purchase($request_data)->send();
            if ($response->isRedirect()) {
                $this->ci->session->set_userdata([
                    'online_payment_amount' => number_format($data['amount'], 2, '.', ''),
                    'currency'              => $data['invoice']->currency_name,
                    ]);
                // Add the token to database
                $this->ci->db->where('id', $data['invoiceid']);
                $this->ci->db->update(db_prefix().'invoices', [
                    'token' => $response->getTransactionReference(),
                ]);
                $response->redirect();
            } else {
                exit($response->getMessage());
            }
        } catch (\Exception $e) {
            echo $e->getMessage() . '<br />';
            exit('Sorry, there was an error processing your payment. Please try again later.');
        }
    }

    /**
     * Custom function to complete the payment after user is returned from paypal
     * @param  array $data
     * @return mixed
     */
    public function complete_purchase($data)
    {
        $gateway = Omnipay::create('PayPal_Express');
        $gateway->setUsername($this->decryptSetting('username'));
        $gateway->setPassword($this->decryptSetting('password'));
        $gateway->setSignature($this->decryptSetting('signature'));
        $gateway->setTestMode($this->getSetting('test_mode_enabled'));

        $response = $gateway->completePurchase([
            'transactionReference' => $data['token'],
            'payerId'              => $this->ci->input->get('PayerID'),
            'amount'               => $data['amount'],
            'currency'             => $data['currency'],
            ])->send();

        $paypalResponse = $response->getData();

        return $paypalResponse;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit