示例#1
0
    hash = hmac.new(MERCHANT_KEY, s).hexdigest()
    if request.POST.get('HASH', '') != hash:
        flag = 'Invalid hash %s. Hash string \n%s' % (request.POST.get(
            'HASH', ''), s)
    else:
        if ipn.is_valid():
            try:
                #When commit = False, object is returned without saving to DB.
                ipn_obj = ipn.save(commit=False)
            except Exception, e:
                flag = "Exception while processing. (%s)" % e
        else:
            flag = "Invalid form. (%s)" % ipn.errors

    if ipn_obj is None:
        ipn_obj = PayUIPN()

    #Set query params and sender's IP address
    ipn_obj.initialize(request)

    if flag is not None:
        #We save errors in the flag field
        ipn_obj.set_flag(flag)

    ipn_obj.save()
    ipn_obj.send_signals()

    date = datetime.now(pytz.UTC).strftime('%Y%m%d%H%M%S')
    hash = hmac.new(MERCHANT_KEY, '00014%s' % date).hexdigest()
    return HttpResponse('<EPAYMENT>%s|%s</EPAYMENT>' % (date, hash))
示例#2
0
    if request.POST.get('HASH','') != hash:
        flag = 'Invalid hash %s. Hash string \n%s' % (request.POST.get('HASH',''), s)
    else:
        if ipn.is_valid():
            try:
                #When commit = False, object is returned without saving to DB.
                ipn_obj = ipn.save(commit = False)
            except Exception, e:
                flag = "Exception while processing. (%s)" % e
        else:
            flag = "Invalid form. (%s)" % ipn.errors



    if ipn_obj is None:
        ipn_obj = PayUIPN()

    #Set query params and sender's IP address
    ipn_obj.initialize(request)

    if flag is not None:
        #We save errors in the flag field
        ipn_obj.set_flag(flag)

    ipn_obj.save()
    ipn_obj.send_signals()

    date = datetime.now(pytz.UTC).strftime('%Y%m%d%H%M%S')
    hash = hmac.new(MERCHANT_KEY,'00014%s' % date).hexdigest()
    return HttpResponse('<EPAYMENT>%s|%s</EPAYMENT>' % (date,hash))
示例#3
0
                ipn_obj = ipn_form.save(commit=False)
            except Exception, exception:
                error = "Exception while processing. (%s)" % exception
        else:
            error = "Invalid form. (%s)" % ipn_form.errors

    if not ipn_obj:
        ipn_obj = PayUIPN()

    # Set query params and sender's IP address
    ipn_obj.response = getattr(request, request.method).urlencode()
    ipn_obj.ip_address = request.META.get('REMOTE_ADDR', '')

    if error:
        # We save errors in the error field
        ipn_obj.set_flag(error)

    ipn_obj.save()

    # Check for a token in the request and save it if found
    IPN_CC_TOKEN = request.POST.get('IPN_CC_TOKEN')
    IPN_CC_MASK = request.POST.get('IPN_CC_MASK')
    IPN_CC_EXP_DATE = request.POST.get('IPN_CC_EXP_DATE')

    if all([IPN_CC_TOKEN, IPN_CC_MASK, IPN_CC_EXP_DATE]):
        PayUToken.objects.create(
            IPN_CC_TOKEN=IPN_CC_TOKEN,
            IPN_CC_MASK=IPN_CC_MASK,
            IPN_CC_EXP_DATE=IPN_CC_EXP_DATE,
            ipn=ipn_obj
        )
示例#4
0
def test_payu_model_flag(flag_info, extra_info):
    model = PayUIPN(flag_info=flag_info)
    model.set_flag(extra_info)
    assert model.flag_info == flag_info + extra_info
    assert model.flag
示例#5
0
                ipn_obj = ipn_form.save(commit=False)
            except Exception, exception:
                error = "Exception while processing. (%s)" % exception
        else:
            error = "Invalid form. (%s)" % ipn_form.errors

    if not ipn_obj:
        ipn_obj = PayUIPN()

    # Set query params and sender's IP address
    ipn_obj.response = getattr(request, request.method).urlencode()
    ipn_obj.ip_address = request.META.get('REMOTE_ADDR', '')

    if error:
        # We save errors in the error field
        ipn_obj.set_flag(error)

    ipn_obj.save()
    ipn_obj.send_signals()

    # Check for a token in the request and save it if found
    IPN_CC_TOKEN = request.POST.get('IPN_CC_TOKEN')
    IPN_CC_MASK = request.POST.get('IPN_CC_MASK')
    IPN_CC_EXP_DATE = request.POST.get('IPN_CC_EXP_DATE')

    if all([IPN_CC_TOKEN, IPN_CC_MASK, IPN_CC_EXP_DATE]):
        Token.objects.create(
            IPN_CC_TOKEN=IPN_CC_TOKEN,
            IPN_CC_MASK=IPN_CC_MASK,
            IPN_CC_EXP_DATE=IPN_CC_EXP_DATE,
            ipn=ipn_obj
示例#6
0
    for k in ['SALEDATE', 'PAYMENTDATE', 'COMPLETE_DATE', 'REFNO', 'REFNOEXT', 'ORDERNO', 'ORDERSTATUS', 'PAYMETHOD', 'PAYMETHOD_CODE', ]:
        if request.POST.has_key(k):
            s += '%s%s' % (len(request.POST.get(k)), request.POST.get(k))

    hash = hmac.new(MERCHANT_KEY, s).hexdigest()
    if request.POST.get('HASH', '') != hash:
        flag = 'Invalid hash %s. Hash string \n%s' % (request.POST.get('HASH', ''), s)
    else:
        if ipn.is_valid():
            try:
                ipn_obj = ipn.save(commit=False) # When commit = False, object is returned without saving to DB.
            except Exception, e:
                flag = "Exception while processing. (%s)" % e
        else:
            flag = "Invalid form. (%s)" % ipn.errors

    if ipn_obj is None:
        ipn_obj = PayUIPN()

    ipn_obj.initialize(request) # Set query params and sender's IP address

    if flag is not None:
        ipn_obj.set_flag(flag) # We save errors in the flag field

    ipn_obj.save()
    ipn_obj.send_signals()

    date = datetime.now(pytz.UTC).strftime('%Y%m%d%H%M%S')
    hash = hmac.new(MERCHANT_KEY, '00014%s' % date).hexdigest()
    return HttpResponse('<EPAYMENT>%s|%s</EPAYMENT>' % (date, hash))