Skip to content

Commit

Permalink
fix url encode bug
Browse files Browse the repository at this point in the history
  • Loading branch information
odero committed Nov 11, 2015
1 parent 2ccf2ea commit 15c215c
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions django_pesapal/views.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import

import logging
import oauth2 as oauth
import requests

from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
from django.db.models.loading import get_model
from django.http import HttpResponse
from django.http import HttpResponse, QueryDict
from django.shortcuts import get_object_or_404
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.views.generic.base import View, RedirectView, TemplateView

from xml.etree import cElementTree as ET

import conf as settings
from . import conf as settings

import logging
import oauth2 as oauth
import requests
import urllib

DEFAULT_TYPE = "MERCHANT"
Transaction = get_model(settings.PESAPAL_TRANSACTION_MODEL)
Expand Down Expand Up @@ -148,12 +151,14 @@ def get_payment_status(self, **kwargs):
class PaymentResponseMixin(object):

def build_url_params(self):
url_params = '?' + urllib.urlencode(
url_params = QueryDict(mutable=True)
url_params.update(
{
'pesapal_merchant_reference': self.transaction.merchant_reference,
'pesapal_transaction_tracking_id': self.transaction.pesapal_transaction
}
)
url_params = '?' + url_params.urlencode()
return url_params

def get_payment_status_url(self):
Expand Down Expand Up @@ -265,12 +270,14 @@ class TransactionStatusView(UpdatePaymentStatusMixin, RedirectView):
def get_redirect_url(self, *args, **kwargs):

params = self.get_params()

self.process_payment_status()

# redirect back to Transaction completed view
url = reverse('transaction_completed')
url += '?' + urllib.urlencode(params)

query_dict = QueryDict(mutable=True)
query_dict.update(params)
url += '?' + query_dict.urlencode()

return url

Expand Down

0 comments on commit 15c215c

Please sign in to comment.