• Resolved uniqcode

    (@uniqcode)


    Hi

    I use WooCommerce Subscriptions in conjunction with your excellent Stripe plugin. I had two errors occur following a successful automatic retry of a failed payment on a subscription renewal order, which appear to indicate bugs in your plugin.

    This was in the PHP error log:

    
    [01-Jun-2020 12:14:55 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function wc_add_notice() in /wp-content/plugins/woo-stripe-payment/includes/abstract/abstract-wc-payment-gateway-stripe.php:998
    Stack trace:
    #0 /wp-includes/class-wp-hook.php(287): WC_Payment_Gateway_Stripe->subscriptions_pre_update_payment_method(Object(WC_Subscription), 'stripe_cc', 'stripe_cc')
    #1 /wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array)
    #2 /wp-includes/plugin.php(478): WP_Hook->do_action(Array)
    #3 /wp-content/plugins/woocommerce-subscriptions/includes/class-wc-subscriptions-change-payment-gateway.php(499): do_action('woocommerce_sub...', Object(WC_Subscription), 'stripe_cc', 'stripe_cc')
    #4 /wp-content/plugins/woocommerce-subscriptions/includes/class-wc-subscriptions-change-payment-gateway.php(629): WC_Subscriptions_Change_Payment_Gateway::update_payment_met in /wp-content/plugins/woo-stripe-payment/includes/abstract/abstract-wc-payment-gateway-stripe.php on line 998
    [01-Jun-2020 15:15:21 UTC] Stripe Notice: Undefined property of Stripe\StripeObject instance: risk_score
    

    And this was added as a note to the Subscription:

    Attemp to save payment method failed. Reason: Unrecognized request URL (GET: /v1/payment_methods/). If you are trying to list objects, remove the trailing slash. If you are trying to retrieve an object, make sure you passed a valid (non-empty) identifier in your code. Please see https://stripe.com/docs or we can help at https://support.stripe.com/.

    Versions in use:
    WooCommerce 3.9.2
    WooCommerce Subscriptions 3.0.4
    Stripe for WooCommerce 3.1.2 (I’m aware that 3.1.3 is out but don’t see anything relevant in the changelog)

    Thanks

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

    (@mrclayton)

    Hi @uniqcode,

    Thanks for contacting us and providing that error log. So it looks like the error is being caused because WCS is trying to update the subscription’s payment method after the automatic retry was successful.

    I am guessing this was an automatic retry triggered by the WC action scheduler because the wc_add_notice function is loaded by WC when it is processing a front-end request, not a back-end request like a scheduled action.

    Was it the same payment method used for the retry as when it failed or a new payment method?

    Kind Regards,
    Clayton

    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @uniqcode,

    I was able to replicate the error by triggering a subscription retry via the action scheduler. This bug would only appear when a background job is running.

    I have made a note to include the fix for this in the next release. The error occurs after the recurring payment is successful so the good new is it won’t affect regular business processes.

    Thank you for bringing this bug to our attention.

    Kind Regards

    Thread Starter uniqcode

    (@uniqcode)

    Hi @mrclayton, thanks for the swift response and explanation.

    The error does seem to have caused a side effect which is problematic, and I wonder if you can suggest how to fix it.

    In the WooCommerce > Subscriptions admin screen, the Subscription that was affected by this bug is no longer showing a Next Payment Date. This is unfortunate, as I need to change it!

    The Schedule box on the right hand side of the Subscription’s page just says “Renewal Payment Retry: 2 days ago” where the Next Payment Date appears on every other Subscription.

    I’m also concerned that this means it won’t renew – although I see there is a woocommerce_scheduled_subscription_payment action scheduled for it. But, as I say, I need to change the renewal date to bring it back into sync with the others.

    What can I do?

    Thanks
    Ben

    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @uniqcode,

    As long as you see the woocommerce_scheduled_subscription_payment then you should be fine. When that action is triggered, all the metadata like next payment date will be updated.

    You can always update your subscription’s next payment date by doing the following:

    1. Access your WordPress postmeta table
    2. For post_id search using the subscription’s id
    3. Locate meta_key _schedule_next_payment
    4. Update the meta_value to the same date you see for the scheduled action. It should be in the format 2020-07-01 19:13:51

    Kind Regards,

    Plugin Author Payment Plugins

    (@mrclayton)

    @uniqcode version 3.1.4 released.

    Thread Starter uniqcode

    (@uniqcode)

    Thanks for your help.

    In my case the scheduled action was already correctly aligned with the subscription’s payment date. My issue was that I needed to change the date of both, preferably by making it editable in the admin screen.

    After much digging I found that the solution was to set the value for meta_key _schedule_payment_retry to zero:

    update wp_postmeta set meta_value = 0 where post_id = [SUBSCRIPTION_ID] and meta_key = '_schedule_payment_retry';

    Presumably this should have happened automatically after the successful payment retry, but didn’t because of the error. Once that was done the payment date once again showed up as editable in the Subscriptions admin page, and when changed there it correctly rescheduled the Action.

    Thanks for putting me on the right track.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘A couple of errors suggesting bugs’ is closed to new replies.