Bhavin Bhavin - 11 months ago 46
PHP Question

Best way to convert or load External files in Code Igniter

I have Started Payment Gateway Integration of Pay U biz in Codeigniter Framework.
I downloaded the PHP SDK from Here :

Now, I tested it and it's working just fine without a framework, but i have to integrate it with Code igniter Framework.

I tried with this Example :

Note : payu.php is the main file which is downloaded from it's website.


require_once dirname( __FILE__ ) . '/payu.php';

/* Payments made easy. */

pay_page( array ( 'key' => 'gtKFFx', 'txnid' => uniqid( 'animesh_' ), 'amount' => rand( 0, 100 ),
'firstname' => 'Test', 'email' => '', 'phone' => '1234567890',
'productinfo' => 'Product Info', 'surl' => 'payment_success', 'furl' => 'payment_failure'), 'eCwWELxi' );

/* And we are done. */

function payment_success() {
/* Payment success logic goes here. */
echo "Payment Success" . "<pre>" . print_r( $_POST, true ) . "</pre>";

function payment_failure() {
/* Payment failure logic goes here. */
echo "Payment Failure" . "<pre>" . print_r( $_POST, true ) . "</pre>";

It's working fine without a framework. But i want to convert it in codeigniter so how can i convert it to codeigniter.

I tried with making library of payu.php file. and autoloading that library but it's not working so how can i convert it in codeigniter? What is the best option of converting it into codeigniter?

So not for only this payment gateway Integration if we want to use
another sdk or any thing else like pay u biz. what is the best way to convert or load
external files in code igniter Framework.

Answer Source

You can use require_once


Codeigniter is has this APPPATH which points to your applications folder. Then you can point to any folder from there. Hope this works

Goodluck meyt