Update app.py
Browse files
app.py
CHANGED
|
@@ -21,12 +21,25 @@ def request_batch_key(onfftid, pay_type, method, cert_type, order_no, user_nm, u
|
|
| 21 |
"tot_amt": tot_amt
|
| 22 |
}
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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):
|
|
@@ -46,12 +59,25 @@ def request_payment(onfftid, fix_key, tot_amt, card_user_type, auth_value, insta
|
|
| 46 |
"order_no": order_no
|
| 47 |
}
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
with gr.Blocks() as demo:
|
| 57 |
gr.Markdown("# API ์ฐ๋ ํ
์คํธ")
|
|
|
|
| 21 |
"tot_amt": tot_amt
|
| 22 |
}
|
| 23 |
|
| 24 |
+
try:
|
| 25 |
+
response = requests.post(url, data=payload)
|
| 26 |
+
response.raise_for_status() # Raises an HTTPError for bad responses
|
| 27 |
+
|
| 28 |
+
# Try to parse JSON, if fails, return the raw text
|
| 29 |
+
try:
|
| 30 |
+
return response.json()
|
| 31 |
+
except requests.exceptions.JSONDecodeError:
|
| 32 |
+
return {
|
| 33 |
+
"error": "Invalid JSON response",
|
| 34 |
+
"status_code": response.status_code,
|
| 35 |
+
"raw_response": response.text
|
| 36 |
+
}
|
| 37 |
+
except requests.exceptions.RequestException as e:
|
| 38 |
+
return {
|
| 39 |
+
"error": str(e),
|
| 40 |
+
"status_code": getattr(e.response, 'status_code', None),
|
| 41 |
+
"raw_response": getattr(e.response, 'text', None)
|
| 42 |
+
}
|
| 43 |
|
| 44 |
def request_payment(onfftid, fix_key, tot_amt, card_user_type, auth_value, install_period, user_nm,
|
| 45 |
user_phone2, product_nm, pay_type, method, order_no):
|
|
|
|
| 59 |
"order_no": order_no
|
| 60 |
}
|
| 61 |
|
| 62 |
+
try:
|
| 63 |
+
response = requests.post(url, data=payload)
|
| 64 |
+
response.raise_for_status() # Raises an HTTPError for bad responses
|
| 65 |
+
|
| 66 |
+
# Try to parse JSON, if fails, return the raw text
|
| 67 |
+
try:
|
| 68 |
+
return response.json()
|
| 69 |
+
except requests.exceptions.JSONDecodeError:
|
| 70 |
+
return {
|
| 71 |
+
"error": "Invalid JSON response",
|
| 72 |
+
"status_code": response.status_code,
|
| 73 |
+
"raw_response": response.text
|
| 74 |
+
}
|
| 75 |
+
except requests.exceptions.RequestException as e:
|
| 76 |
+
return {
|
| 77 |
+
"error": str(e),
|
| 78 |
+
"status_code": getattr(e.response, 'status_code', None),
|
| 79 |
+
"raw_response": getattr(e.response, 'text', None)
|
| 80 |
+
}
|
| 81 |
|
| 82 |
with gr.Blocks() as demo:
|
| 83 |
gr.Markdown("# API ์ฐ๋ ํ
์คํธ")
|