Ejemplo n.º 1
0
def result_payline(request,pending_purchase_hashcode):

    trans_id = request.POST['trans_id']
    id_get = request.POST['id_get']
    final_result = get_result(PAYLINE_DOTIR_API_FINAL, trans_id, id_get)

    context = {}

    # retrieve the pending purchase
    pending_purchase = PendingPurchase.objects.get(hashcode = pending_purchase_hashcode)

    # get the user's coupons
    user_profile = UserProfile.objects.get( user = pending_purchase.user )
    user_existing_coupons = Coupon.objects.filter( user_profile = user_profile )

    # create the temp plan for the plan selected by user
    selected_plan = utility_functions.create_temp_plan(pending_purchase.data_transfer_plan, user_existing_coupons)
    context['selected_plan'] = selected_plan

    response = None

    if final_result is None:
        response =  pay_for_a_plan_failure(request,context)
    else:
        if int(final_result) == 1:
            response =  pay_for_a_plan_success(request,pending_purchase,context,user_existing_coupons,selected_plan)
        else:
            response =  pay_for_a_plan_failure(request,context)

    # remove pending purchase
    pending_purchase.delete()

    return response
Ejemplo n.º 2
0
def result(request):

    trans_id = request.POST['trans_id']
    id_get = request.POST['id_get']

    final_result = get_result(PAYLINE_DOTIR_API_FINAL, trans_id, id_get)

    if int(final_result) == 1:
        result_end = 'successful'
    else:
        result_end = 'UNsuccessful'

    return render(request, 'successful_payment.html',
                  {'result_end': result_end})