feat: 接入微信 Native 扫码支付(复用原回调与履约)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
2643321801
commit
486c050c00
11 files changed
+329
-23
No files matched your search
+24
-2
@@ -909,7 +909,7 @@ class CreateOrderView(APIView):
|
||||
laoban_yonghuid = getattr(current_user, 'UserUID', '') or getattr(current_user, 'yonghuid', '')
|
||||
user_openid, club_id = get_payment_openid(request, current_user, club_id)
|
||||
|
||||
# 支付宝支付不需要 openid
|
||||
# JSAPI 需要 openid;支付宝 / 微信 Native 扫码不需要
|
||||
if pay_method == 'wechat' and not user_openid:
|
||||
return Response({'code': 10, 'msg': '用户openid不存在', 'data': None})
|
||||
|
||||
@@ -995,6 +995,17 @@ class CreateOrderView(APIView):
|
||||
subject=getattr(settings, 'WEIXIN_PAY_DESCRIPTION', '星阙订单'),
|
||||
club_id=club_id,
|
||||
)
|
||||
elif pay_method == 'wechat_native':
|
||||
from jituan.services.wechat_native_pay import generate_wechat_native_pay_params
|
||||
pay_params = generate_wechat_native_pay_params(
|
||||
dingdanid=dingdanid,
|
||||
jine=shangpin_jiage,
|
||||
body=getattr(settings, 'WEIXIN_PAY_DESCRIPTION', '星阙订单'),
|
||||
notify_url=settings.WEIXIN_NOTIFY_URL,
|
||||
club_id=club_id,
|
||||
client_ip=self.get_client_ip(request),
|
||||
scene='order',
|
||||
)
|
||||
else:
|
||||
from jituan.services.club_user import get_pay_app_source
|
||||
pay_params = self.generate_wechat_pay_params(
|
||||
@@ -1239,7 +1250,7 @@ class ContinuePayView(APIView):
|
||||
pay_method = (request.data.get('pay_method') or 'wechat').strip().lower()
|
||||
if not dingdanid:
|
||||
return Response({'code': 1, 'msg': '订单ID不能为空', 'data': None})
|
||||
if pay_method not in ('wechat', 'alipay'):
|
||||
if pay_method not in ('wechat', 'alipay', 'wechat_native'):
|
||||
return Response({'code': 1, 'msg': '不支持的支付方式', 'data': None})
|
||||
|
||||
current_user = request.user
|
||||
@@ -1321,6 +1332,17 @@ class ContinuePayView(APIView):
|
||||
subject=subject,
|
||||
club_id=club_id,
|
||||
)
|
||||
elif pay_method == 'wechat_native':
|
||||
from jituan.services.wechat_native_pay import generate_wechat_native_pay_params
|
||||
pay_params = generate_wechat_native_pay_params(
|
||||
dingdanid=dingdanid,
|
||||
jine=jine,
|
||||
body=subject,
|
||||
notify_url=settings.WEIXIN_NOTIFY_URL,
|
||||
club_id=club_id,
|
||||
client_ip=helper.get_client_ip(request),
|
||||
scene='order_continue',
|
||||
)
|
||||
else:
|
||||
from jituan.services.club_user import get_pay_app_source
|
||||
pay_params = helper.generate_wechat_pay_params(
|
||||
|
||||
Reference in new issue
Block a user