@@ -7,6 +7,7 @@ from logit import logit |
||
7 | 7 |
from paginator import pagination |
8 | 8 |
from pywe_exception import WeChatPayException |
9 | 9 |
from pywe_pay import WeChatPay |
10 |
+from pywe_pay_notify import check_pay_notify |
|
10 | 11 |
from pywe_response import WXPAY_NOTIFY_FAIL, WXPAY_NOTIFY_SUCCESS |
11 | 12 |
from pywe_sign import check_signature |
12 | 13 |
from pywe_xml import xml_to_dict |
@@ -208,7 +209,7 @@ def wx_order_query_api(request): |
||
208 | 209 |
# 订单查询 |
209 | 210 |
query_data = wxpay.order.query(transaction_id, order_id) |
210 | 211 |
# 签名校验 |
211 |
- if not check_signature(query_data): |
|
212 |
+ if not check_signature(query_data, wechat.get('apiKey')): |
|
212 | 213 |
return response(OrderStatusCode.SIGN_CHECK_FAIL) |
213 | 214 |
|
214 | 215 |
# 交易状态 |
@@ -266,19 +267,8 @@ def wx_order_detail_api(request): |
||
266 | 267 |
@transaction.atomic |
267 | 268 |
def wx_notify_url_api(request): |
268 | 269 |
""" 支付异步通知回调地址 """ |
269 |
- data = xml_to_dict(request.body) |
|
270 |
- if isinstance(data, basestring): |
|
271 |
- return HttpResponse(WXPAY_NOTIFY_FAIL) |
|
272 |
- |
|
273 |
- trade_type = data.get('trade_type', '') |
|
274 |
- |
|
275 |
- # 签名校验 |
|
276 |
- if not check_signature(data, settings.WECHAT.get(trade_type, {}).get('apiKey')): |
|
277 |
- return HttpResponse(WXPAY_NOTIFY_FAIL) |
|
278 |
- |
|
279 |
- # 通信标识 |
|
280 |
- return_code = data.get('return_code', '') |
|
281 |
- if return_code != 'SUCCESS': |
|
270 |
+ data, success = check_pay_notify(request.body, wx_configs=settings.WECHAT) |
|
271 |
+ if not success: |
|
282 | 272 |
return HttpResponse(WXPAY_NOTIFY_FAIL) |
283 | 273 |
|
284 | 274 |
out_trade_no = data.get('out_trade_no', '') |
@@ -30,6 +30,7 @@ pywe-jssdk==1.0.2 |
||
30 | 30 |
pywe-miniapp==1.0.0 |
31 | 31 |
pywe-oauth==1.0.3 |
32 | 32 |
pywe-pay==1.0.5 |
33 |
+pywe-pay-notify==1.0.1 |
|
33 | 34 |
pywe-response==1.0.1 |
34 | 35 |
pywe-sign==1.0.5 |
35 | 36 |
pywe-xml==1.0.0 |