How to use get_request_payment method in localstack

Best Python code snippet using localstack_python

wx_pay.py

Source:wx_pay.py Github

copy

Full Screen

...94 for i in range(0,32) :95 pwd += chars[int((math.floor(random.random() * maxPos)))]96 return pwd97 #获取预支付交易会话标识98 def get_request_payment(self):99 _wx_url = "https://api.mch.weixin.qq.com/pay/unifiedorder"100 # print data101 opener = urllib2.build_opener()102 request = urllib2.Request(103 url = _wx_url,104 headers = {'Content-Type' : 'application/xml','charset':'UTF-8'},105 data = self.data)106 f=opener.open(request)107 # print f.read().decode('utf-8')108 xh = XMLHandler()109 # xml.sax.parseString( f.read().decode('utf-8'), xh)110 xml.sax.parseString( f.read(), xh)111 ret = xh.getDict()112 print ret113 # print ret['err_code_des']114 # print ret['xml']115 # print ret['err_code']116 # print ret['prepay_id']117 # print ret['nonce_str']118 self.timeStamp = str( int(round( time.time() * 1000)) )119 self.package = 'prepay_id=' + ret['prepay_id']120 # self.nonceStr = ret['nonce_str']121 self.nonceStr = self.randomString()122 pmStr = "appId="+ self.APP_ID +"&nonceStr=" + self.nonceStr + "&package=prepay_id=" + ret['prepay_id'] + "&signType=MD5&timeStamp=" + self.timeStamp + "&key=283fc3d9d4b8ba3b58601145466d4417"123 self.paySign = self.md5(pmStr)124 # self.paySign = paySign125 return {126 'timeStamp': self.timeStamp,127 'nonceStr': self.nonceStr,128 'package': self.package,129 'paySign': self.paySign,130 }131 # WxHttp(data)132if __name__ == "__main__":133 # from api.models.user import *134 # from api.models.order import *135 #136 # import django137 # django.setup()138 #139 #140 # session = 'XFTGjxhyrUpZTGyesAz/Lg=='141 # _user = User.objects.get( session = session)142 #143 # print _user144 # _order = Order.objects.get(user_id = _user.id,is_payment = IS_PAYMENT_FALSE) # AddMemberOrder145 #146 # #生成微信wx_out_trade_no147 # # 当前时间 + order_id + 随机数148 # # _order.wx_out_trade_no = str(datetime.datetime.now().strftime("%Y%m%d%H%M%S")) + str(_order.id) + str(int(random.random() * 1000))149 #150 # wx_out_trade_no = str(datetime.datetime.now().strftime("%Y%m%d%H%M%S")) + str(_order.id) + str(int(random.random() * 1000))151 # print wx_out_trade_no #2017091212253017904152 # print _order.payment_fee, type(_order.payment_fee)153 #154 # fee = str( int( _order.payment_fee * 100) )155 # _wx_pay = wx_pay( _user.wx_open_id , wx_out_trade_no , fee) # 每次重新生成order.wx_out_trade_no156 # _dict = _wx_pay.get_request_payment()157 # print _dict158 #TODO159 # 三个步骤160 # 1 server接收小程序的Member or Single ,创建订单 do161 # 2 订单返回小程序,支付 do162 # 3 支付notify_url异步成功通知server,订单生效 TODO163 # 4 小获得成功通知,做成功跳转(看文章 or 返回订单列表 TODO164 dom = '''<table style="border: 1px solid #e0e0e0;" border="1" width="507" cellspacing="0" cellpadding="0" align="center">165 <colgroup > <col width="72" /> <col width="116" /> <col width="102" /> <col span="2" width="72" /> <col width="89" /> <col width="86" /></colgroup>166<tbody >167<tr >168<td colspan="7" width="609" height="45">1.报价均以带票价格为主;标准为:02普级或优级食用酒精;报价地区为原料主产区即酒精价格主导区。如玉米酒精以东北、华北为主;木薯酒精以两广、云南、华东为主;糖蜜酒精以两广、云南为主。</td>169</tr>170<tr>...

Full Screen

Full Screen

hx_order.py

Source:hx_order.py Github

copy

Full Screen

...95 _user = user96 _order = order97 _fee = str( int(_order.payment_fee *100) ) #把圆换算为分,并用整数表示98 _wx_pay = wx_pay( _user.wx_open_id , _order.wx_out_trade_no ,_fee , SETTINGS.PAY_CALLBACK_URL)99 _dict = _wx_pay.get_request_payment()100 return _dict101 # 续费支付二维码信息102 def PayRenewWX(self,user,order):103 _user = user104 _order = order105 _fee = str( int(_order.payment_fee *100) ) #把圆换算为分,并用整数表示106 _wx_pay = wx_pay( _user.wx_open_id , _order.wx_out_trade_no ,_fee , SETTINGS.PAY_RENEW_CALLBACK_URL)107 _dict = _wx_pay.get_request_payment()108 return _dict109 # 4-3 微信支付回调110 # 更改数据库为支付成功111 def PayWXCallback(self,_xml):112 xh = XMLHandler()113 xml.sax.parseString( _xml, xh)114 _xml_dict = xh.getDict()115 _out_trade_no = _xml_dict["out_trade_no"]116 _total_fee = _xml_dict["total_fee"]117 #返回结果118 _xml_resualt = '''119 <xml>120 <return_code><![CDATA[%s]]></return_code>121 <return_msg><![CDATA[%s]]></return_msg>...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful