Talking to a payment provider
Most stores never touch raw card data. They integrate a payment provider that handles cards and returns a token. This keeps sensitive data out of your systems and reduces compliance scope.
Authorize then capture
- Authorize checks that funds exist and places a hold, but does not move money.
- Capture actually transfers the held funds, often done when the order ships.
Separating these lets you reserve money at checkout but only charge when you can fulfill.
Handling async results
Payment results often arrive asynchronously through a webhook from the provider. Your endpoint must be idempotent, because the provider may deliver the same event more than once. Verify the webhook signature to ensure it really came from the provider.
Reliability
- Use an idempotency key per payment attempt so retries do not double charge.
- Store each payment state so you can reconcile against the provider if a response is lost.
Key idea
Tokenize cards, split authorize from capture, and make webhook handling idempotent and signature verified.