Exemple #1
0
def pay91_request(request):
    '''
    91pay请求逻辑
    '''
    try:
        data = request.POST
        context = {}
        # 获取金额数量
        amount = data['paynum']
        type = data['type']
        # 生成订单号
        pay_id = settings.ID_91PAY + '@' + settings.USER_91PAY + '@' + datetime.datetime.fromtimestamp(
            time.time()).strftime('%Y%m%d%H%M%S%s')
        res = pay91.pay_request(type, amount, pay_id)
        request.session['pay_id'] = pay_id
        # 记录申请记录
        record = PayRequest.objects.create(username=request.user.username,
                                           info_code=res['trade_no'],
                                           amount=amount, type=res['type'])
        # 获取二维码链接
        context['qrcode'] = res['qrcode']
        info = {
            'title': '请求成功!',
            'subtitle': '描下方二维码付款,付款完成记得按确认哟!',
            'status': 'success', }
        context['info'] = info
    except:
        info = {
            'title': '糟糕,当面付插件可能出现问题了',
            'subtitle': '如果一直失败,请后台联系站长',
            'status': 'error', }
        context['info'] = info
    result = json.dumps(context, ensure_ascii=False)
    return HttpResponse(result, content_type='application/json')
Exemple #2
0
def pay91_request(request):
    '''
    91pay请求逻辑
    '''
    try:
        data = request.POST
        context = {}
        # 获取金额数量
        amount = data['paynum']
        type = data['type']
        # 生成订单号
        pay_id = settings.ID_91PAY + '@' + settings.USER_91PAY + '@' + datetime.datetime.fromtimestamp(
            time.time()).strftime('%Y%m%d%H%M%S%s')
        res = pay91.pay_request(type, amount, pay_id)
        request.session['pay_id'] = pay_id
        # 记录申请记录
        record = PayRequest.objects.create(username=request.user.username,
                                           info_code=res['trade_no'],
                                           amount=amount, type=res['type'])
        # 获取二维码链接
        context['qrcode'] = res['qrcode']
        info = {
            'title': '请求成功!',
            'subtitle': '描下方二维码付款,付款完成记得按确认哟!',
            'status': 'success', }
        context['info'] = info
    except:
        info = {
            'title': '糟糕,当面付插件可能出现问题了',
            'subtitle': '如果一直失败,请后台联系站长',
            'status': 'error', }
        context['info'] = info
    return JsonResponse(context)