Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions wechatpayv3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# -*- coding: utf-8 -*-

try:
from importlib.metadata import version, PackageNotFoundError
except ImportError:
# 兼容 Python 3.7 以下版本
from importlib_metadata import version, PackageNotFoundError

try:
__version__ = version("wechatpayv3")
except PackageNotFoundError:
__version__ = "unknown"

from .type import SignType, WeChatPayType


Expand Down
3 changes: 2 additions & 1 deletion wechatpayv3/async_/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .utils import (aes_decrypt, build_authorization, hmac_sign, load_public_key,
load_certificate, load_private_key, rsa_decrypt,
rsa_encrypt, rsa_sign, rsa_verify, cryptography_version)
from .. import __version__


class AsyncCore:
Expand Down Expand Up @@ -199,7 +200,7 @@ async def request(self, path, method=RequestType.GET, data=None, skip_verify=Fal
else:
headers.update({'Content-Type': 'application/json'})
headers.update({'Accept': 'application/json'})
headers.update({'User-Agent': 'wechatpay python sdk v1.3.11(https://github.com/minibear2021/wechatpayv3)'})
headers.update({'User-Agent': f'wechatpay python sdk v{__version__}(https://github.com/minibear2021/wechatpayv3)'})
if self._public_key_id or cipher_data:
wechatpay_serial = self._public_key_id if self._public_key_id else hex(self._last_certificate().serial_number)[2:].upper()
headers.update({'Wechatpay-Serial': wechatpay_serial})
Expand Down
3 changes: 2 additions & 1 deletion wechatpayv3/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
load_certificate, load_private_key, rsa_decrypt,
rsa_encrypt, rsa_sign, rsa_verify, cryptography_version)

from . import __version__

class Core():
def __init__(self, mchid, cert_serial_no, private_key, apiv3_key, cert_dir=None, logger=None, proxy=None, timeout=None, public_key=None, public_key_id=None):
Expand Down Expand Up @@ -130,7 +131,7 @@ def request(self, path, method=RequestType.GET, data=None, skip_verify=False, si
else:
headers.update({'Content-Type': 'application/json'})
headers.update({'Accept': 'application/json'})
headers.update({'User-Agent': 'wechatpay python sdk v1.3.11(https://github.com/minibear2021/wechatpayv3)'})
headers.update({'User-Agent': f'wechatpay python sdk v{__version__}(https://github.com/minibear2021/wechatpayv3)'})
if self._public_key_id or cipher_data:
wechatpay_serial = self._public_key_id if self._public_key_id else hex(self._last_certificate().serial_number)[2:].upper()
headers.update({'Wechatpay-Serial': wechatpay_serial})
Expand Down