summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eopayment/__init__.py7
-rw-r--r--eopayment/common.py22
-rw-r--r--eopayment/ogone.py6
-rw-r--r--eopayment/paybox.py9
-rw-r--r--eopayment/systempayv2.py7
-rw-r--r--tests/test_keyware.py3
-rw-r--r--tests/test_mollie.py3
-rw-r--r--tests/test_paybox.py4
8 files changed, 12 insertions, 49 deletions
diff --git a/eopayment/__init__.py b/eopayment/__init__.py
index 8d9e020..e7d0d38 100644
--- a/eopayment/__init__.py
+++ b/eopayment/__init__.py
@@ -20,8 +20,6 @@ import importlib
import logging
import pytz
-import six
-
from .common import ( # noqa: F401
URL, HTML, FORM, RECEIVED, ACCEPTED, PAID, DENIED,
CANCELED, CANCELLED, ERROR, WAITING, EXPIRED, force_text,
@@ -31,10 +29,7 @@ from .common import ( # noqa: F401
__all__ = ['Payment', 'URL', 'HTML', 'FORM', 'SIPS', 'SYSTEMPAY',
'TIPI', 'DUMMY', 'get_backend', 'RECEIVED', 'ACCEPTED', 'PAID',
'DENIED', 'CANCELED', 'CANCELLED', 'ERROR', 'WAITING',
- 'EXPIRED', 'get_backends', 'PAYFIP_WS', 'SAGA']
-
-if six.PY3:
- __all__.extend(['KEYWARE', 'MOLLIE'])
+ 'EXPIRED', 'get_backends', 'PAYFIP_WS', 'SAGA', 'KEYWARE', 'MOLLIE']
SIPS = 'sips'
SIPS2 = 'sips2'
diff --git a/eopayment/common.py b/eopayment/common.py
index 3a03f17..522dd91 100644
--- a/eopayment/common.py
+++ b/eopayment/common.py
@@ -24,10 +24,7 @@ from decimal import ROUND_DOWN, Decimal
import six
-if six.PY3:
- import html
-else:
- import cgi
+import html
from gettext import gettext as _
@@ -68,15 +65,10 @@ def force_text(s, encoding='utf-8'):
return s
try:
if not issubclass(type(s), six.string_types):
- if six.PY3:
- if isinstance(s, bytes):
- s = six.text_type(s, encoding)
- else:
- s = six.text_type(s)
- elif hasattr(s, '__unicode__'):
- s = six.text_type(s)
+ if isinstance(s, bytes):
+ s = six.text_type(s, encoding)
else:
- s = six.text_type(bytes(s), encoding)
+ s = six.text_type(s)
else:
s = s.decode(encoding)
except UnicodeDecodeError:
@@ -217,10 +209,8 @@ class Form(object):
return s
def escape(self, s):
- if six.PY3:
- return html.escape(force_text(s, self.encoding))
- else:
- return cgi.escape(force_text(s, self.encoding)).encode(self.encoding)
+ return html.escape(force_text(s, self.encoding))
+
def __str__(self):
s = '<form method="%s" action="%s">' % (self.method, self.url)
diff --git a/eopayment/ogone.py b/eopayment/ogone.py
index e9e4d5f..612906c 100644
--- a/eopayment/ogone.py
+++ b/eopayment/ogone.py
@@ -18,7 +18,6 @@
from decimal import Decimal, ROUND_HALF_UP
from six.moves.urllib import parse as urlparse
import hashlib
-import six
import uuid
from .common import (
@@ -578,10 +577,7 @@ class Payment(PaymentCommon):
return complus, FORM, form
def response(self, query_string, **kwargs):
- if six.PY3:
- params = urlparse.parse_qs(query_string, True, encoding=self.encoding)
- else:
- params = urlparse.parse_qs(query_string, True)
+ params = urlparse.parse_qs(query_string, True, encoding=self.encoding)
params = dict((key.upper(), params[key][0]) for key in params)
if not set(params) >= set(['ORDERID', 'PAYID', 'STATUS', 'NCERROR']):
raise ResponseError('missing ORDERID, PAYID, STATUS or NCERROR')
diff --git a/eopayment/paybox.py b/eopayment/paybox.py
index 84522f4..da19999 100644
--- a/eopayment/paybox.py
+++ b/eopayment/paybox.py
@@ -31,7 +31,6 @@ from Crypto.Signature import PKCS1_v1_5
from Crypto.PublicKey import RSA
from Crypto.Hash import SHA
-import six
from six.moves.urllib import parse as urlparse
from six.moves.urllib import parse as urllib
@@ -352,10 +351,8 @@ class Payment(PaymentCommon):
d['PBX_REPONDRE_A'] = force_text(automatic_return_url)
d = d.items()
- if six.PY3:
- shared_secret = codecs.decode(bytes(self.shared_secret, 'ascii'), 'hex')
- else:
- shared_secret = codecs.decode(bytes(self.shared_secret), 'hex')
+
+ shared_secret = codecs.decode(bytes(self.shared_secret, 'ascii'), 'hex')
d = sign(d, shared_secret)
url = URLS[self.platform]
fields = []
@@ -446,8 +443,6 @@ class Payment(PaymentCommon):
logger.debug('received %r', response.text)
data = dict(urlparse.parse_qsl(response.text, True, True))
if data.get('CODEREPONSE') != PAYBOX_DIRECT_SUCCESS_RESPONSE_CODE:
- if six.PY2:
- raise ResponseError(data['COMMENTAIRE'].encode('utf-8'))
raise ResponseError(data['COMMENTAIRE'])
return data
diff --git a/eopayment/systempayv2.py b/eopayment/systempayv2.py
index dc1853b..695ab20 100644
--- a/eopayment/systempayv2.py
+++ b/eopayment/systempayv2.py
@@ -23,7 +23,6 @@ import hmac
import random
import re
import string
-import six
from six.moves.urllib import parse as urlparse
import warnings
@@ -300,10 +299,8 @@ class Payment(PaymentCommon):
# trans_id starting with 9 are reserved for the systempay backoffice
# https://paiement.systempay.fr/doc/fr-FR/form-payment/reference/vads-trans-id.html
gen = random.SystemRandom()
- if six.PY3:
- alphabet = string.ascii_letters + string.digits
- else:
- alphabet = string.letters + string.digits
+
+ alphabet = string.ascii_letters + string.digits
first_letter_alphabet = alphabet.replace('9', '')
vads_trans_id = (
gen.choice(first_letter_alphabet)
diff --git a/tests/test_keyware.py b/tests/test_keyware.py
index 912d2f9..d826558 100644
--- a/tests/test_keyware.py
+++ b/tests/test_keyware.py
@@ -18,14 +18,11 @@ import json
import pytest
import requests
-import six
from httmock import response, urlmatch, HTTMock, with_httmock, all_requests, remember_called
import eopayment
from eopayment.keyware import Payment
-pytestmark = pytest.mark.skipif(six.PY2, reason='this payment module only supports python3')
-
WEBHOOK_URL = 'https://callback.example.com'
RETURN_URL = 'https://return.example.com'
API_KEY = 'test'
diff --git a/tests/test_mollie.py b/tests/test_mollie.py
index a4b33b4..769b2ab 100644
--- a/tests/test_mollie.py
+++ b/tests/test_mollie.py
@@ -17,15 +17,12 @@
import json
import requests
-import six
import eopayment
import pytest
from eopayment.mollie import Payment
from httmock import remember_called, response, urlmatch, with_httmock
-pytestmark = pytest.mark.skipif(six.PY2, reason='this payment module only supports python3')
-
WEBHOOK_URL = 'https://callback.example.com'
RETURN_URL = 'https://return.example.com'
API_KEY = 'test'
diff --git a/tests/test_paybox.py b/tests/test_paybox.py
index c72fb46..f7f393c 100644
--- a/tests/test_paybox.py
+++ b/tests/test_paybox.py
@@ -21,7 +21,6 @@ from unittest import TestCase
from decimal import Decimal
import base64
import mock
-import six
from six.moves.urllib import parse as urllib
from xml.etree import ElementTree as ET
@@ -47,9 +46,6 @@ BACKEND_PARAMS = {
class PayboxTests(TestCase):
- if six.PY2:
- def assertRaisesRegex(self, *args, **kwargs):
- return self.assertRaisesRegexp(*args, **kwargs)
def test_sign(self):
key = (b'0123456789ABCDEF0123456789ABCDEF0123456789'