def set_params(self, **kwargs): self.params = {} for (k, v) in kwargs.items(): self.params[k] = smart_str(v) self.params['nonce_str'] = random_str(length=32) self.params.update(self.common_params)
def post(self, body, out_trade_no, total_fee, spbill_create_ip, notify_url, open_id, url): # 直接调用基类的post方法查询prepay_id,如果成功,返回一个字典 unified_order = super(JsAPIOrderPay, self)._post(body, out_trade_no, total_fee, spbill_create_ip, notify_url, open_id=open_id) nonce_str = random_str(length=32) time_stamp = time.time() pay_params = { 'appId': self.app_id, 'timeStamp': '%d' % time_stamp, 'nonceStr': nonce_str, 'package': 'prepay_id=%s' % unified_order.get('prepay_id'), 'signType': 'MD5' } pay_params['paySign'] = sign_url(pay_params, self.api_key, key_name='key', upper_case=True) unified_order.update({ 'pay_params': pay_params, 'config_params': get_js_config_params(url, nonce_str, time_stamp) }) return unified_order
def post(self, body, out_trade_no, total_fee, spbill_create_ip, notify_url, open_id, url): # 直接调用基类的post方法查询prepay_id,如果成功,返回一个字典 unified_order = super(JsAPIOrderPay, self)._post(body, out_trade_no, total_fee, spbill_create_ip, notify_url, open_id=open_id) nonce_str = random_str(length=32) time_stamp = time.time() pay_params = {'appId': self.app_id, 'timeStamp': '%d' % time_stamp, 'nonceStr': nonce_str, 'package': 'prepay_id=%s' % unified_order.get('prepay_id'), 'signType': 'MD5'} pay_params['paySign'] = sign_url( pay_params, self.api_key, key_name='key', upper_case=True) unified_order.update({'pay_params': pay_params, 'config_params': get_js_config_params(url, nonce_str, time_stamp)}) return unified_order