• Resolved iugoau

    (@iugoau)


    Howdy!

    We had an error come up on one of our sites today, just wanted to let you know.

    As far as we can tell it was triggered when someone tried to change their payment method for a Woo Subscriptions subscription from the WC customer subscription pages.

    WP/Plugin versions:

    • WP: 6.5.2
    • Woo Subscriptions: 6.2.0
    • WooCommerce: 8.7.0
    • Payment Plugins for Stripe WooCommerce: 3.3.60

    The error was:

    Error Call to a member function get_customer_id() on null

    The error came from:

    woo-stripe-payment/includes/abstract/abstract-wc-payment-gateway-stripe.php:1901

    Tracing back from that line, which is in process_change_payment_method_request(), it’s trying to call $token->get_customer_id() on a $token retrieved a couple lines ago for a WC Subscription.

    $this->get_token( $this->payment_method_token, $subscription->get_user_id() ) has returned null in this case, and there is no guarding against that possible value in process_change_payment_method_request()

    In this customer’s particular case, there is no prior payment method as the subscription and parent order were created by a data importer – it’s possible this is resulting in the token not being retrieved.

    For a solution, it might be possible to include the erroring line within the if(){} following just after it, though being the customer ID it might potentially be worth getting the customer from the order itself rather than the token?

    Cheers!
    Dan

Viewing 1 replies (of 1 total)
  • Plugin Author Payment Plugins

    (@mrclayton)

    Hi @iugoau

    Thank you for the thorough breakdown of the error and potential causes. The token should always exists because when a customer is changing their payment method, if it’s a new payment method, it’s saved beforehand.

    Can you confirm if this customer has a large number of payment methods already saved in the database? I am wondering if the database queries limit is being reached and that particular token is not included in the results. I believe the default limit is 20.

    Kind Regards

Viewing 1 replies (of 1 total)
  • The topic ‘With Woo Subs: “Call to a member function get_customer_id() on null”’ is closed to new replies.