PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, January 30, 2022

[FIXED] I am using paypal payment gateway, its working but some time on success auto return showing blank screen?

 January 30, 2022     codeigniter, codeigniter-2, codeigniter-3, paypal, php     No comments   

Issue

I am using paypal payment gateway (currently using sandbox), its working but some time on success auto return showing blank screen?? response url is pretty good, but some times after auto return its showing blank screen.

My code:

after success auto return redirect properly:

http://domainname/client/paypal/success?amt=9.24&cc=USD&item_name=Weight%20Loss%20Diet%20Program&st=Completed&tx=9CX31984H5808205U

after success auto return redirect properly but showing website blank screen:

http://domainname/client/paypal/success?amt=9.24&cc=USD&item_name=Weight%20Loss%20Diet%20Program&st=Completed&tx=9CX31984H5808205U

everything is looking good with code & return url, then why after return sometimes website showing blank screen??

My Code Snippet to execute paypal response:

switch($action){
       case "success":               

        if(isset($_GET['tx']))
                        {
                            $tx_token = $_GET['tx'];
                            $req = 'cmd=_notify-synch'; 
                            $auth_token = PDT_IDENTITY_TOKEN;
                            $req .= "&tx=$tx_token&at=$auth_token";

                            $ch = curl_init();

                        if($sandbox==0){
                              curl_setopt($ch, CURLOPT_URL, "https://www.paypal.com/cgi-bin/webscr"); //Live
                        }else{
                              curl_setopt($ch, CURLOPT_URL, "https://www.sandbox.paypal.com/cgi-bin/webscr"); //Sandbox
                        }      

                        curl_setopt($ch, CURLOPT_POST, 1);
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
                        curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
                        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
                        //set cacert.pem verisign certificate path in curl using 'CURLOPT_CAINFO' field here,
                        //if your server does not bundled with default verisign certificates.
                        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);

                        if($sandbox==0){
                              curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: www.paypal.com")); //Live
                        }else{
                              curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: www.sandbox.paypal.com")); //Sandbox
                        }                        

                        $res = curl_exec($ch);
                        curl_close($ch);  

                        $lines = explode("\n", trim($res));
                        $keyarray = array(); 

                            if (strcmp ($lines[0], "SUCCESS") == 0)
                            {
                                   for ($i = 1; $i < count($lines); $i++)
                                   {
                                      $temp = explode("=", $lines[$i],2);
                                      $keyarray[urldecode($temp[0])] = urldecode($temp[1]);
                                   }

                                   $invoice_id = $keyarray['invoice'];
                                   $transaction_id = $keyarray['txn_id'];
                                   $payment_status = $keyarray['payment_status'];
                                   if($payment_status=='Completed')
                                   {
                                      ........
                                   }
                             }
                         }
        ....
        break;
        ....
      }

Solution

During PayPal operations, the variables you are using are part of PDT (Paypal data transfer), which is PayPal a/c feature which needs to be enabled. Please check your PayPal a/c PDT settings once.



Answered By - user11602461
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing