Someone paid for our product and got nothing. The payment went through, the provider sent us the event, and our handler answered with a success code. The customer was charged and their account stayed on the free plan. Nobody got an error, so nobody noticed.
Here is what happened, and the three checks we added so it cannot happen silently again.
The payer had no account yet
The customer paid before they created an account. Our webhook looked up the account by the payer's email, found nothing, and returned 200 . From the provider's side the delivery succeeded, so it never retried.
const user = await findUserByEmail ( email ) ; if ( ! user ) { logger . warn ( "no registered user, skipping" ) ; return NextResponse . json ( { received : true } , { status : 200 } ) ; }
Enter fullscreen mode
Exit fullscreen mode
That 200 is the bug. It says "I handled this", and we did not.
What we changed
Keep the entitlement until it can be used.…