Forum Replies Created
-
AuthorPosts
-
April 10, 2024 at 12:20 pm in reply to: Fatal error! Payment with ref_id swpm_XXXX|1195 can’be found. #27894
jaesga
ParticipantThe error happends while executing the callback function (SwpmStripeSCASubscriptionIpnHandler::handle_stripe_ipn).
After paying on stripe everything seems fine, then when redirected to my site executing that function leads to the error. Searching into the code I’m pretty sure the problem is a race condition.
When reaching swpm-stripe-sca-subscription-ipn.php:L69 $sess is false, because $events array (L50) is empty.
Activating my logs, I see that this error (Fatal error! Payment with ref_id %s can’t be found) is logged before the webhook notification logs for events invoice.paid and invoice.payment_succeeded (check my first messsage).
I fixed on my site by adding some retries with 1s sleep in between to fetch the “checkout.session.completed” events from Stripe and after 1-2s the event is ready and things starts working again.
Hope this helps you to reproduce / patch.
Regards,
JApril 8, 2024 at 10:48 am in reply to: Fatal error! Payment with ref_id swpm_XXXX|1195 can’be found. #27887jaesga
ParticipantBoth (test / live) are configured the same way:
URL:
ENV_HOST?swpm_process_stripe_subscription=1&hook=1Events:
charge.refunded
customer.subscription.deleted
customer.subscription.updated
invoice.paid
invoice.payment_succeededLet me know if something is not properly set up
April 5, 2024 at 2:20 pm in reply to: Fatal error! Payment with ref_id swpm_XXXX|1195 can’be found. #27880jaesga
ParticipantI am having exactly the same problem since few days ago.
I think the problem is on a race condition under SwpmStripeSCASubscriptionIpnHandler::handle_stripe_ipn.
I realized that the callback to my site (and that method execution) was perform before these Webhook events are received:[2024/04/05 16:12:31] – SUCCESS: End of Stripe subscription webhook processing. Webhook type: invoice.paid
[2024/04/05 16:12:32] – SUCCESS: Stripe subscription webhook received: invoice.payment_succeeded. Checking if we need to handle this webhook.
[2024/04/05 16:12:32] – SUCCESS: End of Stripe subscription webhook processing. Webhook type: invoice.payment_succeededThis probably make “checkout.session.completed” event still not available causing the error.
I added for testing purposes just a sleep(2) to the code and things start to work again.Can some developer of the plugin check this out plz? Maybe a recent update of the plugin break something? I will try to review the changelog.
Thanks in advance,
J. -
AuthorPosts