asterisk2billing.org
http://forum.asterisk2billing.org/

PayPal fix
http://forum.asterisk2billing.org/viewtopic.php?f=16&t=4717
Page 1 of 2

Author:  atamurad [ Sun Dec 28, 2008 4:43 pm ]
Post subject:  PayPal fix

Paypal code in A2b is obsolete, it uses plain HTTP to talk to PayPal servers. They don't accept plain http anymore.

This patch fixes it by using HTTPS with libCURL.

Atamurad Hezretkuliyev

Code:
35,46d34
< $flag_ver = 0;
<
< function read_body($ch, $string)
< {
<    global $flag_ver;
<     $length = strlen($string);
<    if( strpos($string, "VERIFIED")== false  ) {
<       $flag_ver = 1;   
<    } else $flag_ver = 0;
<     write_log(LOGFILE_EPAYMENT, "Response: $length bytes\n$string\nVerified? $flag_ver ");
<     return $length;
< }
87,97c75,99
<
<       $url = "https://".PAYPAL_VERIFY_URL."/cgi-bin/webscr";
<        //open connection 
<        $ch = curl_init(); 
<          
<        //set the url, number of POST vars, POST data 
<        curl_setopt($ch,CURLOPT_URL,$url); 
<        curl_setopt($ch,CURLOPT_POST,1); 
<        curl_setopt($ch,CURLOPT_POSTFIELDS,$req); 
<          curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'read_body');
<
---
>       $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
>       $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
>       $header .= "Content-Length: " . strlen ($req) . "\r\n\r\n";
>       for ($i = 1; $i <=3; $i++)
>       {
>          write_log(LOGFILE_EPAYMENT, basename(__FILE__).' line:'.__LINE__."-OPENDING HTTP CONNECTION TO ".PAYPAL_VERIFY_URL);
>          $fp = fsockopen (PAYPAL_VERIFY_URL, 443, $errno, $errstr, 30);
>          if($fp)
>          {   
>             break;
>          }
>          else
>          {
>             write_log(LOGFILE_EPAYMENT, basename(__FILE__).' line:'.__LINE__." -Try#".$i." Failed to open HTTP Connection : ".$errstr.". Error Code: ".$errno);
>             sleep(3);
>          }
>       }      
>       if (!$fp)
>       {
>          write_log(LOGFILE_EPAYMENT, basename(__FILE__).' line:'.__LINE__."-Failed to open HTTP Connection: ".$errstr.". Error Code: ".$errno);
>          exit();
>       }      
>       else
>       {
>          fputs ($fp, $header . $req);         
99,110c101,109
<
<       write_log(LOGFILE_EPAYMENT, "Opening HTTPS connection with curl to paypal");         
<
<        //execute post 
<        $result = curl_exec($ch); 
<
<       write_log(LOGFILE_EPAYMENT, "Result : $result");
<          
<        //close connection 
<        curl_close($ch);
<
<
---
>          while (!feof($fp))
>          {
>             $res = fgets ($fp, 1024);
>             if (strcmp ($res, "VERIFIED") == 0)
>             {
>                write_log(LOGFILE_EPAYMENT, basename(__FILE__).' line:'.__LINE__."-PAYPAL Transaction Verification Status: Verified ");
>                $flag_ver = 1;
>             }            
>          }
116c115,116
<
---
>       }
>       fclose ($fp);   

Author:  asiby [ Mon Dec 29, 2008 4:19 am ]
Post subject: 

Good work atamurad.

Keep it up.

Author:  graher01 [ Tue Dec 30, 2008 1:21 pm ]
Post subject: 

asiby wrote:
Good work atamurad.

Keep it up.


I had a sample fix. I changed in a2billing.conf PAYPAL_VERIFY_URL ="ssl://www.paypal.com" and now it works fine.

Author:  areski [ Sat Jan 03, 2009 9:28 pm ]
Post subject: 

I dont follow here, we have this value by default in a2billing.conf

; paypal transaction verification url
paypal_verify_url = "ssl://www.paypal.com"

why it does need to be changed?

Yours,
/Areski

Author:  middletn [ Sat Jan 03, 2009 9:58 pm ]
Post subject: 

Are the quotes needed?

Author:  kissas [ Tue Mar 24, 2009 9:57 pm ]
Post subject: 

how can use this patch?
the file is checkout_process.php ?
how patch the file?

Author:  stavros [ Wed Mar 25, 2009 5:06 pm ]
Post subject: 

kissas wrote:
how can use this patch?
With 'patch', but I'm not sure that you need to. I no longer use Paypal myself, so could someone else please confirm it still works today without need of this patch.

This time last year, asiby recapped some of the pre-requisites needed to get Paypal payments functioning correctly.

Author:  graher01 [ Wed Mar 25, 2009 5:49 pm ]
Post subject: 

stavros wrote:
kissas wrote:
how can use this patch?
With 'patch', but I'm not sure that you need to. I no longer use Paypal myself, so could someone else please confirm it still works today without need of this patch.

This time last year, asiby recapped some of the pre-requisites needed to get Paypal payments functioning correctly.


Paypal does work you need to use ssl://www.paypal.com on the a2billing.conf

Author:  stavros [ Wed Mar 25, 2009 6:04 pm ]
Post subject: 

Thanks for your confirmation there graher01. So, kissas, the patch is not useless, but it's not essential either.

Author:  kissas [ Thu Mar 26, 2009 2:29 pm ]
Post subject: 

with ssl://www.paypal.com in a 1.3.2 a2b its not working, with www.paypal.com its working fine.

Author:  areski [ Sun Jul 26, 2009 1:06 pm ]
Post subject:  Re: PayPal fix

make sure you have this in the code of checkout_process.php
$fp = fsockopen (PAYPAL_VERIFY_URL, 443, $errno, $errstr, 30);

and not :

$fp = fsockopen (PAYPAL_VERIFY_URL, 80, $errno, $errstr, 30);


then in a2billing.cong set as follow :

paypal_payment_url = "https://secure.paypal.com/cgi-bin/webscr"

paypal_verify_url = "ssl://www.paypal.com"


Cheers,
/Areski

Author:  nitzan [ Sun Jul 26, 2009 7:02 pm ]
Post subject:  Re: PayPal fix

I'm having the same problem. Some (very few!) customers are able to pay via paypal - the rest aren't.

PayPal definitely broke something...

Are only A2B 1.3 users experiencing this? I guess I'll have to compare it myself, but is there a significant different between how 1.3 and 1.4 send the users to the paypal website to submit payment?

Author:  djtacho [ Tue Jul 28, 2009 6:39 am ]
Post subject:  Re: PayPal fix

Did you find a fix to the problem yet? I tryed all the sudgested solution:

make sure you have this in the code of checkout_process.php
$fp = fsockopen (PAYPAL_VERIFY_URL, 443, $errno, $errstr, 30);

and not :

$fp = fsockopen (PAYPAL_VERIFY_URL, 80, $errno, $errstr, 30);


then in a2billing.cong set as follow :

paypal_payment_url = "https://secure.paypal.com/cgi-bin/webscr"

paypal_verify_url = "ssl://www.paypal.com"




but it DID NOT WORK. Please tell me how to fix the problem. Thank you.

Author:  rukna [ Tue Jul 28, 2009 9:52 pm ]
Post subject:  Re: PayPal fix

This is an issue introduced by PayPal (did I mention they suck big time?!). The problem started occurring a couple of weeks ago not just for A2B users but for a lot of "paypal buy-it-now button" users.

In the little time I've spent researching this issue, it appears that some people have reported that PP no longer likes IFRAMES and got around it by launching the transaction in a new window. A2B doesn't suffer from that, of course.

Just my $.02

Author:  mbnwa [ Wed Jul 29, 2009 10:11 pm ]
Post subject:  Re: PayPal fix

in A2Billing.conf change the following

paypal_payment_url = "https://secure.paypal.com/cgi-bin/webscr"

TO

paypal_payment_url = "https://www.paypal.com/cgi-bin/webscr"

Issue resolved

Page 1 of 2 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/