Error processing payment | WordPress.org

Hi @augustus1996

We’re taking a look at what might be the root cause. Can you please send us the PayPal plugin’s log file so we can review and compare to other log files that we have?

Kind Regards

2023-06-01T15:11:16+00:00 CRITICAL Uncaught Error: Call to a member function getId() on null in /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-content/plugins/pymntpl-paypal-woocommerce/src/PaymentResult.php:54
Stack trace:
#0 /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-content/plugins/pymntpl-paypal-woocommerce/src/Payments/Gateways/AbstractGateway.php(206): PaymentPlugins\WooCommerce\PPCP\PaymentResult->__construct()
#1 /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-content/plugins/woocommerce/includes/class-wc-checkout.php(1050): PaymentPlugins\WooCommerce\PPCP\Payments\Gateways\AbstractGateway->process_payment()
#2 /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-content/plugins/woocommerce/includes/class-wc-checkout.php(1279): WC_Checkout->process_order_payment()
#3 /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-content/plugins/woocommerce/includes/class-wc-ajax.php(485): WC_Checkout->process_checkout()
#4 /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-includes/class-wp-hook.php(308): WC_AJAX::checkout()
#5  in /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-content/plugins/pymntpl-paypal-woocommerce/src/PaymentResult.php on line 54

2023-06-01T17:02:42+00:00 CRITICAL Uncaught Error: Call to a member function getId() on null in /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-content/plugins/pymntpl-paypal-woocommerce/src/PaymentResult.php:54
Stack trace:
#0 /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-content/plugins/pymntpl-paypal-woocommerce/src/Payments/Gateways/AbstractGateway.php(206): PaymentPlugins\WooCommerce\PPCP\PaymentResult->__construct()
#1 /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-content/plugins/woocommerce/includes/class-wc-checkout.php(1050): PaymentPlugins\WooCommerce\PPCP\Payments\Gateways\AbstractGateway->process_payment()
#2 /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-content/plugins/woocommerce/includes/class-wc-checkout.php(1279): WC_Checkout->process_order_payment()
#3 /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-content/plugins/woocommerce/includes/class-wc-ajax.php(485): WC_Checkout->process_checkout()
#4 /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-includes/class-wp-hook.php(308): WC_AJAX::checkout()
#5  in /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-content/plugins/pymntpl-paypal-woocommerce/src/PaymentResult.php on line 54

2023-06-01T17:05:52+00:00 CRITICAL Uncaught Error: Call to a member function getId() on null in /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-content/plugins/pymntpl-paypal-woocommerce/src/PaymentResult.php:54
Stack trace:
#0 /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-content/plugins/pymntpl-paypal-woocommerce/src/Payments/Gateways/AbstractGateway.php(206): PaymentPlugins\WooCommerce\PPCP\PaymentResult->__construct()
#1 /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-content/plugins/woocommerce/includes/class-wc-checkout.php(1050): PaymentPlugins\WooCommerce\PPCP\Payments\Gateways\AbstractGateway->process_payment()
#2 /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-content/plugins/woocommerce/includes/class-wc-checkout.php(1279): WC_Checkout->process_order_payment()
#3 /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-content/plugins/woocommerce/includes/class-wc-ajax.php(485): WC_Checkout->process_checkout()
#4 /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-includes/class-wp-hook.php(308): WC_AJAX::checkout()
#5  in /var/www/thinkslimmer.wpfueledstaging.com/htdocs/wp-content/plugins/pymntpl-paypal-woocommerce/src/PaymentResult.php on line 54

This is what we have on the error log

I think the issue was related to this
Here’s the latest version of the plugin that you have

As you can see here. this function have the paypal_order_id which causing an issue and critical error.

	/**
	 * PaymentResult constructor.
	 *
	 * @param \PaymentPlugins\PayPalSDK\Order|\WP_Error $paypal_order
	 * @param \WC_Order                                 $order
	 * @param AbstractGateway                           $payment_method
	 * @param string                                    $error_message
	 */
	public function __construct( $paypal_order, \WC_Order $order, AbstractGateway $payment_method = null, $error_message="" ) {
		if ( is_wp_error( $paypal_order ) ) {
			$this->success       = false;
			$this->error_message = $paypal_order->get_error_message();
			$this->error_code    = $paypal_order->get_error_code();
		} elseif ( $paypal_order === false ) {
			$this->success       = false;
			$this->error_message = $error_message;
		} else {
			$this->success         = true;
			$this->paypal_order    = $paypal_order;
			$this->paypal_order_id = $paypal_order->getId();
		}
		$this->order          = $order;
		$this->payment_method = $payment_method;
	}

Compare to the version 1.29

	/**
	 * PaymentResult constructor.
	 *
	 * @param \PaymentPlugins\PayPalSDK\Order $paypal_order
	 * @param \WC_Order                       $order
	 * @param AbstractGateway                 $payment_method
	 * @param string                          $error_message
	 */
	public function __construct( $paypal_order, \WC_Order $order, AbstractGateway $payment_method = null, $error_message="" ) {
		if ( is_wp_error( $paypal_order ) ) {
			$this->success       = false;
			$this->error_message = $paypal_order->get_error_message();
		} elseif ( $paypal_order === false ) {
			$this->success       = false;
			$this->error_message = $error_message;
		} else {
			$this->success      = true;
			$this->paypal_order = $paypal_order;
		}
		$this->order          = $order;
		$this->payment_method = $payment_method;
	}

	public function success() {
		return $this->success;
	}

Hi @augustus1996

Thank you for the login for and the feedback. We will review everything and respond to this thread shortly.

Kind regards

FYI – I tried removing this line of code, from the pymntpl-paypal-woocommerce/src/PaymentResult.php and I was able to successfully checkout without the “Error processing checkout. Please try again” error. Can you review this. Thanks a lot.

$this->paypal_order_id = $paypal_order->getId();
  • This reply was modified 6 hours, 42 minutes ago by augustus1996.

I did try to fix it using this method


	/**
	 * PaymentResult constructor.
	 *
	 * @param \PaymentPlugins\PayPalSDK\Order|\WP_Error $paypal_order
	 * @param \WC_Order                                 $order
	 * @param AbstractGateway                           $payment_method
	 * @param string                                    $error_message
	 */
	public function __construct( $paypal_order, \WC_Order $order, AbstractGateway $payment_method = null, $error_message="" ) {
		if ( is_wp_error( $paypal_order ) ) {
			$this->success       = false;
			$this->error_message = $paypal_order->get_error_message();
			$this->error_code    = $paypal_order->get_error_code();
		} elseif ( $paypal_order === false ) {
			$this->success       = false;
			$this->error_message = $error_message;
		} else {
			$this->success         = true;
			$this->paypal_order    = $paypal_order;
	
			if(function_exists('getId')){
				$this->paypal_order_id = $paypal_order->getId();
			}
		}
		$this->order          = $order;
		$this->payment_method = $payment_method;
	}

Hi @augustus1996

What’s odd is the PayPal Order object should not be null at that point since you stated you were able to successfully checkout. Are you certain your transaction status is completed for the order you tested your code change one?

Kind Regards

yes you are right the paypal object should not be null, the only thing that is null is the getId() function that is causing the critical error.

this may have happened because we are not using funnelkit and i think the patch you added is for the site who is using funnelkit if i’m not mistaken.

i do see my order on the backen order successfully.

Hi @augustus1996

yes you are right the paypal object should not be null, the only thing that is null is the getId()

The error message Call to a member function getId() on null translates to “you tried to call a function on a null object” so that means the PayPal order object is null. I am not sure how that could be possible. Is this happening on a regular checkout page order?

i do see my order on the backen order successfully.

What is the WooCommerce order’s status?

Here is a link to the update which checks the null condition.

The order status is active or completed, I’ve used the subscription for this and the subscription status is active.

I do think the getId function on the paypal SDK doesn’t work since that’s causing critical error.

I do think the getId function on the paypal SDK doesn’t work since that’s causing critical error.

I agree, that didn’t work, but it’s not because there is something wrong with the function getId(). That function has been in the plugin since it was originally released a year ago.

That error message is specifically stating that you can’t call getId on a null object which means the PayPal order object is null. I am trying to understand how the PayPal order could be null in your scenario because I am not able to replicate in our development environment.

We also don’t have any other reports of this specific error. The other support thread that you were commenting on was not related to the error you’re reporting.

Kind Regards

It works now, thanks a lot.

This situation likely arose when an individual utilized PayPal and designated their card as the primary payment option within their PayPal account.

It works now, thanks a lot.

Ok, will include that in the next release. I finally figured out why that was happening. Your subscription is a free trial subscription yes? If so that’s the cause and we will be releasing the update within the next hour.

The free trial doesn’t have a corresponding PayPal order the same way a one off payment or regular subscription does.

Thanks for reporting this issue and your help troubleshooting.

Kind Regards

You are right, this is a free trial subscription.

Thanks a lot. I think this plugin is really helpful done the official paypal plugin that woocommerce have.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer