def pdt(request, item_check_callable=None, template="pdt/pdt.html", context=None): """Payment data transfer implementation: http://tinyurl.com/c9jjmw""" context = context or {} pdt_obj = None txn_id = request.GET.get('tx') failed = False if txn_id is not None: # If an existing transaction with the id tx exists: use it try: pdt_obj = PayPalPDT.objects.get(txn_id=txn_id) except PayPalPDT.DoesNotExist: # This is a new transaction so we continue processing PDT request pass if pdt_obj is None: form = PayPalPDTForm(request.GET) if form.is_valid(): try: pdt_obj = form.save(commit=False) except Exception, e: error = repr(e) failed = True else: error = form.errors failed = True if failed: pdt_obj = PayPalPDT() pdt_obj.set_flag("Invalid form. %s" % error) pdt_obj.initialize(request) if not failed: # The PDT object gets saved during verify pdt_obj.verify(item_check_callable)