Brazilian developer since 2011. Microsoft MVP, Docker Captain, and Google Dev Expert. OpenJS foundation member and Node.js contributor. Loves JavaScript and TypeScript.
In this case I suggest you use other code, the 402 relates to a resource that itself needs a payment, like when you have a premium API and this API is not paid for by the user (just an example).
One code you can use, if your product communicates with something external and you expect something to be true (the payment), you can extend the definition to business rules and use either 412 as this is a precondition for the API to go forth, or 417 (my personal favorite) as it's part of an expectation your server had but it didn't come true.
If you really want to attain to the definition, you can add the Expect header too.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In this case I suggest you use other code, the 402 relates to a resource that itself needs a payment, like when you have a premium API and this API is not paid for by the user (just an example).
One code you can use, if your product communicates with something external and you expect something to be true (the payment), you can extend the definition to business rules and use either 412 as this is a precondition for the API to go forth, or 417 (my personal favorite) as it's part of an expectation your server had but it didn't come true.
If you really want to attain to the definition, you can add the
Expect
header too.