class ApiSource(BaseModel):
householder:str
Amount:int #配合规格,自动补上小数点後两位00
OrderNo:str
PayType:str
订单建置API
@app.post("/sinopacApi_Order", summary="永丰建置订单API" )# , response_model=ApiResultGet
async def sinopacApi_Order(apiparams: ApiSource):
start = time.time()
# ShopNo 由主办单位提供,此处示例以 xxx 取代
Shop_No = {'ShopNo':"NAxxx_001"}
NonceValue=getNonce(Shop_No)
SHAValue ,IVValue= getSHAValue(NonceValue)
hashID = getAESKey()
lastDate= datetime.date.today() + datetime.timedelta(days=1)
print("lastDate",str(lastDate).replace("-",""))
print("apiparams.PayType => ",apiparams.PayType)
OrderNo_total=apiparams.PayType+"_"+apiparams.OrderNo+"_"+str(datetime.datetime.now().timestamp())
if apiparams.PayType=="A":
send_message_ori = {
"ShopNo": Shop_No["ShopNo"],
"OrderNo": OrderNo_total,
"Amount": apiparams.Amount*100,
"CurrencyID": "TWD",
"PayType": apiparams.PayType, #管理费仅用汇款,无信用卡缴费模式
"ATMParam": {"ExpireDate":str(lastDate).replace("-","")},
"CardParam": {},
"ConvStoreParam": {},
"PrdtName": "order",
"Param1": apiparams.householder,
"Param2": apiparams.OrderNo,
"ReturnURL": "http://10.11.22.113:8803/QPay.ApiClient/Store/Return",
"BackendURL": "http://10.11.22.113:8803/QPay.ApiClient/AutoPush/PushSuccess",
}
elif apiparams.PayType=="C":
send_message_ori = {
"ShopNo": Shop_No["ShopNo"],
"OrderNo": OrderNo_total,
"Amount": apiparams.Amount*100,
"CurrencyID": "TWD",
"PayType": apiparams.PayType, #管理费仅用汇款,无信用卡缴费模式
"ATMParam": {},
"CardParam": {"AutoBilling":"Y"},
"ConvStoreParam": {},
"PrdtName": "order",
"Param1": apiparams.householder,
"Param2": apiparams.OrderNo,
"ReturnURL": "http://10.11.22.113:8803/QPay.ApiClient/Store/Return",
"BackendURL": "http://10.11.22.113:8803/QPay.ApiClient/AutoPush/PushSuccess",
}
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)
send_POST_message={
"Version": "1.0.0",
"ShopNo": Shop_No["ShopNo"],
"APIService": "OrderCreate",
"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_json => ',r.json())
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
设定
执行结果
以下为执行结果,主要得到的资讯为查询完成("Description": "S0000 – 处理成功"),同时也可以得到汇款帐,提供客户直接使用ATM汇入费用。
订单建立之後,就是要来查看缴费纪录罗~明天见
<<: Day 22.5 | Livewire 实作 购物网站: 建立资料表
针对 commit 讯息的规范,最为人熟知的是 Angular 的 Commit Message F...
大家新年快乐!上一篇完成後还剩下这些功能: 可以一次删除全部的代办事项 能删除所有已完成的代办事项的...
AddressSanitizer (ASan) 是一种编译器和执行时间技术,会以 零 误报来公开许多...
这几天研究下来,发现有三个词汇很让人搞不懂,也就是人工智慧(Artifical Intellig...
角色情境 小明同时学会输入指令操作着终端机、 以及透过滑鼠操作着图像化介面的 Sourcetree ...