Fatal error with PayPal Checkout add-on v. 3.9.0

I’m not sure when version 3.9.0 was released, but I was accessing forms with PayPal fields just fine earlier today. Now, trying to load the form editing screen causes a fatal error, and from that point on, the whole site is inaccessible until I manually deactivate the plugin in the file system.

Here’s the error:

PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in [REDACTED]/wp-content/plugins/gravityformsppcp/includes/class-gf-ppcp-api.php:147

The code up to and including line 147 is this:

// Convert JSON response to array.
$result_body = wp_remote_retrieve_body( $result );
if ( ! empty( $result_body ) ) {
	$result_body = gf_ppcp()->maybe_decode_json( $result_body );
} else {
	$result_body = array();
}
$debug_id                       = wp_remote_retrieve_header( $result, 'Paypal-Debug-Id' );
$result_body['PayPal-Debug-Id'] = $debug_id;

I haven’t dug deeper, but I think what’s happening is that the gf_ppcp()->maybe_decode_json() method is returning a string instead of an array. I was able to work around the problem by replacing the else statement with: if (!is_array($result_body))

I’m going to submit a support ticket too but I thought I would post it here in case anyone else is running into any new issues today with the PayPal add-on.

I have the same error on a few of my clients’ websites that use the PayPal plugin today. I hope this can find a solution soon.

Also have this problem on multiple sites and I have just submitted it to the support team. I note that there is also an error reported when examining the paypal connection setup in the webhook section.

We have encountered the same errors with the webhook and critical error on form pages on some of our client sites as well. We’ve submitted a ticket for support as well. Glad we’re not the only ones in this boat, and hoping this gets resolved quickly!

We are working on this and will release a solution as soon as we can!

1 Like

I can confirm that this fix worked for me. I replaced the if ( ! empty( $result_body ) with if (!is_array($result_body)). THANKS!

After further investigation, the fatal error is being triggered by this PayPal incident which is preventing the add-ons proper communication with the PayPal REST API. Our support team is able to provide a hotfix build of the PayPal Add-On which adds a guard clause to prevent the fatal error.

Note: Until PayPal resolves the incident on their end, it is likely that transactions may not be accepted. This version simply prevents any related fatal errors resulting from their outage.

1 Like

Great work by the GF team tracking this down… thanks!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.