Validate Third-Party Responses and Failure Handling
Bind authentic provider data to local merchant, payment, order, amount, and currency before bounded retries or fulfillment.
You’re reading a preview. Premium includes the full lesson and specialist practice. View the full curriculum.
A genuine provider response can authorize the wrong thing
Safe API consumption means treating external responses as input even when they arrive over verified TLS from a trusted provider. Transport authenticity establishes the peer. Schema validation establishes accepted structure. Business binding establishes whether those facts authorize this local operation.
CheckoutDock asks a payment provider about a payment ID supplied during an order-confirmation flow. The provider truthfully returns paid for a cheap order, but the handler marks a different expensive order paid because it checks only status. No forged certificate, signature, or malformed JSON is required.
{
"payment_id": "pay-small",
"merchant_id": "merchant-north",
"order_reference": "order-small",
"amount_minor": 500,
"currency": "USD",
"status": "settled"
}
The local order being confirmed expects pay-large, reference order-large, amount 50,000 minor units, and the same currency. “Paid” is a fact about the provider's returned payment, not universal permission to settle any order.