1
This commit is contained in:
@@ -142,7 +142,7 @@ _alipay_client = None
|
|||||||
_alipay_client_app_id = None
|
_alipay_client_app_id = None
|
||||||
|
|
||||||
|
|
||||||
def _get_alipay_client(app_id: str, private_key: str, public_key: str, gateway: str = ""):
|
def _get_alipay_client(app_id: str, private_key: str, public_key: str, gateway: str = "", notify_url: str = ""):
|
||||||
"""Get or create an Alipay client. Recreated if app_id changes."""
|
"""Get or create an Alipay client. Recreated if app_id changes."""
|
||||||
global _alipay_client, _alipay_client_app_id
|
global _alipay_client, _alipay_client_app_id
|
||||||
|
|
||||||
@@ -166,6 +166,8 @@ def _get_alipay_client(app_id: str, private_key: str, public_key: str, gateway:
|
|||||||
config.alipay_public_key = public_key
|
config.alipay_public_key = public_key
|
||||||
config.sign_type = "RSA2"
|
config.sign_type = "RSA2"
|
||||||
config.charset = "utf-8"
|
config.charset = "utf-8"
|
||||||
|
config.notify_url = notify_url
|
||||||
|
config.notify_type = "json"
|
||||||
# 先尝试使用 certifi 证书
|
# 先尝试使用 certifi 证书
|
||||||
config.ca_certificates = certifi.where()
|
config.ca_certificates = certifi.where()
|
||||||
|
|
||||||
@@ -305,12 +307,13 @@ def _create_alipay_order(order: PaymentOrder, db_configs: dict[str, str]) -> str
|
|||||||
private_key = db_configs.get("payment_alipay_private_key", "")
|
private_key = db_configs.get("payment_alipay_private_key", "")
|
||||||
public_key = db_configs.get("payment_alipay_public_key", "")
|
public_key = db_configs.get("payment_alipay_public_key", "")
|
||||||
gateway = db_configs.get("payment_alipay_gateway", "")
|
gateway = db_configs.get("payment_alipay_gateway", "")
|
||||||
|
notify_url = db_configs.get("payment_alipay_notify_url", "")
|
||||||
|
|
||||||
if not app_id or not private_key:
|
if not app_id or not private_key:
|
||||||
logger.warning("Alipay config missing in database (app_id / private_key)")
|
logger.warning("Alipay config missing in database (app_id / private_key)")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
client = _get_alipay_client(app_id, private_key, public_key, gateway)
|
client = _get_alipay_client(app_id, private_key, public_key, gateway, notify_url)
|
||||||
if client is None:
|
if client is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user