aiqtech commited on
Commit
ac8e3c3
โ€ข
1 Parent(s): 5cd2cc8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +109 -0
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()