def pay_transaction_view(request, transaction, expired=None): if expired: return render(request, 'transactions/expired_payment.html', { 'document': transaction.document, }) if transaction.state != Transaction.States.Initial: return render( request, 'transactions/complete_payment.html', { 'transaction': transaction, 'document': transaction.document, 'fail_data': FAIL_CODES.get(transaction.fail_code) }) payment_processor = transaction.payment_method.get_payment_processor() view = payment_processor.get_view(transaction, request) if not view or not transaction.can_be_consumed: return render(request, 'transactions/expired_payment.html', { 'document': transaction.document, }) transaction.last_access = timezone.now() transaction.save() try: return view(request) except NotImplementedError: raise Http404
def pay_transaction_view(request, transaction, expired=None): if expired: return render(request, 'transactions/expired_payment.html', { 'document': transaction.document, }) if transaction.state != Transaction.States.Initial: return render(request, 'transactions/complete_payment.html', { 'transaction': transaction, 'document': transaction.document, 'fail_data': FAIL_CODES.get(transaction.fail_code) }) payment_processor = transaction.payment_method.get_payment_processor() view = payment_processor.get_view(transaction, request) if not view or not transaction.can_be_consumed: return render(request, 'transactions/expired_payment.html', { 'document': transaction.document, }) transaction.last_access = timezone.now() transaction.save() try: return view(request) except NotImplementedError: raise Http404
def complete_payment_view(request, transaction, expired=None): if transaction.state == transaction.States.Initial: payment_processor = get_instance(transaction.payment_processor) payment_processor.handle_transaction_response(transaction, request) if 'return_url' in request.GET: redirect_url = furl(request.GET['return_url']).add({ 'transaction_uuid': transaction.uuid }).url return HttpResponseRedirect(redirect_url) else: return render(request, 'transactions/complete_payment.html', { 'transaction': transaction, 'document': transaction.document, 'fail_data': FAIL_CODES.get(transaction.fail_code), })
def complete_payment_view(request, transaction, expired=None): if transaction.state == transaction.States.Initial: payment_processor = get_instance(transaction.payment_processor) payment_processor.handle_transaction_response(transaction, request) if 'return_url' in request.GET: redirect_url = six.moves.urllib.parse.unquote( furl(request.GET['return_url']).add( { 'transaction_uuid': transaction.uuid } ).url ) return HttpResponseRedirect(redirect_url) else: return render(request, 'transactions/complete_payment.html', { 'transaction': transaction, 'document': transaction.document, 'fail_data': FAIL_CODES.get(transaction.fail_code), })