Idempotency and retries
Use a stableexternal_reference from your own system for every profile and account, and use it to match records.
Process webhooks idempotently too. Use the event
id to skip events you’ve already handled.
Handle errors
Branch your code on the stable errorreason, not the human-readable message. The message is for people and can change at any time.
Treat changes as asynchronous
Assume creation and status-changing operations finish asynchronously, unless the endpoint explicitly says otherwise. Wait for a webhook or read the resource before treating a change as done. When ordering matters, read the current state of the resource instead of relying on the order events arrive in.Represent amounts exactly
Many financial and token amounts are strings paired with adecimals value. Keep them as strings or use a decimal library. Don’t convert them to floating-point numbers, which lose precision.