1.在微信支付后台配置apikey
1.微信支付商户接入文档地址:
https://pay.weixin.qq.com/wiki/doc/api/index.html
2.微信支付对接小程序的API文档地址:
https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_1
3.设置key:
1.key设置路径:微信商户平台(pay.weixin.qq.com)-->账户设置-->API安全-->密钥设置
2.输入32位数字和大小写字母的组合,设置为apikey(密钥)
在apps/utils目录下新建key.py:
STR = [chr(i) for i in range(65,91)] print(STR) #65-91对应字符A-Z #[\'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\', \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\', \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\', \'Y\', \'Z\'] str = [chr(i) for i in range(97,123)] print(str) #a-z #[\'a\', \'b\', \'c\', \'d\', \'e\', \'f\', \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\', \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\', \'w\', \'x\', \'y\', \'z\'] number = [chr(i) for i in range(48,58)] #0-9 print(number) #[\'0\', \'1\', \'2\', \'3\', \'4\', \'5\', \'6\', \'7\', \'8\', \'9\'] total=STR+str+number import random # 生成32位由数字和大小字母组成的随机字符串key key=\'\' for i in range(32): key+=random.choice(total) print(key)
请发表评论