def get_public_wechat_h5(amount): clientip = request.headers.get('X-Real-IP') or request.remote_addr pay_type = PAY_TYPE.WECHAT_H5 amount = Decimal(amount) / 100 appid = '100000' try: pay_record = create_pay_record(int(time.time() * 1000), '', appid, pay_type, amount, '') except Exception as e: return {'status': -1, 'error': 'Duplicate order id'} result = guangda.wechat_h5_pay(pay_record, u'体验支付', clientip) result['orderid'] = str(pay_record.id) url = result['url'] return """ <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <a href="%s">点击这里跳转完成支付</a> </body> </html> """ % url
def test_wechat_h5(): """ 微信扫码付转H5测试 """ pay_type = PAY_TYPE.WECHAT_QR amount = Decimal(1) appid = '100000' try: pay_record = create_pay_record(int(time.time() * 1000), '', appid, pay_type, amount, '') except IntegrityErrors: return {'status': -1, 'error': 'Duplicate order id'} result = guangda.qr_pay(pay_record) return redirect(result['qrCode'])
def get_public_wechat_qr(amount=0): if not amount: amount = Decimal(randint(1, 3)) pay_type = PAY_TYPE.WECHAT_QR appid = '100001' try: pay_record = create_pay_record(int(time.time() * 1000), '', appid, pay_type, amount, '') except IntegrityErrors: raise err.DuplicateOrderID(u"订单号重复") result = keda.qr_pay(pay_record, order_info=u'体验支付') result['orderid'] = str(pay_record.id) result['amount'] = str(amount) return result
def get_public_alipay_qr(): amount = request.args.get('amount') _type = request.args.get('type') if amount: amount = Decimal(amount) / 100 else: amount = Decimal(randint(1, 3)) pay_type = PAY_TYPE.ALIPAY_QR appid = '100002' try: pay_record = create_pay_record(int(time.time() * 1000), '', appid, pay_type, amount, '') except IntegrityErrors: return {'status': -1, 'error': 'Duplicate order id'} result = keda.qr_pay(pay_record, order_info=u'体验支付') result['orderid'] = str(pay_record.id) result['amount'] = str(amount) if _type == 'h5': return redirect(result['qrCode']) return result
raise err.AppIDWrong() if not appid_detail.valid: raise err.AppidInvalid() orderid = query_dct['orderid'] amount = Decimal(query_dct['amount']) if not check_payamount(amount): raise err.ParamError('amount should not be divided by 10') notify_url = query_dct['notifyUrl'] ordername = query_dct.get('subject') clientip = query_dct.get('clientip') order_info = query_dct.get('orderInfo') return_url = query_dct.get('returnUrl') description = query_dct.get('description') try: pay_record = create_pay_record(orderid, appid_detail.accountid, appid, pay_type, amount, notify_url, description) except IntegrityErrors: raise err.DuplicateOrderID() except Exception as e: _LOGGER.exception('db error') raise err.SystemError() finally: orm.session.rollback() pay_handler = _PAY_HANDLER[appid_detail.real_pay] # 支付宝扫码付线下要一元以上 if pay_type == PAY_TYPE.ALIPAY_QR and amount < Decimal('1'): raise err.MiniAmount() if pay_type == PAY_TYPE.WECHAT_H5: result = pay_handler.wechat_h5_pay(pay_record, ordername, clientip)