Friday, 25 May 2018

paytm gateway integration in codeigniter

paytm gateway integration in codeigniter

How we can integrate paytm gateway in codeigniter framework

Step 1: Downlaod the paytm gateway library form the github

https://github.com/Paytm-Payments/Paytm_Web_Sample_Kit_PHP

You can follow this video for placing paytm lib files in codeigniter framework



In controller

<?php

require_once(APPPATH."libraries/lib/config_paytm.php");
require_once(APPPATH."libraries/lib/encdec_paytm.php");


class Welcome extends CI_Controller {

    public function PaytmGateway()
    {
        $orderId = 106; /// must be unique
      $this->StartPayment($orderId);
    }

    public function StartPayment($orderId)
    {
        $paramList["MID"] = PAYTM_MERCHANT_MID;
        $paramList["ORDER_ID"] = $orderId;     
        $paramList["CUST_ID"] = 344;   /// according to your logic
        $paramList["INDUSTRY_TYPE_ID"] = 'RETIAL';
        $paramList["CHANNEL_ID"] = 'WEB';
        $paramList["TXN_AMOUNT"] = 50;
        $paramList["WEBSITE"] = PAYTM_MERCHANT_WEBSITE;
   
        $paramList["CALLBACK_URL"] = "http://127.0.0.1/gateway/Welcome/PaytmResponse";
        $paramList["MSISDN"] = '77777777'; //Mobile number of customer
        $paramList["EMAIL"] ='foo@gmail.com';
        $paramList["VERIFIED_BY"] = "EMAIL"; //
        $paramList["IS_USER_VERIFIED"] = "YES"; //
      //  print_r($paramList);
        $checkSum = getChecksumFromArray($paramList,PAYTM_MERCHANT_KEY);

        ?>

        <!--submit form to payment gateway OR in api environment you can pass this form data-->
   
        <form id="myForm" action="<?php echo PAYTM_TXN_URL ?>" method="post">
        <?php
         foreach ($paramList as $a => $b) {
        echo '<input type="hidden" name="'.htmlentities($a).'" value="'.htmlentities($b).'">';
       }
       ?>
            <input type="hidden" name="CHECKSUMHASH" value="<?php echo $checkSum ?>">
        </form>
        <script type="text/javascript">
            document.getElementById('myForm').submit();
         </script>
 
<?php
    }

    /////////// response from paytm gateway////////////
    public function PaytmResponse()
    {
        $paytmChecksum = "";
        $paramList = array();
        $isValidChecksum = "FALSE";

        $paramList = $_POST;
        echo "<pre>";
        print_r($paramList);
   
//        $paytmChecksum = isset($_POST["CHECKSUMHASH"]) ? $_POST["CHECKSUMHASH"] : ""; //Sent by Paytm pg
//
//        $isValidChecksum = verifychecksum_e($paramList, PAYTM_MERCHANT_KEY, $paytmChecksum); //will return TRUE or FALSE string.
//
//        if($isValidChecksum == "TRUE")
//        {
//            if ($_POST["STATUS"] == "TXN_SUCCESS")
//            { /// put your to save into the database // tansaction successfull
//                var_dump($paramList);
//            }
//            else {/// failed
//                var_dump($paramList);
//            }
//        }else
//        {//////////////suspicious
//           // put your code here
//       
//        }
    }
}
?>

Do not forget to subscribe my channel if this code help you

Thursday, 19 April 2018

PHP codeigniter status code in not working

While making project in Codeigniter framework many developers face these problems:
  • php http_response_code not working 
  • Http response code always returns 200
  • php http_response_code not working when hosting a linux server
  • 404 page not found in not working
  • php 500 not working in codeigniter
  • header already sent error in php
  • warning cannot modify header information headers already sent by (output started xyz.php line no...

All these problems occur when you host your website at Linux server that you have developed in codeigniter framework. 

You have to modify index.php file which is in the root directory of Codeigniter framework.

Step 1) Add ob_start(); function at the beginning of index.php after <?php

This function will turn on the output buffering. so that http response code works correctly. 

Step 2) define('ENVIRONMENT','development');

The modified index.php file is as


Thanks for sharing your valuable time.......

Sunday, 4 March 2018

json validation in codeigniter

json validation in codeigniter

How to validate json data or json nested array in codeigniter


For example we have two fields email and password to validate and sending request from postman as shown below:
request method: post
{
    "email":"sachinsharma.one@gmail.com",
    "password":"12345"
}

In controller

public function login_post()
{
header('Content-type: application/json');

                $request = json_decode(file_get_contents('php://input'),true);

$this->form_validation->set_data($request); /// for setting data

$this->form_validation->set_rules('email','Email', 'required|valid_email');
$this->form_validation->set_rules('password','PASSWORD', 'required|min_length[4]|max_length[20]');

if($this->form_validation->run()==false)
{
echo validation_errors();
}
else
{
// your code..............
}
}

In this way you can validate json data or even big json data

Tuesday, 12 September 2017

Htet computer science 2017

Hi friends we are always ready to provide you job alerts of Govt as well as private. we provide you study material, question bank of computer and question papers of various competitive exams.

Questions asked in Htet computer science  PGT Level-3

Q.1…………….. symbol is used to see every column of a table?
a) /     
b) _ _
c) *
d) !


Q. 2 HTTP  is a combination of FTP  and ………..  .
a) SMTP
b) E-mail
c) Web page
d) Web browser


Q. 3 What is the output of the following C++ program ?
#include <iostream.h>
Int x=7;
Void showx();
Void showagain();
Void main()
{
                Showx();
                Showx();
                Showxagain();
}
Void showx()
{
Int x= 34;
Cout<<x++<<endl;

}
Void showagain()
{
Cout<<x++<<endl;
}
Options are:
a)  35
      36
      37
b)   34
      34
      7
c) 35
     36
     8
d) 35
    35
    8


Q 4. The …………………… attribute specifies the URL of the document that you want to link.
a) img
b) a
c) src
d) href


Q 5. Which file keeps command to execute automatically when operating system is started ?
a) command.com
b) autoexec.bat 
c) config.sys
d) all options are wrong


NEXT PAGE 2, PAGE 3, PAGE 4, PAGE 5