fix: 支付宝充值回调地址写死到 settings,沿用原有密钥配置
不再要求改 app_secrets;NOTIFY_URL_CZJILU 缺省或误配成订单回调时自动用 /shangpin/alipay-czjilu-notify/。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -33,9 +33,12 @@ def get_alipay_config(club_id=None):
|
||||
else:
|
||||
cfg = getattr(settings, 'ALIPAY_PROD', {})
|
||||
|
||||
# 注意:NOTIFY_URL_CZJILU 不得静默回落到订单 NOTIFY_URL,否则充值回调会打进订单回调被吞掉
|
||||
# 充值回调优先读 secrets;空则用 settings 默认地址(绝不回落到订单 NOTIFY_URL)
|
||||
czjilu_notify = (cfg.get('NOTIFY_URL_CZJILU') or '').strip()
|
||||
order_notify = (cfg.get('NOTIFY_URL') or '').strip()
|
||||
default_czjilu = (getattr(settings, 'ALIPAY_CZJILU_NOTIFY_URL', '') or '').strip()
|
||||
if not czjilu_notify or (order_notify and czjilu_notify.rstrip('/') == order_notify.rstrip('/')):
|
||||
czjilu_notify = default_czjilu
|
||||
return {
|
||||
'APP_ID': cfg.get('APP_ID', ''),
|
||||
'PID': cfg.get('PID', ''),
|
||||
@@ -50,25 +53,17 @@ def get_alipay_config(club_id=None):
|
||||
|
||||
|
||||
def get_czjilu_notify_url(club_id=None):
|
||||
"""获取 Czjilu 类充值的支付宝异步回调地址;未单独配置则抛错,禁止回落到订单回调。"""
|
||||
"""获取 Czjilu 充值回调地址:secrets 可选覆盖,否则用 settings 写死的正确地址。
|
||||
|
||||
密钥/APP_ID 仍用原有 ALIPAY_PROD,不必再配新密钥。
|
||||
禁止回落到订单 NOTIFY_URL,避免充值通知被订单回调吞掉。
|
||||
"""
|
||||
cfg = get_alipay_config(club_id)
|
||||
notify_url = (cfg.get('NOTIFY_URL_CZJILU') or '').strip()
|
||||
if not notify_url:
|
||||
raise Exception(
|
||||
'支付宝配置缺少 NOTIFY_URL_CZJILU(须指向 /shangpin/alipay-czjilu-notify/),'
|
||||
'禁止使用订单回调地址,否则充值到账会失败'
|
||||
)
|
||||
order_notify = (cfg.get('NOTIFY_URL') or '').strip()
|
||||
if order_notify and notify_url.rstrip('/') == order_notify.rstrip('/'):
|
||||
raise Exception(
|
||||
'NOTIFY_URL_CZJILU 不能与订单 NOTIFY_URL 相同,'
|
||||
'请配置为 .../shangpin/alipay-czjilu-notify/'
|
||||
)
|
||||
if 'alipay-czjilu-notify' not in notify_url:
|
||||
logger.warning(
|
||||
'NOTIFY_URL_CZJILU=%s 未包含 alipay-czjilu-notify,请确认是否配错',
|
||||
notify_url,
|
||||
)
|
||||
notify_url = (getattr(settings, 'ALIPAY_CZJILU_NOTIFY_URL', '') or '').strip()
|
||||
if not notify_url:
|
||||
raise Exception('缺少支付宝充值回调地址 ALIPAY_CZJILU_NOTIFY_URL')
|
||||
return notify_url
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user