first commit

This commit is contained in:
jefferyzhao
2025-07-31 17:39:37 +08:00
commit 9565e29ae0
24 changed files with 701 additions and 0 deletions

53
FuiouPay.py Normal file
View File

@ -0,0 +1,53 @@
import json
from datetime import datetime
import requests
from Crypto.PublicKey import RSA
import base64
from Crypto.Cipher import PKCS1_v1_5
# 使用公钥加密
def rsa_long_encrypt(public_key,msg, length=100):
"""
单次加密串的长度最大为 (key_size/8)-11
1024bit的证书用100 2048bit的证书用 200
"""
pub_key = RSA.importKey(open(public_key).read())
# pub_key = RSA.importKey(open('E:/YinJian/银建支付对接维护说明/富友/fy-enterprise-wechat-payment-push/pub_key.pem').read())
pubobj = PKCS1_v1_5.new(pub_key)
res = []
for i in range(0, len(msg), length):
res.append(pubobj.encrypt(msg[i:i + length].encode('GBK')))
return base64.b64encode(b"".join(res)).decode('GBK')
class H5Main:
def __init__(self, sub_mchnt_cd):
self.mchnt_cd = "0001000F7152279"
self.sub_mchnt_cd = sub_mchnt_cd
self.url = 'https://aggpcpay.fuioupay.com/aggh5Gate.fuiou'
self.notify_url = "http://web.jiyuankeshang.com/api4/paymentCallBack"
self.page_notify_url = "http://web.jiyuankeshang.com/api4/page_notify"
# self.notify_url = "http://172.16.6.15:3006/paymentCallBack"
def unified_order(self, order_no, total, description):
param = {
"mchnt_cd": self.mchnt_cd,
"sub_mchnt_cd": self.sub_mchnt_cd,
"order_date": datetime.now().strftime("%Y%m%d"),
"order_id": order_no,
"order_amt": total,
"page_notify_url": self.page_notify_url,
"back_notify_url": self.notify_url,
"ver": "4.0.0",
"goods_name": "云学堂年费",
"goods_detail": description,
"fee_type": "CNY",
}
pub_key_location = 'pub_key.pem'
# pub_key_location = 'E:\YinJian\银建支付对接维护说明\技培\jp-enterprise-wechat-payment-push\pub_key.pem'
print("======================发起支付====================",param)
# 加密
message = json.dumps(param)
encrypted_message = rsa_long_encrypt(pub_key_location,message,100)
return json.dumps({"message": encrypted_message})