Beispiel #1
0
def payment_execute(request, template="shop/payment_confirmation.html"):    
	order = None
	lookup = {}
	if request.GET.has_key('token'):
		paypal_api()
		token = request.GET['token']
		payer_id = request.GET['PayerID']
		order = get_object_or_404(Order, paypal_redirect_token=token)
		payment = Payment.find(order.transaction_id)
		payment.execute({ "payer_id": payer_id })
	elif request.GET.has_key('transaction_id'):
		api = pagseguro_api()
		email = api.data['email']
		token = api.data['token']
		transaction = request.GET['transaction_id']
		url = api.config.TRANSACTION_URL % transaction
		resp = urllib2.urlopen("%s?email=%s&token=%s" % (url,email,token)).read()
		lookup["id"] = ETree.fromstring(resp).findall("reference")[0].text
		print ETree.fromstring(resp).findall("reference")[0].text
		if not request.user.is_authenticated(): lookup["key"] = request.session.session_key
		if not request.user.is_staff: lookup["user_id"] = request.user.id
		order = get_object_or_404(Order, **lookup)
		order.transaction_id = transaction
	elif request.GET.has_key('orderid'):
		return redirect("/store/bank?order_id=%s" % request.GET['orderid'])
	order.status = 2
	order.save()
	context = { "order" : order }
	response = render(request, template, context)
	return response
Beispiel #2
0
def payment_execute(request, template="shop/payment_confirmation.html"):
    order = None
    lookup = {}
    if request.GET.has_key('token'):
        paypal_api()
        token = request.GET['token']
        payer_id = request.GET['PayerID']
        order = get_object_or_404(Order, paypal_redirect_token=token)
        payment = Payment.find(order.transaction_id)
        payment.execute({"payer_id": payer_id})
    elif request.GET.has_key('transaction_id'):
        api = pagseguro_api()
        email = api.data['email']
        token = api.data['token']
        transaction = request.GET['transaction_id']
        url = api.config.TRANSACTION_URL % transaction
        resp = urllib2.urlopen("%s?email=%s&token=%s" %
                               (url, email, token)).read()
        lookup["id"] = ETree.fromstring(resp).findall("reference")[0].text
        print ETree.fromstring(resp).findall("reference")[0].text
        if not request.user.is_authenticated():
            lookup["key"] = request.session.session_key
        if not request.user.is_staff: lookup["user_id"] = request.user.id
        order = get_object_or_404(Order, **lookup)
        order.transaction_id = transaction
    elif request.GET.has_key('orderid'):
        return redirect("/store/bank?order_id=%s" % request.GET['orderid'])
    order.status = 2
    order.save()
    context = {"order": order}
    response = render(request, template, context)
    return response
Beispiel #3
0
def paypal_redirect(request,order):
    paypal_api()
    payment = paypalrestsdk.Payment.find(order.transaction_id)
    for link in payment.links:
        if link.method == "REDIRECT":
            redirect_url = link.href
            url = urlparse.urlparse(link.href)
            params = urlparse.parse_qs(url.query)
            redirect_token = params['token'][0]
            order.paypal_redirect_token = redirect_token
            order.save()
    return redirect(redirect_url)
Beispiel #4
0
def paypal_redirect(request, order):
    paypal_api()
    payment = paypalrestsdk.Payment.find(order.transaction_id)
    for link in payment.links:
        if link.method == "REDIRECT":
            redirect_url = link.href
            url = urlparse.urlparse(link.href)
            params = urlparse.parse_qs(url.query)
            redirect_token = params['token'][0]
            order.paypal_redirect_token = redirect_token
            order.save()
    return redirect(redirect_url)
Beispiel #5
0
 def payment_execute(self, request, template="shop/payment_confirmation.html"):    
     paypal_api()
     token = request.GET['token']
     payer_id = request.GET['PayerID']
     logger.debug("feedly.views.payment_execute(token=%s,payer_id=%s)" % (token,payer_id))
     order = get_object_or_404(Order, paypal_redirect_token=token)
     payment = Payment.find(order.transaction_id)
     payment.execute({ "payer_id": payer_id })
     # Pago, falta enviar
     order.status = 3
     order.save()
     context = { "order" : order }
     response = render(request, template, context)
     return response