Example #1
0
def express_payment(request):
    user = request.user
    cart_subtotal = cart.cart_subtotal(request)

    if request.method == "POST":
        form = PaymentForm(request.POST)
        if form.is_valid():
            order = form.save(commit=False)
            order.buyer = request.user
            order.transaction_id = order
            order.save()
            if order.pk:
                cart_items = cart.get_cart_items(request)
                for item in cart_items:
                    order_item = OrderItem(item=item.item_id,
                                           quantity=item.quantity,
                                           price=item.item_id.price,
                                           order=order)
                    order_item.save()
    item = {
        "amt": cart_subtotal,  # amount to charge for item
        "invnum": "696969696",  # unique tracking variable paypal
        "custom": '555',  # custom tracking variable for you
        "cancelurl": settings.URL + "error",  # error page
        "returnurl": settings.URL + "success"
    }  # success page

    kw = {
        "item": item,  # what you're selling
        "success_url": "/success/"
    }  # redirect location after success, I am not sure but it shouldn't work
    ppp = PayPalPro(**kw)
    return ppp(request)
Example #2
0
def request_payment_pro(request):
    item = {
        'amt': "10.00",  # amount to charge for item
        'inv': "inventory#",  # unique tracking variable paypal
        'custom': "tracking#",  # custom tracking variable for you
        'cancelurl':
        "https://www.donomo.com/account/pay/cancel/",  # Express checkout cancel url
        'returnurl': "https://www.donomo.com/account/pay/return/"
    }  # Express checkout return url

    kw = {
        'item': 'item',  # what you're selling
        'payment_template': 'template',  # template to use for payment form
        'confirm_template':
        'confirm_template',  # form class to use for Express checkout confirmation
        'payment_form_cls':
        'payment_form_cls',  # form class to use for payment
        'success_url':
        '/success',  # where to redirect after successful payment
    }
    ppp = PayPalPro(**kw)
    return HttpResponse(ppp.render_payment_form())
Example #3
0
def pay_premium(request):
    item = {
        "paymentrequest_0_amt": "10.00",  # amount to charge for item
        "inv": "inventory",  # unique tracking variable paypal
        "custom": "tracking",  # custom tracking variable for you
        "cancelurl": "./",  # Express checkout cancel url
        "returnurl": "./"
    }  # Express checkout return url

    ppp = PayPalPro(
        item=item,  # what you're selling
        payment_template="payment.html",  # template name for payment
        confirm_template="confirmation.html",  # template name for confirmation
        success_url="/success/",  # redirect location after success
        nvp_handler=nvp_handler)
    return ppp(request)
Example #4
0
def ppp_wrapper(request, handler=None):
    item = {"paymentrequest_0_amt": "10.00",
            "inv": "inventory",
            "custom": "tracking",
            "cancelurl": "http://foo.com/cancel",
            "returnurl": "http://foo.com/return"}

    if handler is None:
        handler = lambda nvp: nvp  # NOP
    ppp = PayPalPro(
        item=item,                             # what you're selling
        payment_template="payment.html",       # template name for payment
        confirm_template="confirmation.html",  # template name for confirmation
        success_url="/success/",               # redirect location after success
        nvp_handler=handler
        )

    return ppp(request)
Example #5
0
def buy_my_item(request):
    item = {
        "paymentrequest_0_amt": "12.00",  # amount to charge for item
        "invnum": "2345wertsddf22412",  # unique tracking variable paypal
        "custom": "rwterdte1232r",  # custom tracking variable for you
        "cancelurl": "%s%s" %
        (settings.ALLOWED_HOSTS[0], "/cancel"),  # Express checkout cancel url
        "returnurl": "%s%s" %
        (settings.ALLOWED_HOSTS[0], "/return"),  # Express checkout return url
        "amt": 1.0
    }
    ppp = PayPalPro(
        item=item,  # what you're selling
        # payment_template="payment.html",      # template name for payment
        # confirm_template="confirm.html", # template name for confirmation
        success_url="/paypal/success/",  # redirect location after success
        nvp_handler=nvp_handler)
    return ppp(request)
def authorization(request, pk):
    payment = get_object_or_404(Payment, pk=pk)
    TWOPLACES = Decimal(10)**-2

    amount = str(payment.amount.quantize(TWOPLACES))

    item = {
        'amt': amount,
        'invnum': payment.pk,
        'cancelurl': payment.order.get_absolute_url(),
        'returnurl': payment.order.get_absolute_url()
    }

    kw = {
        'item': item,
        'payment_template': 'getpaid/paypal_payment.html',
        'confirm_template': 'getpaid/paypal_confirm.html',
        'success_url': payment.order.get_absolute_url(),  # FIX
        'fail_url': payment.order.get_absolute_url()
    }  # FIX
    ppp = PayPalPro(**kw)
    return ppp(request)
Example #7
0
def paypal_checkout(request):
    #    if request.method == 'POST':
    booking = get_booking(request)
    item = {
        "PAYMENTREQUEST_0_AMT": str(round(booking.guest_payment,
                                          2)),  # amount to charge for item
        'PAYMENTREQUEST_0_DESC': booking.place.title,
        'PAYMENTREQUEST_0_CURRENCYCODE': booking.currency.name,
        "PAYMENTREQUEST_0_INV": "AAAAAA",  # unique tracking variable paypal
        "PAYMENTREQUEST_0_CUSTOM":
        str(booking.id),  # custom tracking variable for you
        "cancelurl": "%s%s" % (settings.SITE_NAME, reverse('paypal_cancel')),
        "returnurl": "%s%s" % (settings.SITE_NAME, reverse('paypal_checkout')),
    }

    kw = {
        "item": item,
        "payment_template": "book_place.html",  #probably not used
        "confirm_template": "paypal-confirm.html",
        "success_url": reverse('paypal_complete'),
        'context': request.session.get('booking_context', {})
    }
    ppp = PayPalPro(**kw)
    return ppp(request)
Example #8
0
 def proceed(self):
     from paypal.pro.views import PayPalPro
     ppp = PayPalPro(**self.data)
     return ppp(self.request)