Skip to content

Commit

Permalink
fix: 결제 API 파라미터 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
YoungeuiHong committed Jun 1, 2024
1 parent 4e46cc1 commit b22096e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
15 changes: 10 additions & 5 deletions korail_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@
import threading
import os
from dotenv import load_dotenv
from pydantic import BaseModel

load_dotenv()

class Card(BaseModel):
card_number: str
expiration_year: str
expiration_month: str
cvc: str


KORAIL_ID = os.getenv("KORAIL_ID")
KORAIL_PW = os.getenv("KORAIL_PW")
CARD_NUMBER = os.getenv("CARD_NUMBER")
EXP_MONTH = os.getenv("EXP_MONTH")
EXP_YEAR = os.getenv("EXP_YEAR")
CARD_PASSWORD = os.getenv("CARD_PASSWORD")
AUTH_NUMBER = os.getenv("AUTH_NUMBER")

Expand Down Expand Up @@ -114,7 +119,7 @@ def finalize_payment(driver):
pay_button.click()


async def pay_train():
async def pay_train(cardInfo: Card):
alert_thread = threading.Thread(target=handle_alerts, args=(driver,))
alert_thread.daemon = True
alert_thread.start()
Expand All @@ -123,7 +128,7 @@ async def pay_train():
navigate_to_reservation_page(driver)
click_payment_button(driver)
enter_card_details(
driver, CARD_NUMBER, EXP_MONTH, EXP_YEAR, CARD_PASSWORD, AUTH_NUMBER
driver, cardInfo.card_number, cardInfo.expiration_month, cardInfo.expiration_year, CARD_PASSWORD, AUTH_NUMBER
)
agree_and_issue_ticket(driver)
finalize_payment(driver)
Expand Down
9 changes: 7 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class Train(BaseModel):
date: str
time: str

class Card(BaseModel):
card_number: str
expiration_year: str
expiration_month: str
cvc: str

@app.post("/search")
async def search_train_endpoint(train: Train):
Expand All @@ -36,8 +41,8 @@ async def reserve_train_endpoint(train: Train):


@app.post("/pay")
async def pay_train_endpoint():
return await pay_train()
async def pay_train_endpoint(cardInfo: Card):
return await pay_train(cardInfo)


@app.post("/extract_card_info")
Expand Down

0 comments on commit b22096e

Please sign in to comment.