Commit dbb6897c authored by Jérome Perrin's avatar Jérome Perrin

paypal_secure_payment: python3 support

parent cadde8a3
......@@ -26,15 +26,18 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import zope
import contextlib
from six.moves.urllib.parse import urlencode
from six.moves.urllib.request import urlopen, Request
import zope.interface
from zLOG import LOG, DEBUG
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from erp5.component.interface.IPaymentService import IPaymentService
@zope.interface.implementer(IPaymentService)
class PaypalService(XMLObject):
"""Paypal Service for payment"""
......@@ -57,10 +60,7 @@ class PaypalService(XMLObject):
"""See Payment Service Interface Documentation"""
def _getFieldList(self, paypal_dict):
field_list = []
for k,v in paypal_dict.iteritems():
field_list.append((k, v))
return field_list
return list(paypal_dict.items())
def navigate(self, REQUEST=None, **kw):
"""See Payment Service Interface Documentation"""
......@@ -96,13 +96,13 @@ class PaypalService(XMLObject):
param_dict["cmd"] = "_notify-validate"
if "service" in param_dict:
param_dict.pop("service")
param_list = urlencode(param_dict)
param_list = urlencode(param_dict).encode()
paypal_url = self.getLinkUrlString()
request = Request(paypal_url, param_list)
request.add_header("Content-type", "application/x-www-form-urlencoded")
response = urlopen(request)
status = response.read()
with contextlib.closing(urlopen(request)) as response:
status = response.read()
LOG("PaypalService status", DEBUG, status)
method_id = self._getTypeBasedMethod("reportPaymentStatus").id
getattr(self.activate(), method_id)(response_dict=REQUEST.form)
return status == "VERIFIED"
\ No newline at end of file
return status == b"VERIFIED"
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment