PayPal PHP SDK Payment crash on 500

Viewed 444

bsd

Hello, I am using the Paypal PHP SDK to connect with paypal. I am on a shared hosting account - linux system.

I have set up everything and it seems to be ok... but when it gets to the $payment->create method it produces an 500 error.

Is there something I am missing? also, How can I check to see if the apiContext is connecting ok?

require __DIR__  . '/sdk/autoload.php';

// requiring SDK uses

$api = new \PayPal\Rest\ApiContext(
        new \PayPal\Auth\OAuthTokenCredential(
            '...',     // ClientID
            '...'      // ClientSecret
        )
);

$api->setConfig([
    'mode' => 'sandbox',
    'http.ConnectionTimeOut' => 30,
    'log.LogEnabled' => false,
    'log.FileName' => '',
    'log.LogLevel' => 'FINE',
    'validation.level' => 'log'
]);

// setting up payer, details, amount, transaction, redirectUrls etc...

$payment->create($api); // crashes on a 500 error

Is there something I should check on the hosting setup? how can I debug apiContext?

I haven't used composer, is this a problem?

Still haven't found a solution for this problem, any help would be great

This is the log export

this is the log output -

[24-07-2017 11:15:44] PayPal\Core\PayPalHttpConnection : INFO: POST https://api.sandbox.paypal.com/v1/oauth2/token
[24-07-2017 11:15:44] PayPal\Core\PayPalHttpConnection : DEBUG: Request Headers     : 
[24-07-2017 11:15:44] PayPal\Core\PayPalHttpConnection : DEBUG: Request Data        : grant_type=client_credentials
--------------------------------------------------------------------------------------------------------------------------------

[24-07-2017 11:15:44] PayPal\Core\PayPalHttpConnection : INFO: Response Status  : 0
[24-07-2017 11:15:44] PayPal\Core\PayPalHttpConnection : DEBUG: Response Headers    : 
[24-07-2017 11:15:44] PayPal\Core\PayPalHttpConnection : ERROR: Got Http response code 0 when accessing https://api.sandbox.paypal.com/v1/oauth2/token. 
[24-07-2017 11:15:44] PayPal\Core\PayPalHttpConnection : DEBUG: 

================================================================================================================================
4 Answers

Bit of an old topic, but since I stumbled on this one, here is what caused the problem for me.

The payment method uses openssl_encrypt to encrypt the data. When using openssl_encrypt with FreeBSD based systems (including MacOS X Mojave + MacPorts), the calls to openssl_encrypt fails in PHP 7.3.

See discussion.

Related