• Resolved Mushi

    (@mubashiriqbal)


    Hi,

    We recently updated Braintree For WooCommerce plugin to 3.0.5 and we are getting these error in the log
    "PHP Fatal error: Uncaught Error: Call to a member function get_payment_method_title() on null in /wp-content/plugins/woo-payment-gateway/includes/abstract/abstract-class-wc-braintree-payment-gateway.php:1251"

    We also noticed number of recurrent orders failure and got this message in the order notes “Error processing recurring payment. Reason: Cannot determine payment method.”

    We are using WooCommerce Subscription and this plugin.

    Kindly help us on this ASAP.

    Thank YOu.

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

    (@mrclayton)

    @mubashiriqbal,

    For one of the subscriptions where the error was “Cannot determine payment method” can you check in the postmeta table and see what the value is for the meta_key “_payment_method_token”?

    When a renewal order is created, the subscriptions postmeta data is copied over to the renewal order by WCS. That value should not be blank but that error message is indicating that it may be.

    Also, can you provide the full stack trace from the error log? It will be helpful to see where the call that caused the error originated from.

    Kind regards,

    Thread Starter Mushi

    (@mubashiriqbal)

    @mrclayton Thank you for the quick reply. Post meta value for “payment_method_token” is showing as blank. Order renewal was working fine till the version 2.6.65.

    Can you please tell me how to fix this.

    Thank You

    Plugin Author Payment Plugins

    (@mrclayton)

    @mubashiriqbal,

    That value should not be blank for the subscription. Our plugin never deletes the _payment_method_token value. Can you go back to a renewal order for that subscription and see what the “_payment_method_token” value was? You need to take the value from the renewal order and copy and paste it to the subscription’s “_payment_method_token.”

    Also please include the full stack track so I can see where the error in your log originated from.

    Kind regards,

    Thread Starter Mushi

    (@mubashiriqbal)

    For a quick solution we have downgraded the plugin to 2.6.65.
    Here is a detail error message
    PHP Fatal error: Uncaught Error: Call to a member function get_payment_method_title() on null in /wp-content/plugins/woo-payment-gateway/includes/abstract/abstract-class-wc-braintree-payment-gateway.php:1251\nStack trace:\n#0 /wp-includes/class-wp-hook.php(286): WC_Braintree_Payment_Gateway->update_failing_payment_method(Object(WC_Subscription), Object(WC_Order))\n#1 /wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array)\n#2 /wp-includes/plugin.php(465): WP_Hook->do_action(Array)\n#3 /wp-content/plugins/woocommerce-subscriptions/includes/class-wc-subscriptions-change-payment-gateway.php(677): do_action('woocommerce_sub...', Object(WC_Subscription), Object(WC_Order))\n#4 /wp-includes/class-wp-hook.php(286): WC_Subscriptions_Change_Payment_Gateway::change_failing_payment_method(Object(WC_Order), Object(WC_Subscription))\n#5 /wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', A...\n'

    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @mubashiriqbal,

    Please do the following so we can confirm if it’s a data issue. Find the user ID for the subscription then navigate to your woocommerce_payment_tokens table. Perform a search using that user ID and see if there are any payment methods in the table for that user. What do you see?

    You can use phpMyAdmin to view your tables.

    Kind Regards,

    Thread Starter Mushi

    (@mubashiriqbal)

    @mrclayton We have over four thousands active subscribers but the “woocommerce_payment_tokens” table is showing record of only 393 users.

    Plugin Author Payment Plugins

    (@mrclayton)

    @mubashiriqbal,

    Please re-read my previous request. I am wanting to know if anything is returned for that specific user. The fact that you have 4,000 subscribers but only 393 tokens isn’t an issue because our plugin syncs the payment methods when the customer logs in.

    The token doesn’t have to exist in the payment_method_tokens table in order for a subscription to process.

    Kind regards,

    Thread Starter Mushi

    (@mubashiriqbal)

    @mrclayton

    Thank for the explanation. I don’t any record of payment methods in “woocommerce_payment_tokens” table for that user.

    Plugin Author Payment Plugins

    (@mrclayton)

    @mubashiriqbal,

    I am trying to understand how the change_failing_payment_method function in WCS was called. For the renewal order that failed, did you update the order’s payment method or did the customer update their payment method?

    Or did you manauly try to process the renewal order again? I think there might be some more information in the stack trace that will show where the request originated from.

    Kind regards,

    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @mubashiriqbal,

    In the latest release, 3.0.7, I have added some code so that the get_token always return an instance of a payment token regardless of whether it exists in the woocommerce_payment_tokens table.

    This will prevent any null exceptions when the failed payment method is updated and the token doesn’t exist in the WC tokens table.

    Kind regards,

    Thread Starter Mushi

    (@mubashiriqbal)

    @mrclayton Can our issue be fixed if we update to version 3.0.7?

    Plugin Author Payment Plugins

    (@mrclayton)

    @mubashiriqbal,

    Yes that’s why I let you know what I changed in the latest version.

    Kind regards,

    Thread Starter Mushi

    (@mubashiriqbal)

    @mrclayton That sounds good. I will update the plugin to 3.0.7 and see if that works for us. Thank You for the wonderful support ??

    Thread Starter Mushi

    (@mubashiriqbal)

    @mrclayton I have updated the plugin to the latest version 3.0.7. So far order renewal is working fine but i noticed that we are getting the following order notes with some orders

    Payment method MasterCard xxxx is the customer’s default payment method in Braintree. It was used for the recurring payment because the subscription’s _payment_method_token key is blank and would have caused a failed renewal. Please correct your postmeta.

    Plugin Author Payment Plugins

    (@mrclayton)

    @mubashiriqbal,

    Yes, the message is pretty descriptive and is telling you that your _payment_method_token key in the postmeta table is blank. That’s the whole reason your recurring payments were failing in the first place.

    So the point of the message is to alert merchants like yourself that you should look in to why that value is blank. In version 3.0.7 I added code to charge the customer’s default payment method if the _payment_method_token is blank. That ensures the renewal at least processes.

    Kind regards,

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Call to a member function get_payment_method_title on null’ is closed to new replies.