kookmin-sw / timebank-2023-docs

시간은행 문서화
GNU General Public License v3.0
1 stars 0 forks source link

페이앱 등록, 유저생성, 계좌생성, 송금 Bank API 명세 #45

Open seungwoo1124 opened 11 months ago

seungwoo1124 commented 11 months ago

TimeBank API


페이 앱 등록 api

{
    "id":2,
    "name":"timePay",
    "appkey":"a6e107b31149759dd130564af93acfff5c3a7db0f5902ee496d2cd5821328128"
}

유저 등록 api

계좌 개설 api

{
    "password": "..."
}
import requests
import json

url = "http://localhost:8080/api/v1/bank/account"

requestData = {
    "password": "test"
}

#아래 두 변수는 헤더로 들어갑니다.
userContext = {
    "userId": 1,
    "accountId": 1,
    "accountType": "INDIVIDUAL"
}
appName = "testApp"

data = {"password": requestData["password"]}
headers = {"userContext": json.dumps(userContext), "appName": appName, "Content-Type": "application/json"}

response = requests.post(url, json=data, headers=headers)

print(response.status_code)
print(response.text)

송금 api

{
    "sendBankAccountNumber": "...",  송금자 계좌번호
    "receiverBankAccountNumber": "...",  수신자 계좌번호
    "amount": "...",
    "password": "...",
}
{
    "transactionAt":"2023-12-03T13:14:08.0924872",
    "amount":120,
    "balanceSnapshot":300.00,
    "status":"SUCCESS",
    "senderBankAccountNumber":"02-01-03-46",
    "receiverBankAccountNumber":"02-01-04-59"
}

테스트할 데이터

request_data = { 'senderBankAccountNumber': '01-01-02-90', 'receiverBankAccountNumber': '01-01-01-60', 'amount': 120, 'password': '1234' }

송금 유저 컨텍스트

userContext = { "userId": 2, "accountId": 2, "accountType": "INDIVIDUAL" }

POST 요청 보내기

url = 'http://localhost:8080/api/v1/bank/account/transfer' headers = {"userContext": json.dumps(userContext), "Content-Type": "application/json"} response = requests.post(url, headers=headers, data=json.dumps(request_data))

응답 확인

print(response.status_code) print(response.text)