|
@@ -214,11 +214,11 @@ class WechatPayObject:
|
|
|
'refund_fee': refund_fee # 退款金额
|
|
|
}
|
|
|
# doc: https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=4_3
|
|
|
- string_sign = "&".join([f"{k}={params[k]}" for k in sorted(params)] + [f"{'key'}={self.APIKEY}"])
|
|
|
+ string_sign = "&".join(['{}={}'.format(k, params[k]) for k in sorted(params)] + ['key={}'.format(self.APIKEY)])
|
|
|
params['sign'] = hashlib.md5(string_sign.encode('utf8')).hexdigest().upper() # MD5签名
|
|
|
xml = "<xml>{}</xml>".format("".join([f"<{k}>{v}</{k}>" for k, v in params.items()])) # 数据拼接成xml格式
|
|
|
- cert = f"{BASE_DIR}/Ansjer/file/wechatpay/apiclient_cert.pem"
|
|
|
- key = f"{BASE_DIR}/Ansjer/file/wechatpay/apiclient_key.pem"
|
|
|
+ cert = '{}/Ansjer/file/wechatpay/apiclient_cert.pem'.format(BASE_DIR)
|
|
|
+ key = '{}/Ansjer/file/wechatpay/apiclient_key.pem'.format(BASE_DIR)
|
|
|
r = requests.post(url=self.refund_url, headers={'Content-Type': 'text/xml'}, data=xml.encode('utf-8'),
|
|
|
cert=(cert, key), verify=True)
|
|
|
response = xmltodict.parse(r.text)
|