@@ -65,15 +65,15 @@ def pay(self,
65
65
if description :
66
66
params .update ({'description' : description })
67
67
else :
68
- raise WeChatPayException ('description is not assigned.' )
68
+ raise Exception ('description is not assigned.' )
69
69
if out_trade_no :
70
70
params .update ({'out_trade_no' : out_trade_no })
71
71
else :
72
- raise WeChatPayException ('out_trade_no is not assigned.' )
72
+ raise Exception ('out_trade_no is not assigned.' )
73
73
if amount :
74
74
params .update ({'amount' : amount })
75
75
else :
76
- raise WeChatPayException ('amount is not assigned.' )
76
+ raise Exception ('amount is not assigned.' )
77
77
if payer :
78
78
params .update ({'payer' : payer })
79
79
if scene_info :
@@ -90,37 +90,37 @@ def pay(self,
90
90
params .update ({'settle_info' : settle_info })
91
91
if self ._type in [WeChatPayType .JSAPI , WeChatPayType .MINIPROG ]:
92
92
if not payer :
93
- raise WeChatPayException ('payer is not assigned' )
93
+ raise Exception ('payer is not assigned' )
94
94
path = '/v3/pay/transactions/jsapi'
95
95
elif self ._type == WeChatPayType .APP :
96
96
path = '/v3/pay/transactions/app'
97
97
elif self ._type == WeChatPayType .H5 :
98
98
if not scene_info :
99
- raise WeChatPayException ('scene_info is not assigned.' )
99
+ raise Exception ('scene_info is not assigned.' )
100
100
path = '/v3/pay/transactions/h5'
101
101
elif self ._type == WeChatPayType .NATIVE :
102
102
path = '/v3/pay/transactions/native'
103
- return self ._core .post (path , json = json . dumps ( params ) )
103
+ return self ._core .post (path , data = params )
104
104
105
105
def close (self , out_trade_no ):
106
106
"""关闭订单
107
107
:param out_trade_no: 商户订单号,示例值:'1217752501201407033233368018'
108
108
"""
109
109
if not out_trade_no :
110
- raise WeChatPayException ('out_trade_no is not assigned.' )
110
+ raise Exception ('out_trade_no is not assigned.' )
111
111
path = '/v3/pay/transactions/out-trade-no/%s/close' % out_trade_no
112
112
params = {}
113
113
params ['mchid' ] = self ._mchid
114
114
params ['out_trade_no' ] = out_trade_no
115
- return self ._core .post (path , json = json . dumps ( params ) )
115
+ return self ._core .post (path , data = params )
116
116
117
117
def query (self , transaction_id = None , out_trade_no = None ):
118
118
"""查询订单
119
119
:param transaction_id: 微信支付订单号,示例值:1217752501201407033233368018
120
120
:param out_trade_no: 商户订单号,示例值:1217752501201407033233368018
121
121
"""
122
122
if not (transaction_id or out_trade_no ):
123
- raise WeChatPayException ('params is not assigned' )
123
+ raise Exception ('params is not assigned' )
124
124
if transaction_id :
125
125
path = '/v3/pay/transactions/id/%s' % transaction_id
126
126
else :
@@ -152,11 +152,11 @@ def refund(self,
152
152
if out_refund_no :
153
153
params .update ({'out_refund_no' : out_refund_no })
154
154
else :
155
- raise WeChatPayException ('out_refund_no is not assigned.' )
155
+ raise Exception ('out_refund_no is not assigned.' )
156
156
if amount :
157
157
params .update ({'amount' : amount })
158
158
else :
159
- raise WeChatPayException ('amount is not assigned.' )
159
+ raise Exception ('amount is not assigned.' )
160
160
if transaction_id :
161
161
params .update ({'transation_id' : transaction_id })
162
162
if out_trade_no :
@@ -168,7 +168,7 @@ def refund(self,
168
168
if goods_detail :
169
169
params .update ({'goods_detail' : goods_detail })
170
170
path = '/v3/refund/domestic/refunds'
171
- return self ._core .post (path , json = json . dumps ( params ) )
171
+ return self ._core .post (path , data = params )
172
172
173
173
def query_refund (self , out_refund_no ):
174
174
"""查询单笔退款
@@ -239,11 +239,11 @@ def combine_pay(self,
239
239
if combine_out_trade_no :
240
240
params .update ({'combine_out_trade_no' : combine_out_trade_no })
241
241
else :
242
- raise WeChatPayException ('combine_out_trade_no is not assigned.' )
242
+ raise Exception ('combine_out_trade_no is not assigned.' )
243
243
if sub_orders :
244
244
params .update ({'sub_orders' : sub_orders })
245
245
else :
246
- raise WeChatPayException ('sub_orders is not assigned.' )
246
+ raise Exception ('sub_orders is not assigned.' )
247
247
if scene_info :
248
248
params .update ({'scene_info' : scene_info })
249
249
if combine_payer_info :
@@ -254,25 +254,25 @@ def combine_pay(self,
254
254
params .update ({'time_expire' : time_expire })
255
255
if self ._type in [WeChatPayType .JSAPI , WeChatPayType .MINIPROG ]:
256
256
if not combine_payer_info :
257
- raise WeChatPayException ('combine_payer_info is not assigned' )
257
+ raise Exception ('combine_payer_info is not assigned' )
258
258
path = '/v3/combine-transactions/jsapi'
259
259
elif self ._type == WeChatPayType .APP :
260
260
path = '/v3/combine-transactions/app'
261
261
elif self ._type == WeChatPayType .H5 :
262
262
if not scene_info :
263
- raise WeChatPayException ('scene_info is not assigned.' )
263
+ raise Exception ('scene_info is not assigned.' )
264
264
path = '/v3/combine-transactions/h5'
265
265
elif self ._type == WeChatPayType .NATIVE :
266
266
path = '/v3/combine-transactions/native'
267
- return self ._core .post (path , json = json . dumps ( params ) )
267
+ return self ._core .post (path , data = params )
268
268
269
269
def combine_query (self , combine_out_trade_no ):
270
270
"""合单查询订单
271
271
:param combine_out_trade_no: 合单商户订单号,示例值:P20150806125346
272
272
"""
273
273
params = {}
274
274
if not combine_out_trade_no :
275
- raise WeChatPayException ('param combine_out_trade_no is not assigned' )
275
+ raise Exception ('param combine_out_trade_no is not assigned' )
276
276
else :
277
277
params .update ({'combine_out_trade_no' :combine_out_trade_no })
278
278
path = '/v3/combine-transactions/out-trade-no/%s' % combine_out_trade_no
@@ -288,21 +288,13 @@ def combine_close(self, combine_out_trade_no, sub_orders, combine_appid=None):
288
288
params ['combine_appid' ] = combine_appid or self ._appid
289
289
290
290
if not combine_out_trade_no :
291
- raise WeChatPayException ('combine_out_trade_no is not assigned.' )
291
+ raise Exception ('combine_out_trade_no is not assigned.' )
292
292
if not sub_orders :
293
- raise WeChatPayException ('sub_orders is not assigned.' )
293
+ raise Exception ('sub_orders is not assigned.' )
294
294
else :
295
295
params .update ({'sub_orders' : sub_orders })
296
296
path = '/v3/combine-transactions/out-trade-no/%s/close' % combine_out_trade_no
297
- return self ._core .post (path , json = json .dumps (params ))
298
-
299
- class WeChatPayException (Exception ):
300
- def __init__ (self , reason ):
301
- self ._reason = reason
302
-
303
- def __str__ (self ):
304
- return self ._reason
305
-
297
+ return self ._core .post (path , data = params )
306
298
307
299
class WeChatPayType (Enum ):
308
300
JSAPI = 0
0 commit comments