Exemplo n.º 1
0
def gateway(request):
    amount_post = request.POST['amount']
    amount = int(amount_post)

    redirect_url = 'http://127.0.0.1:8000/result/'
    gateway_url = send_url(amount, redirect_url,
                           SEND_URL_FINAL, PAYLINE_DOTIR_API_FINAL)

    return redirect(gateway_url)
Exemplo n.º 2
0
def initialise_payment_payline(request,plan_name):

    #check if the plan is valid.
    valid_plans = ["L1","L2","L5","U1","U3","U6"]
    if plan_name not in valid_plans :
        raise Http404("Data transfer selected is not valid.")

    # get the plan the user has selected
    all_plans = Data_Transfer_Plan.objects.all()
    plan = utility_functions.get_plan_by_name(all_plans,plan_name)

    # get the user's coupons
    user_profile = UserProfile.objects.get( user = request.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(plan, user_existing_coupons)

    # create a pending purchase
    pending_purchase = PendingPurchase()
    pending_purchase.data_transfer_plan = plan
    pending_purchase.user = request.user
    pending_purchase.save()

    # prepare amount
    if user_existing_coupons:
        amount = selected_plan.discounted_price
    else:
        amount =  selected_plan.original_price

    # get gateway_url
    # integrate pending purchase hashcode in redirect url
    redirect_url = 'http://gooshibegooshi.com/payment/result_payline/'+pending_purchase.hashcode+'/'
    gateway_url = send_url(amount, redirect_url,SEND_URL_FINAL, PAYLINE_DOTIR_API_FINAL)

    # redirect to payline.ir
    return redirect(gateway_url)