MCPcopy Create free account
hub / github.com/ImSingee/PayJS / micropay

Method micropay

payjs/base.py:328–364  ·  view source on GitHub ↗

发起刷卡支付 :param total_fee: 支付金额,单位为分,介于 1 - 1000000 之间 :param out_trade_no: 订单号,应保证唯一性,1-32 字符 :param auth_code: 刷卡支付授权码,设备读取用户微信中的条码或者二维码信息,18 位纯数字,以 10、11、12、13、14、15 开头 :param body: (可选)订单标题,0 - 32 字符 :return:

(self, total_fee: int, out_trade_no, auth_code, body: str = '')

Source from the content-addressed store, hash-verified

326 return ret
327
328 def micropay(self, total_fee: int, out_trade_no, auth_code, body: str = ''):
329 """
330 发起刷卡支付
331 :param total_fee: 支付金额,单位为分,介于 1 - 1000000 之间
332 :param out_trade_no: 订单号,应保证唯一性,1-32 字符
333 :param auth_code: 刷卡支付授权码,设备读取用户微信中的条码或者二维码信息,18 位纯数字,以 10、11、12、13、14、15 开头
334 :param body: (可选)订单标题,0 - 32 字符
335 :return:
336 """
337 url = r'https://payjs.cn/api/micropay'
338
339 if not total_fee > 0:
340 raise InvalidInfoException(-2004, "金额必须为正整数(单位为分)")
341
342 out_trade_no = str(out_trade_no)
343
344 if not out_trade_no:
345 logger.warning("用户端订单号不可省略")
346 if not len(out_trade_no) <= 32:
347 logger.warning("用户端订单号最多为 32 位")
348
349 if not len(body) <= 32:
350 logger.warning("标题最多为 32 位")
351
352 if not str(auth_code).isdigit() or not len(str(auth_code)) == 18:
353 logger.warning("刷卡支付授权码应为 18 位纯数字")
354
355 data = {
356 'mchid': self.mchid,
357 'total_fee': total_fee,
358 'out_trade_no': out_trade_no,
359 'body': body,
360 'auth_code': auth_code,
361 }
362
363 ret = self.request(url, data)
364 return ret
365
366 def close(self, payjs_order_id=None):
367 """

Callers

nothing calls this directly

Calls 2

requestMethod · 0.95

Tested by

no test coverage detected