Paypal returns captcha as a response

Vilmis
Contributor
Contributor

Hello,
I'm using this code to verify a payment and all the time it worked perfectly:


namespace Donate\Vendor;

if ( ! defined('STARTED')) exit;

use \Donate\Vendor\Settings;
use \Donate\Vendor\DB;

class Paypal
{
private static $paypalSandboxUrl = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
private static $paypalUrl = 'https://www.paypal.com/cgi-bin/webscr';

public static function verify()
{
if (Settings::get('app.paypal.test'))
{
$url = self::$paypalSandboxUrl;
}
else
{
$url = self::$paypalUrl;
}

$encodedData = 'cmd=_notify-validate';

if ( ! empty($_POST))
{
$encodedData .= '&' . file_get_contents('php://input');
}
else
{
throw new Exception("No POST data found.");
}

DB::query("UPDATE paypal SET status = ? WHERE item_number = ?", [$encoded_data,$_POST['item_number']]);

$response = @file_get_contents($url . '/' . $encodedData);
$response = trim($response);

_log($response, 'user');

return ($response == 'VERIFIED') ? true : false;
}
}

and now it stopped working for no reason.
There where is response line the paypal returns whole html code of captcha, but works without any issue same code with sandbox. Any idea how to fix? Any smartman could to suggest something? 🙂

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.