Update transaction_id/notify_msg for wx_order_query_api

Brightcells %!s(int64=7) %!d(string=hace) años
padre
commit
7eaff4171b
Se han modificado 1 ficheros con 7 adiciones y 3 borrados
  1. 7 3
      pay/views.py

+ 7 - 3
pay/views.py

@@ -207,13 +207,17 @@ def wx_order_query_api(request):
207 207
     wxpay = WeChatPay(wechat.get('appID'), wechat.get('apiKey'), wechat.get('mchID'))
208 208
 
209 209
     # 订单查询
210
-    query_data = wxpay.order.query(transaction_id, order_id)
210
+    data = wxpay.order.query(transaction_id, order_id)
211 211
     # 签名校验
212
-    if not check_signature(query_data, wechat.get('apiKey')):
212
+    if not check_signature(data, wechat.get('apiKey')):
213 213
         return response(OrderStatusCode.SIGN_CHECK_FAIL)
214 214
 
215
+    order.notify_msg = data
216
+    order.transaction_id = data.get('transaction_id', '')
217
+    order.save()
218
+
215 219
     # 交易状态
216
-    trade_state = query_data.get('trade_state')
220
+    trade_state = data.get('trade_state')
217 221
     # 订单状态判断更新
218 222
     if trade_state == 'SUCCESS':  # 订单支付成功
219 223
         order_paid_success(order)