This commit is contained in:
doudou201703
2026-09-19 11:51:34 +08:00
parent dd4383130d
commit 922583becb
15 changed files with 223 additions and 124 deletions
@@ -42,7 +42,7 @@ class sixWechatPay六果泡泡支付(BaseModel):
# ---------- 商户API密钥对(用于签名请求) ----------
merchant_private_key_pem: str = Field(default=Path(settings.BASE_DIR).joinpath("wechat_微信支付证书/江苏六果科技有限公司支付证书/apiclient_key.pem").read_text(), alias="商户私钥PEM", description="apiclient_key.pem 内容")
merchant_public_key_pem: str = Field(default=Path(settings.BASE_DIR).joinpath("wechat_微信支付证书/江苏六果科技有限公司支付证书/微信支付公钥.pem").read_text(), alias="商户公钥PEM", description="apiclient_cert.pem 内容(很少用到)")
merchant_public_key_pem: str = Field(default=Path(settings.BASE_DIR).joinpath("wechat_微信支付证书/江苏六果科技有限公司支付证书/apiclient_cert.pem").read_text(), alias="商户公钥PEM", description="apiclient_cert.pem 内容(很少用到)")
# ---------- 微信支付公钥(用于验签和加密敏感字段) ----------
wechatpay_public_key_id: str = Field(default="PUB_KEY_ID_0117003834192026080500181856002000", alias="微信支付公钥ID")
@@ -126,7 +126,7 @@ class sixWechatPay六果泡泡支付(BaseModel):
print(e, "捕获了签名串验证不通过的错误") # 签名验证失败
raise "捕获了签名串验证不通过的错误"
def gouzhao构造签名串(self, ):
def getHeaders构造签名串(self, ):
"""注释"""
url_data = re.search(r'/v3.*', string=self.pay_uri).group()
utc_unix_timestamp = int(datetime.now(tz=ZoneInfo("utc")).timestamp())
@@ -256,15 +256,14 @@ class sixWechatPay六果泡泡支付(BaseModel):
associated_data = pydash.get(obj=response_body, path="resource.associated_data", default=None)
nonce = pydash.get(obj=response_body, path="resource.nonce", default=None)
wei_xin_zhi_fu_hui_diao_data = self.modegmc解密(
nonce=nonce, ciphertext=ciphertext,
associated_data=associated_data,
nonce=nonce, ciphertext=ciphertext, associated_data=associated_data,
)
return wei_xin_zhi_fu_hui_diao_data
def getpay_navite发起二维码支付(self, ):
""" 二维码支付,可以适用于 网站 的用户扫码支付 """
headers = self.gouzhao构造签名串()
response = requests.post(url=self.pay_uri, headers=headers, json=self.pay_请求体)
# headers = self.getHeaders构造签名串()
response = requests.post(url=self.pay_uri, headers=self.pay_Headers, json=self.pay_请求体)
生成的支付链接 = response.json()
return 生成的支付链接
@@ -313,10 +312,15 @@ class sixWechatPay六果泡泡支付(BaseModel):
def 发起退款(self, ):
pass
uri = f"https://api.mch.weixin.qq.com/v3/refund/domestic/refunds"
heardes = self.gouzhao构造签名串()
heardes = self.getHeaders构造签名串()
print(heardes)
response_data = requests.post(url=self.pay_uri, json=self.pay_请求体, headers=heardes)
print(response_data.json())
def getpay_发起提现(self):
pass
response: Response = requests.post(url=self.pay_uri, json=self.pay_请求体, headers=self.pay_Headers)
return response.json()
if __name__ == "__main__":