CodeIgniter Forums
custom library not load - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 2.x (https://forum.codeigniter.com/forumdisplay.php?fid=18)
+--- Thread: custom library not load (/showthread.php?tid=65439)



custom library not load - webgooy - 06-12-2016

hi
i create custom library for payment gateway but when load in my controller  show me blank page.

function  invoice(){
           
           
           
            
           $invoice_id=$this->input->post('invoice_id');
           $amount=$this->input->post('amount');
           $Description=$this->input->post('Description');
           $MerchantID='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx';
           $CallbackURL='url';
           $Mobile='09126015062';
           $Email='[email protected]';
         
           
           $this->load->library('mylibrary');
           $this->mylibrary->request($MerchantID,$amount,$Description,$CallbackURL,$Mobile,$Email);
           
    
     $student_profile         = $this->db->get_where('student', array(
         'student_id' => $this->session->userdata('student_id')
        ))->row();
        $student_id              = $student_profile->student_id;
        $page_data['invoices']   = $this->db->get_where('invoice', array(
            'student_id' => $student_id
        ))->result_array();
        $page_data['page_name']  = 'mypal';
        $page_data['page_title'] = get_phrase('manage_invoice/payment');
        $this->load->view('index', $page_data);
        
    }      

i found when load  library this problem happens.

please help me what wrong in this code


RE: custom library not load - Wouter60 - 06-12-2016

There is nothing wrong with this piece of code in your controller. Check the library itself for syntax errors.


RE: custom library not load - webgooy - 06-12-2016

(06-12-2016, 06:16 AM)Wouter60 Wrote: There is nothing wrong with this piece of code in your controller. Check the library itself for syntax errors.

thanks for your answer and please help me to find syntax errors in my library
this is my library


<?php

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

/*
 * CodeIgniter ZarinPal getway library
 *
 * @author              Mahdi Majidzadeh (http://restro.ir)
 * @license             GNU Public License 2.0
 * @package             ZarinPal
 */



class Myclass
{
    private $url;
    private $ERR;
    private $authority;
    private $refid;

    public function request($merchant_id, $amount, $desc, $call_back, $mobile = null, $email = null)
    {
       $client = new SoapClient('https://de.zarinpal.com/pg/services/WebGate/wsdl', array('encoding' => 'UTF-8'));
    
    $result = $client->PaymentRequest(
                        array(
                                'MerchantID'     => $MerchantID,
                                'Amount'     => $Amount,
                                'Description'     => $Description,
                                'Email'     => $Email,
                                'Mobile'     => $Mobile,
                                'CallbackURL'     => $CallbackURL
                            )
    );
    
    //Redirect to URL You can do it also by creating a form
    if($result->Status == 100)
    {
        Header('Location: https://www.zarinpal.com/pg/StartPay/'.$result->Authority);
    } else {
        echo'ERR: '.$result->Status;
    }
       
    }
}
    public function verify(){
        $MerchantID = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX';
        $Amount = 1000; //Amount will be based on Toman
        $Authority = $_GET['Authority'];
    
    if($_GET['Status'] == 'OK'){
        // URL also Can be https://ir.zarinpal.com/pg/services/WebGate/wsdl
        $client = new SoapClient('https://de.zarinpal.com/pg/services/WebGate/wsdl', array('encoding' => 'UTF-8'));
        
        $result = $client->PaymentVerification(
                              array(
                                    'MerchantID'     => $MerchantID,
                                    'Authority'      => $Authority,
                                    'Amount'     => $Amount
                                )
        );
        
        if($result->Status == 100){
            echo 'Transation success. RefID:'. $result->RefID;
        } else {
            echo 'Transation failed. Status:'. $result->Status;
        }

    } else {
        echo 'Transaction canceled by user';
    }
    }
   
}


RE: custom library not load - albertleao - 06-12-2016

Check your apache logs files for errors so you can see the line number if there is a syntax error


RE: custom library not load - Bhavesh - 06-12-2016

Hi

You added one extra  } in your code
Please remove } top of the public function verify() function