Simple Membership Plugin › Forums › Simple Membership Plugin › Stripe subscription updates not processing
Tagged: events, stripe, subscription, webhook
- This topic has 9 replies, 3 voices, and was last updated 6 years, 6 months ago by
admin.
-
AuthorPosts
-
October 24, 2019 at 12:58 pm #19181
Marc LP
ParticipantHello,
we have a website with a yearly subscription plan using Stripe. We are using your latest update 3.9.2.
Although the automatic payments are correctly processed by Stripe, the member accounts are NOT updated and they are wrongly marked as Expired. This process was working some weeks ago, so we don’t know what may be the cause of the error. Maybe something with the Stripe SCA update done in september?
Doing some investigation, I have enabled the debug option and, from Stripe, I have manually resent the “customer.subscription.updated” event for a certain customer. The webhook response was always “200”, but it didn’t appear in the log. So I ended looking at the source code of your plugin up until the function “SwpmStripeSubscriptionIpnHandler->handle_stripe_ipn” which is responsible to treat the request.
Activating some disabled debugging logs I’ve verified that the Stripe request reaches that function but is IGNORED because it is not a ‘customer.subscription.deleted’ or ‘charge.refunded’ event and finally returns a “200 OK” response code, so the subscription update is not really processed.
Can you please check that the subscription renewal notifications work in your plugin?
Thank you
October 24, 2019 at 1:32 pm #19183The Assurer
ModeratorThe developers have been informed, and will investigate.
October 26, 2019 at 5:18 am #19215admin
KeymasterFor a subscription payment, your membership level’s expiry setting should be “No Expiry”. So when the cancellation of the subscription comes in, the account will be “deactivated”, otherwise the account will keep going (meaning the subscription is still active).
What is the membership level’s expiry setting that you are using?
October 28, 2019 at 8:24 am #19224Marc LP
ParticipantWhat is the membership level’s expiry setting that you are using?
Our setting for paid accounts is “Expire After 12 Months”
For a subscription payment, your membership level’s expiry setting should be “No Expiry”. So when the cancellation of the subscription comes in, the account will be “deactivated”, otherwise the account will keep going (meaning the subscription is still active).
So by what you say, you are confirming that your plugin does not check the Stripe subscription payment notifications, only the cancellation events?
That’s a little unfortunate, so if, for whatever reason, Stripe cannot notify a cancellation, the paid member will keep its status indefinitely?Please we need confirmation about this.
November 5, 2019 at 9:07 am #19251Marc LP
ParticipantHi again,
could you please take a minute to answer my last comments?
Thank you.
November 9, 2019 at 3:32 am #19267admin
KeymasterThe plugin receives the webhooks from Stripe for normal transactions and for cancellations. Then it updates the profile accordingly. I need to see why it is not updating profile when the normal charge comes in.
Just to confirm, are you using the new SCA compatible button option that we recently added to the plugin?
November 11, 2019 at 9:24 am #19272Marc LP
ParticipantJust to confirm, are you using the new SCA compatible button option that we recently added to the plugin?
Yes, currently we have changed the subscription button for the new SCA-compatible one but indeed the previous one is still enabled in some areas of our website.
But that really doesn’t matter for the current problem, right? as all failing subscriptions come from previous years when SCA button didn’t exist.The plugin receives the webhooks from Stripe for normal transactions and for cancellations. Then it updates the profile accordingly. I need to see why it is not updating profile when the normal charge comes in.
As I explained in my first message, in my debugging I found that all Stripe webhook subscription related requests are finally processed in the “swpm-stripe-subscription-ipn.php” file:
https://plugins.trac.wordpress.org/browser/simple-membership/trunk/ipn/swpm-stripe-subscription-ipn.phpSo, unless I’m wrong, this is what your code does when Stripe sends an event:
Line #13, the webhook url has the parameter “hook”, so if clause is true
Line #31, the subscription event “customer.subscription.updated” is not one of the if clause, so it is not executed (that is correct)
Line #44, the function is exited by a return, so that event is not processed
End of the Stripe event processingWe can give you a copy of the site if you wish, but it seems the problem would be the same in any other installation of your plugin.
November 12, 2019 at 7:29 am #19273admin
Keymasterokay so my info was a little bit wrong. What I said works that way for PayPal. Looks like for Stripe subscription we were only offering that “no expiry” type membership level setup. The main reason was the the subscription updated even actually gets triggered for many different types of scenario (not only just for recurring charges). I have just worked on enhancing the webhook handler so the Stripe subscription can also work for the duration type membership level setup. This should handle it for both the SCA and non SCA subscription payments. Lets see how this works.
Can you please download this copy of the plugin and check it out:
[the released version of the plugin contains this update now]November 12, 2019 at 11:58 am #19274Marc LP
ParticipantThank you.
After installing this new version of your plugin we’ve found that the event is finally processed, but in our tests some subscriptions were not updated because:
“Did not find an existing record in the members table for subscriber ID: sub_aaaaa”
I’ve debugged your new code and find that the requested subscriber ID is correct, but it is not exactly the same value that the column “subscr_id” of the table “wp_swpm_members_tbl” has. In particular, some Stripe subscriptions are saved in this format:
sub_aaaaa|570
Where 570 happens to be the ID of our old Stripe subscription button. I don’t know why some subscriptions are saved like this while others are not.Anyway, I’ve modified the line 298 of the file “/ipn/swpm-stripe-subscription-ipn.php” this way:
$query_db = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}swpm_members_tbl WHERE subscr_id = %s OR subscr_id LIKE %s", $subscr_id, $subscr_id.'|%' ), OBJECT );So the subscr_id must match the beginning of the column value, and that worked and all subscriptions finally began updating.
As a side note, the recurring subscription payments still does not appear in the “Payments” section of your plugin. You should fix that too.
November 12, 2019 at 11:19 pm #19276admin
KeymasterThank you. I will update the code also. I will work on adding the stripe recurring payments to the menu also.
-
AuthorPosts
- You must be logged in to reply to this topic.