- goal: 특정 계좌에서 출금한다.
- endpoint:
POST /withdrawals/{idempotencyKey} - Content-Type:
application/json - Authorization:
Bearer {accessToken}
- path
idempotencyKey: 멱등키
- body
accountId: 출금 계좌 IDamount: 출금 금액
POST /withdrawals/{idempotencyKey}
Content-Type: application/json
Authorization: Bearer {accessToken}
{
"accountId": 1,
"amount": 10000
}- status:
200 OK - body
status:SUCCEEDED | FAILED | IN_PROGRESStransferId: 거래 IDerrorCode: 실패 코드
FAILED는 HTTP 에러 대신 응답 body로 반환된다.
현재 구현에서 자주 나오는 errorCode는 아래와 같다.
INVALID_REQUESTACCOUNT_NOT_FOUNDOWNER_NOT_FOUNDINSUFFICIENT_BALANCEDAILY_LIMIT_EXCEEDED
{
"status": "SUCCEEDED",
"transferId": 123,
"errorCode": null
}-
status:
400 Bad Request -
context
- request body validation failure
- idempotency key expired
- same idempotency key with different request body
-
status:
401 Unauthorized -
context
- authentication required
-
status:
404 Not Found -
context
- idempotency key not found
-
status:
500 Internal Server Error -
context
- unexpected persistence failure