How to Authorize and Capture a Payment
Platform engineers implementing or debugging the actual authorize/capture request-response cycle β full flow, request/response shapes, and validation rules. For the conceptual model (what pre-auth/capture is, expiry, partial authorization), see Pre-Auth & Capture Flow.
Sequence Diagram β Full Flowβ
Step 1 β Create Pre-Auth Paymentβ
Requestβ
Sample Request β Pre-Auth
curl -X POST "https://api-stg.uhg.com/api/financial/commerce/nonprodcheckout/v2/payments" \
-H "Authorization: Bearer <token>" \
-H "X-Merchant-Id: b955db5e-aef2-47de-bbb9-c80b9cc16e8f" \
-H "X-Upstream-Env: dev" \
-H "Content-Type: application/json" \
-d '{
"merchantTransactionId": "preauth-20260404-001",
"amount": 25000,
"currencyCode": "USD",
"authorizeCard": true,
"partialAuthorization": true,
"customer": {
"hsid": "b313c1d1-b5b6-4ec7-8b5a-3a9cf7755060"
},
"paymentAllocations": [
{
"amount": 25000,
"paymentMethodId": "b0b3c48d-4cf6-404a-a554-e14640a51c5b"
}
]
}'
Response β 202 Acceptedβ
{
"url": "https://api-stg.uhg.com/.../v2/payments/770e8400-e29b-41d4-a716-446655440000",
"data": {
"id": "770e8400-e29b-41d4-a716-446655440000",
"merchantTransactionId": "preauth-20260404-001",
"amount": 25000,
"currencyCode": "USD",
"status": "INITIATED",
"authorizeCard": true,
"partialAuthorization": true
}
}
GET β After Authorization (200 OK)β
{
"data": {
"id": "770e8400-e29b-41d4-a716-446655440000",
"amount": 25000,
"authorizedAmount": 25000,
"capturedAmount": 0,
"status": "AUTHORIZED",
"authorizeCard": true,
"partialAuthorization": true,
"paymentAllocations": [
{
"id": "cccc1111-2222-3333-4444-555566667777",
"amount": 25000,
"authorizedAmount": 25000,
"capturedAmount": 0,
"status": "AUTHORIZED"
}
]
}
}
Webhook β PAYMENT_AUTHORIZEDβ
{
"name": "PAYMENT_AUTHORIZED",
"source": "merchant-portal",
"payload": {
"id": "770e8400-e29b-41d4-a716-446655440000",
"merchantTransactionId": "preauth-20260404-001",
"amount": 25000,
"status": "AUTHORIZED",
"paymentAllocations": [
{
"id": "cccc1111-2222-3333-4444-555566667777",
"amount": 25000,
"authorizedAmount": 25000,
"status": "AUTHORIZED"
}
]
}
}
Step 2 β Captureβ
Full Capture (No Request Body)β
Omitting the request body captures the full authorized amount on all allocations.
curl -X PATCH "https://api-stg.uhg.com/api/financial/commerce/nonprodcheckout/v2/payments/770e8400-e29b-41d4-a716-446655440000/capture" \
-H "Authorization: Bearer <token>" \
-H "X-Merchant-Id: b955db5e-aef2-47de-bbb9-c80b9cc16e8f" \
-H "X-Upstream-Env: dev" \
-H "Content-Type: application/json"
Partial Capture (With Request Body)β
Capture less than the authorized amount. The remaining authorized amount is released.
Sample Request β Partial Capture
curl -X PATCH "https://api-stg.uhg.com/api/financial/commerce/nonprodcheckout/v2/payments/770e8400-e29b-41d4-a716-446655440000/capture" \
-H "Authorization: Bearer <token>" \
-H "X-Merchant-Id: b955db5e-aef2-47de-bbb9-c80b9cc16e8f" \
-H "X-Upstream-Env: dev" \
-H "Content-Type: application/json" \
-d '{
"paymentAllocations": [
{
"id": "cccc1111-2222-3333-4444-555566667777",
"amount": 18000
}
],
"metadata": {
"captureReason": "partial-fulfillment"
}
}'
Capture Validation Rulesβ
| Rule | HTTP Status | Error |
|---|---|---|
Payment must be in AUTHORIZED state | 400 | INVALID_REQUEST |
Capture amount β€ authorized amount per allocation | 400 | INVALID_REQUEST |
Allocation id must belong to the payment | 400 | INVALID_REQUEST |
| Combined metadata (existing + new) β€ 20 entries | 400 | INVALID_REQUEST |
Capture Response β 202 Acceptedβ
{
"url": "https://api-stg.uhg.com/.../v2/payments/770e8400-e29b-41d4-a716-446655440000",
"data": {
"id": "770e8400-e29b-41d4-a716-446655440000",
"amount": 25000,
"authorizedAmount": 25000,
"capturedAmount": 18000,
"status": "COMPLETED",
"paymentAllocations": [
{
"id": "cccc1111-2222-3333-4444-555566667777",
"amount": 25000,
"authorizedAmount": 25000,
"capturedAmount": 18000,
"status": "COMPLETED"
}
]
}
}
Related Documentationβ
- Pre-Auth & Capture Flow β the conceptual model, expiry, and partial authorization
- Payment Lifecycle States
- Cancel Payment
- API Reference β Capture