Permalink
Browse files

Merge branch 'hotfix/authnet_encoding' into develop

  • Loading branch information...
2 parents 364a852 + abcab34 commit f026d1043190d63edbcfdd592ad2f56ea11a4e97 @bhagany bhagany committed May 4, 2012
Showing with 13 additions and 3 deletions.
  1. +1 −1 hiicart/gateway/authorizenet/ipn.py
  2. +11 −1 hiicart/gateway/authorizenet/views.py
  3. +1 −1 hiicart/gateway/paypal/views.py
View
2 hiicart/gateway/authorizenet/ipn.py
@@ -37,7 +37,7 @@ class AuthorizeNetIPN(IPNBase):
def __init__(self, cart):
super(AuthorizeNetIPN, self).__init__("authorizenet", cart, default_settings)
- self._require_settings(["MERCHANT_ID", "MERCHANT_KEY",
+ self._require_settings(["MERCHANT_ID", "MERCHANT_KEY",
"MERCHANT_PRIVATE_KEY"])
def confirm_ipn_data(self, data):
View
12 hiicart/gateway/authorizenet/views.py
@@ -29,6 +29,16 @@ def ipn(request):
if request.method != "POST":
return HttpResponse("Requests must be POSTed")
data = request.POST.copy()
+ # Authorize sends us info urlencoded as latin1
+ # So, if we end up with the unicode char in our processed POST that means
+ # "unknown char" (\ufffd), try to transcode from latin1
+ parsed_raw = parse_qs(request.raw_post_data)
+ for key, value in data.iteritems():
+ if u'\ufffd' in value:
+ try:
+ data.update({key: unicode(unquote_plus(parsed_raw[key][-1]), 'latin1')})
+ except:
+ pass
log.info("IPN Notification received from Authorize.net: %s" % data)
try:
log.info("IPN Notification received from Authorize.net (raw): %s" % request.raw_post_data)
@@ -51,7 +61,7 @@ def ipn(request):
gateway.set_response(data)
# Return the user back to the store front
- response = render_to_response('gateway/authorizenet/ipn.html',
+ response = render_to_response('gateway/authorizenet/ipn.html',
{'return_url': data['return_url']})
response['Location'] = data['return_url']
return response
View
2 hiicart/gateway/paypal/views.py
@@ -80,7 +80,7 @@ def _base_paypal_ipn_listener(request, ipn_class):
log.info("Unknown IPN type or status. Type: %s\tStatus: %s" %
(txn_type, status))
return HttpResponse()
-
+
@csrf_view_exempt
@format_exceptions

0 comments on commit f026d10

Please sign in to comment.