使用者於費用繳交申請後,匯款或刷卡後,查詢費用繳交之相關紀錄。
@app.post("/sinopacApi_OrderQuery_order", summary="永豐訂單查詢API(訂單編號查詢)" )# , response_model=ApiResultGet
async def sinopacApi_Order(orderNo: str = "A_20210924_1632450255.946536"):
start = time.time()
# ShopNo 由主辦單位提供,此處示例以 xxx 取代
Shop_No = {'ShopNo':"NAXXX_001"}
NonceValue=getNonce(Shop_No)
SHAValue ,IVValue= getSHAValue(NonceValue)
hashID = getAESKey()
send_message_ori = {
"ShopNo": Shop_No["ShopNo"],
"OrderNo": orderNo,
"PayDateTimeS":"",
"PayDateTimeE":"",
"PayFlag": ""
}
print('send_message_ori => ',send_message_ori)
send_message_TextHash=getMessageTextHash(send_message_ori,NonceValue,hashID)
SignValue = getSignValue(send_message_TextHash)
jsonText=json.dumps(send_message_ori, ensure_ascii=False).replace(' ', "")
print(jsonText)
aes_encrypt_str = AES_CBC_Encrpt(hashID, IVValue, jsonText)
print(f'加密結果為: {aes_encrypt_str}')
send_POST_message={
"Version": "1.0.0",
"ShopNo": Shop_No["ShopNo"],
"APIService": "OrderQuery",
"Sign": SignValue,
"Nonce": NonceValue,
"Message": aes_encrypt_str
}
print('send_POST_message => ',send_POST_message)
requests_link = 'https://apisbx.sinopac.com/funBIZ/QPay.WebAPI/api/Order'
r = requests.post(url = requests_link, json = send_POST_message )
print('status_code => ',r.status_code)
print('status_Nonce => ',r.json()["Nonce"])
NonceValue=r.json()["Nonce"]
SHAValue ,IVValue= getSHAValue(NonceValue)
hashID = getAESKey()
aes_decrypt_str = AES_CBC_Decrypt(hashID, iv=IVValue, data=r.json()["Message"])
print(f'解密結果為: {aes_decrypt_str}')
decrypt_dist=json.loads(aes_decrypt_str)
r.close()
return {"message": "success", 'time': time.time() - start ,"decrypt_dist" : decrypt_dist}
uvicorn app.main:app --host 0.0.0.0 --port 80
設定
以訂單A_20210924_1632450255.946536為例,參數為A_20210924_1632450255.946536,設定如下
執行結果
以下為執行結果,主要得到的資訊為建立訂單程序為處理成功,訂單狀態為1A400,表示已經匯款完成了。
今天做完訂單狀態的查詢,明天要做整批的訂單查詢,固定每日從永豐服務抓回歷史訂單資訊。