Menu

1 / 2

Why Paddle's subscription.activated arrives before subscription.created

DEV Community·FetchSandbox·6 months ago
#xvPK8ByW
#testing#paddle#webhooks#subscription#created
Reading 0:00
15s threshold

You'd think events fire in the order things happen. They don't.

I was building a Paddle integration last week. Subscription billing, nothing fancy. Customer clicks buy, Paddle handles checkout, my app gets webhooks and updates the database.

The flow should be simple:

Customer completes checkout

subscription.created fires

subscription.activated fires

My app inserts a row on .created , updates status on .activated

That's what I built. It worked great in my head.

What actually happened

In production, subscription.activated arrived before subscription.created about 30% of the time.

My handler did a database insert on subscription.created :

case ' subscription.created ' : await db . insert ( subscriptions ). values ({ paddleId : event . data . id , status : ' created ' , customerId : event . data . customer_id , }); break ;

Enter fullscreen mode

Exit fullscreen mode

And an update on subscription.activated :

case ' subscription.activated ' : await db . update ( subscriptions ) .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.