When a subscription has been moved into the "Payment Method Issue" section of the Subscriptions CP any Stripe webhooks for that subscription fail.
In our case, we have a couple of customers with subscriptions that failed payments. It looks like the payment method has then been updated. But when Stripe sends the webhook, it causes an error because the subscription cannot be found.
Stripe continues to send the webhook at decreasing time intervals.
The log says that the subscription cannot be found and refers to line 605 of commerce-stripe/src/bas/SubscriptionGateway.php
do {
// Handle cases when Stripe sends us a webhook so soon that we haven't processed the subscription that triggered the webhook
sleep(1);
$subscription = Subscription::find()->reference($subscriptionReference)->one();
$counter++;
} while (!$subscription && $counter < $limit);
if (!$subscription) {
throw new SubscriptionException('Subscription with the reference “' . $subscriptionReference . '” not found when processing webhook ' . $data['id']);
}
It would appear that the query that is meant to fetch the subscription fails. Is this perhaps because of a status?
Expected behavior
I'd expect the subscription to be reactivated and moved out of the Payment Method Issue section, and the webhook to succeed.
Additional info
I'll add, we are still investigating this as it might be something to do with the Stripe setting on how to handle a failed subscription.
@fantasticmachine Let us know what you'll find. If the issue is on Stripe or Commerce side.
Well there’s definitely an issue with Commerce not finding the subscription. Whether it should or not, I’m not sure.
The payment appears to have been successful but Commerce has effectively deactivated the subscription so Stripe can’t deliver the Webhook.
On 31 Mar 2021, at 10:41, Dale Ramirez @.*> wrote:
@fantasticmachine https://github.com/fantasticmachine Let us know what you'll find. If the issue is on Stripe or Commerce side.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/craftcms/commerce/issues/2063#issuecomment-810928550, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGJ5ONXRBVCLF2SBKXEWY3TGLU27ANCNFSM42BZ64LQ.
Looks like there was something similar happening in https://github.com/craftcms/commerce-stripe/commit/d71dd172434a63b399d4bba89711738f8ad7baf5
I believe we have suffered the same issue recently. Our problem subscription is in the "Failed to Start" group, with no apparent way to adjust it.
A customer has signed up for a subscription, there's a record of the subscription on the Customer, but it shows up in the Commerce > Subscriptions > Failed to Start area. Looking at the record on the customer, there was a billing issue recorded, AND their subscription is marked as paid. Looking in Stripe, the initial payment was declined due to insufficient funds, but then they have paid...
We have no way that I can see to mark that customers subscription as a valid subscription, and it looks like any automated method with webhooks is not working.
I think this a similar issue here https://github.com/craftcms/commerce-stripe/issues/134. I am going to close this issue cause this is a Commerce stripe plugin issue.
I have the same issue, so far not on a large scale, but means that client is out of sync on a lot of their subscription orders.
@pdaleramirez I don't think this is quite the same issue as the one you have referenced.
The issue is more akin to craftcms/commerce-stripe@d71dd17 which @andris-sevcenko fixed. But his fix was in a different part of the codebase for a different circumstance.
In our case the customer's subscription renewal payment fails with Stripe. Commerce responds to this marking the subscription as suspended.
What this then means, is that if the subscription later receives a successful payment (for instance if funds become available on the card) the success webhook is sent to Commerce. But Commerce cannot retrieve the subscription because it is not looking for suspended subscriptions in its query. Thus it throws an exception saying that the subscription doesn't exist.
This is becoming a serious issue for us as the customer base grows and our subscriptions become more popular. Any failed payments result in a suspended subscription that cannot be restarted by a subsequent successful payment.
Can someone take a closer look at this to confirm what I (and others here) think is happening?
Most helpful comment
@pdaleramirez I don't think this is quite the same issue as the one you have referenced.
The issue is more akin to craftcms/commerce-stripe@d71dd17 which @andris-sevcenko fixed. But his fix was in a different part of the codebase for a different circumstance.
In our case the customer's subscription renewal payment fails with Stripe. Commerce responds to this marking the subscription as suspended.
What this then means, is that if the subscription later receives a successful payment (for instance if funds become available on the card) the success webhook is sent to Commerce. But Commerce cannot retrieve the subscription because it is not looking for suspended subscriptions in its query. Thus it throws an exception saying that the subscription doesn't exist.
This is becoming a serious issue for us as the customer base grows and our subscriptions become more popular. Any failed payments result in a suspended subscription that cannot be restarted by a subsequent successful payment.
Can someone take a closer look at this to confirm what I (and others here) think is happening?