samifalouti commited on
Commit
bce2a8e
·
verified ·
1 Parent(s): bef7d9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -31,8 +31,11 @@ def create_payment(req: PaymentRequest):
31
  "Content-Type": "application/json"
32
  }
33
  r = requests.post("https://api.chargily.com/v1/payment-links", json=payload, headers=headers)
34
- if r.status_code != 201:
35
  raise HTTPException(status_code=500, detail=r.text)
36
- return r.json()
 
 
 
37
  except Exception as e:
38
  raise HTTPException(status_code=500, detail=str(e))
 
31
  "Content-Type": "application/json"
32
  }
33
  r = requests.post("https://api.chargily.com/v1/payment-links", json=payload, headers=headers)
34
+ if not r.ok:
35
  raise HTTPException(status_code=500, detail=r.text)
36
+
37
+ # Return only the payment_url
38
+ payment_link = r.json().get("payment_url")
39
+ return {"payment_url": payment_link}
40
  except Exception as e:
41
  raise HTTPException(status_code=500, detail=str(e))