Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests
|
3 |
+
|
4 |
+
def request_batch_key(onfftid, pay_type, method, cert_type, order_no, user_nm, user_phone2, product_nm,
|
5 |
+
card_user_type, card_no, expire_date, auth_value, password, tot_amt):
|
6 |
+
url = "https://store.onoffkorea.co.kr/fix/index.php"
|
7 |
+
payload = {
|
8 |
+
"onfftid": onfftid,
|
9 |
+
"pay_type": pay_type,
|
10 |
+
"method": method,
|
11 |
+
"cert_type": cert_type,
|
12 |
+
"order_no": order_no,
|
13 |
+
"user_nm": user_nm,
|
14 |
+
"user_phone2": user_phone2,
|
15 |
+
"product_nm": product_nm,
|
16 |
+
"card_user_type": card_user_type,
|
17 |
+
"card_no": card_no,
|
18 |
+
"expire_date": expire_date,
|
19 |
+
"auth_value": auth_value,
|
20 |
+
"password": password,
|
21 |
+
"tot_amt": tot_amt
|
22 |
+
}
|
23 |
+
|
24 |
+
response = requests.post(url, data=payload)
|
25 |
+
|
26 |
+
if response.status_code == 200:
|
27 |
+
return response.json()
|
28 |
+
else:
|
29 |
+
return f"Error: {response.status_code} - {response.text}"
|
30 |
+
|
31 |
+
def request_payment(onfftid, fix_key, tot_amt, card_user_type, auth_value, install_period, user_nm,
|
32 |
+
user_phone2, product_nm, pay_type, method, order_no):
|
33 |
+
url = "https://store.onoffkorea.co.kr/fix/index.php"
|
34 |
+
payload = {
|
35 |
+
"onfftid": onfftid,
|
36 |
+
"fix_key": fix_key,
|
37 |
+
"tot_amt": tot_amt,
|
38 |
+
"card_user_type": card_user_type,
|
39 |
+
"auth_value": auth_value,
|
40 |
+
"install_period": install_period,
|
41 |
+
"user_nm": user_nm,
|
42 |
+
"user_phone2": user_phone2,
|
43 |
+
"product_nm": product_nm,
|
44 |
+
"pay_type": pay_type,
|
45 |
+
"method": method,
|
46 |
+
"order_no": order_no
|
47 |
+
}
|
48 |
+
|
49 |
+
response = requests.post(url, data=payload)
|
50 |
+
|
51 |
+
if response.status_code == 200:
|
52 |
+
return response.json()
|
53 |
+
else:
|
54 |
+
return f"Error: {response.status_code} - {response.text}"
|
55 |
+
|
56 |
+
with gr.Blocks() as demo:
|
57 |
+
gr.Markdown("# API ์ฐ๋ ํ
์คํธ")
|
58 |
+
|
59 |
+
with gr.Tab("์นด๋ ๋ฐฐ์นํค ๋ฐ๊ธ ์์ฒญ"):
|
60 |
+
onfftid = gr.Textbox(label="์จ์คํ์ฝ๋ฆฌ์ TID")
|
61 |
+
pay_type = gr.Textbox(label="๊ฒฐ์ ํ์
", value="fixKey")
|
62 |
+
method = gr.Textbox(label="๋ฉ์๋", value="request")
|
63 |
+
cert_type = gr.Radio(["0", "1"], label="์ธ์ฆ ์ฌ๋ถ", value="0")
|
64 |
+
order_no = gr.Textbox(label="์ฃผ๋ฌธ๋ฒํธ")
|
65 |
+
user_nm = gr.Textbox(label="์ฃผ๋ฌธ์ ์ด๋ฆ")
|
66 |
+
user_phone2 = gr.Textbox(label="์ฃผ๋ฌธ์ ์ฐ๋ฝ์ฒ")
|
67 |
+
product_nm = gr.Textbox(label="์ํ๋ช
")
|
68 |
+
card_user_type = gr.Radio(["0", "1"], label="์นด๋ ํ์
", value="0")
|
69 |
+
card_no = gr.Textbox(label="์นด๋๋ฒํธ")
|
70 |
+
expire_date = gr.Textbox(label="์ ํจ๊ธฐ๊ฐ(YYMM)")
|
71 |
+
auth_value = gr.Textbox(label="์ฃผ๋ฏผ(์ฌ์
์)๋ฑ๋ก๋ฒํธ")
|
72 |
+
password = gr.Textbox(label="์นด๋๋น๋ฐ๋ฒํธ ์ 2์๋ฆฌ")
|
73 |
+
tot_amt = gr.Number(label="๊ฒฐ์ ๊ธ์ก")
|
74 |
+
|
75 |
+
batch_key_button = gr.Button("๋ฐฐ์นํค ๋ฐ๊ธ ์์ฒญ")
|
76 |
+
batch_key_output = gr.JSON(label="์๋ต ๊ฒฐ๊ณผ")
|
77 |
+
|
78 |
+
batch_key_button.click(
|
79 |
+
request_batch_key,
|
80 |
+
inputs=[onfftid, pay_type, method, cert_type, order_no, user_nm, user_phone2, product_nm,
|
81 |
+
card_user_type, card_no, expire_date, auth_value, password, tot_amt],
|
82 |
+
outputs=batch_key_output
|
83 |
+
)
|
84 |
+
|
85 |
+
with gr.Tab("์นด๋ ๋ฐฐ์นํค ๊ฒฐ์ ์น์ธ ์์ฒญ"):
|
86 |
+
onfftid_pay = gr.Textbox(label="์จ์คํ์ฝ๋ฆฌ์ TID")
|
87 |
+
fix_key = gr.Textbox(label="์นด๋ ๋ฐฐ์น ํค")
|
88 |
+
tot_amt_pay = gr.Number(label="๊ฒฐ์ ๊ธ์ก")
|
89 |
+
card_user_type_pay = gr.Radio(["0", "1"], label="์นด๋ ํ์
", value="0")
|
90 |
+
auth_value_pay = gr.Textbox(label="์ฃผ๋ฏผ(์ฌ์
์)๋ฑ๋ก๋ฒํธ")
|
91 |
+
install_period = gr.Dropdown(["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"], label="ํ ๋ถ๊ธฐ๊ฐ")
|
92 |
+
user_nm_pay = gr.Textbox(label="๊ณ ๊ฐ๋ช
")
|
93 |
+
user_phone2_pay = gr.Textbox(label="๊ณ ๊ฐ์ฐ๋ฝ์ฒ")
|
94 |
+
product_nm_pay = gr.Textbox(label="์ํ๋ช
")
|
95 |
+
pay_type_pay = gr.Textbox(label="๊ฒฐ์ ํ์
", value="fixKey")
|
96 |
+
method_pay = gr.Textbox(label="๋ฉ์๋", value="authTran")
|
97 |
+
order_no_pay = gr.Textbox(label="์ฃผ๋ฌธ๋ฒํธ")
|
98 |
+
|
99 |
+
payment_button = gr.Button("๊ฒฐ์ ์น์ธ ์์ฒญ")
|
100 |
+
payment_output = gr.JSON(label="์๋ต ๊ฒฐ๊ณผ")
|
101 |
+
|
102 |
+
payment_button.click(
|
103 |
+
request_payment,
|
104 |
+
inputs=[onfftid_pay, fix_key, tot_amt_pay, card_user_type_pay, auth_value_pay, install_period,
|
105 |
+
user_nm_pay, user_phone2_pay, product_nm_pay, pay_type_pay, method_pay, order_no_pay],
|
106 |
+
outputs=payment_output
|
107 |
+
)
|
108 |
+
|
109 |
+
demo.launch()
|