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

Method native

payjs/base.py:134–174  ·  view source on GitHub ↗

发起扫码支付 :param total_fee: 支付金额,单位为分,介于 1 - 1000000 之间 :param out_trade_no: 订单号,应保证唯一性,1-32 字符 :param body: (可选)订单标题,0 - 32 字符 :param notify_url: (可选)回调地址,留空使用默认,传入空字符串代表无需回调 :param attach: (可选)用户自定义数据,在notify的时候会原样返回 :return:

(self, total_fee: int, out_trade_no, body: str = '', notify_url=None, attach=None)

Source from the content-addressed store, hash-verified

132 return self.check_status_by_payjs_order_id(payjs_order_id)
133
134 def native(self, total_fee: int, out_trade_no, body: str = '', notify_url=None, attach=None):
135 """
136 发起扫码支付
137 :param total_fee: 支付金额,单位为分,介于 1 - 1000000 之间
138 :param out_trade_no: 订单号,应保证唯一性,1-32 字符
139 :param body: (可选)订单标题,0 - 32 字符
140 :param notify_url: (可选)回调地址,留空使用默认,传入空字符串代表无需回调
141 :param attach: (可选)用户自定义数据,在notify的时候会原样返回
142 :return:
143 """
144 url = r'https://payjs.cn/api/native'
145
146 if not total_fee > 0:
147 raise InvalidInfoException(-2004, "金额必须为正整数(单位为分)")
148
149 out_trade_no = str(out_trade_no)
150
151 if not out_trade_no:
152 logger.warning("用户端订单号不可省略")
153 if not len(out_trade_no) <= 32:
154 logger.warning("用户端订单号最多为 32 位")
155
156 if not len(body) <= 32:
157 logger.warning("标题最多为 32 位")
158
159 if notify_url is None:
160 notify_url = self.notify_url
161 if not check_url(notify_url, force_ssl=self.FORCE_SSL):
162 raise InvalidInfoException(-2003, '通知回调地址有误')
163
164 data = {
165 'mchid': self.mchid,
166 'total_fee': total_fee,
167 'out_trade_no': out_trade_no,
168 'body': body,
169 'notify_url': notify_url,
170 'attach': attach,
171 }
172
173 ret = self.request(url, data)
174 return ret
175
176 def cashier(self, total_fee: int, out_trade_no, body: str = '', notify_url=None, callback_url=None, attach=None):
177 """

Callers

nothing calls this directly

Calls 3

requestMethod · 0.95
check_urlFunction · 0.90

Tested by

no test coverage detected