Granting credits on invoice.paid — out-of-order webhooks and missing subscription
#1203
-
|
Hi everyone, thanks for this gem. I’m using Rails 8 with Pay (only with Stripe) and SolidQueue. It works great in development, but in production I’ve noticed something odd: sometimes the I know Stripe doesn’t guarantee webhook order, so that part makes sense. What I’m not sure about is the best way to handle it. Would you consider it reasonable to rely on def subscription
@_subscription ||= begin
Pay::Subscription.find_by(processor_id: subscription_id) ||
begin
Pay::Stripe::Subscription.sync(subscription_id)
Pay::Subscription.find_by(processor_id: subscription_id)
end
end
endDoes this seem like the right solution to you? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Yep, you're on the right track! The sync will ensure you get the up-to-date data on the Stripe Subscription, so you may want to just always sync it. pay_subscription = Pay::Stripe::Subscription.sync(subscription_id) |
Beta Was this translation helpful? Give feedback.
Yep, you're on the right track!
The sync will ensure you get the up-to-date data on the Stripe Subscription, so you may want to just always sync it.
syncwill also return the subscription so you could just do: