's'
This commit is contained in:
BIN
app/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
app/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
app/__pycache__/main.cpython-312.pyc
Normal file
BIN
app/__pycache__/main.cpython-312.pyc
Normal file
Binary file not shown.
49
app/main.py
49
app/main.py
@@ -90,27 +90,32 @@ async def payh5(item: dict):
|
|||||||
# 返回结果中包含`jsapi`字段,该字段的值即是前端发起时所需的6个支付参数
|
# 返回结果中包含`jsapi`字段,该字段的值即是前端发起时所需的6个支付参数
|
||||||
headers = {"content-type": "application/x-www-form-urlencoded"}
|
headers = {"content-type": "application/x-www-form-urlencoded"}
|
||||||
response = requests.post(request_url, data=order, headers=headers)
|
response = requests.post(request_url, data=order, headers=headers)
|
||||||
# if response:
|
print('response.json()----',response.json())
|
||||||
# print(response.json())
|
if response:
|
||||||
# return response.json()
|
print(response.json())
|
||||||
|
return response.json()
|
||||||
|
|
||||||
payjs_result = response.json()
|
|
||||||
# 判断支付是否成功(这里根据 PayJS 返回结果自行判断)
|
|
||||||
if payjs_result.get("return_code") == "SUCCESS":
|
class CreateUserRequest(BaseModel):
|
||||||
# 支付成功,新增 memos 用户
|
username: str = None
|
||||||
memos_data = {
|
password: str = None
|
||||||
"username": item.get("username", f"user{timenew}"),
|
|
||||||
"password": item.get("password", "123456"),
|
@app.post("/create_user")
|
||||||
"role": "USER",
|
async def create_user(item: CreateUserRequest):
|
||||||
"state": "NORMAL"
|
timenew = str(int(time.time()))
|
||||||
}
|
memos_data = {
|
||||||
memos_headers = {
|
"username": item.username or f"user{timenew}",
|
||||||
"Content-Type": "application/json",
|
"password": item.password or "123456",
|
||||||
"Authorization": f"Bearer {MEMOS_TOKEN}"
|
"role": "USER",
|
||||||
}
|
"state": "NORMAL"
|
||||||
memos_resp = requests.post(MEMOS_API, json=memos_data, headers=memos_headers)
|
}
|
||||||
memos_result = memos_resp.json()
|
memos_headers = {
|
||||||
return JSONResponse({"payjs": payjs_result, "memos": memos_result})
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": f"Bearer {MEMOS_TOKEN}"
|
||||||
|
}
|
||||||
|
memos_resp = requests.post(MEMOS_API, json=memos_data, headers=memos_headers)
|
||||||
|
memos_result = memos_resp.json()
|
||||||
|
print('memos_result-',memos_result)
|
||||||
|
return memos_result
|
||||||
|
|
||||||
# 支付未成功,直接返回 PayJS 信息
|
|
||||||
return JSONResponse({"payjs": payjs_result})
|
|
||||||
2
run.py
2
run.py
@@ -2,5 +2,5 @@ import uvicorn
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# uvicorn.run("app.main:app", host="0.0.0.0", port=8700, reload=True)
|
# uvicorn.run("app.main:app", host="0.0.0.0", port=8700, reload=True)
|
||||||
uvicorn.run("app.main:app", host="127.0.0.1", port=8700, reload=True)
|
uvicorn.run("app.main:app", host="0.0.0.0", port=8200, reload=True)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user