diff --git a/eopayment/__init__.py b/eopayment/__init__.py index 9b82803..8116ee4 100644 --- a/eopayment/__init__.py +++ b/eopayment/__init__.py @@ -17,24 +17,25 @@ import datetime import importlib import logging + import pytz from .common import ( # noqa: F401 - URL, - HTML, - FORM, - RECEIVED, ACCEPTED, - PAID, - DENIED, CANCELED, CANCELLED, + DENIED, ERROR, - WAITING, EXPIRED, - force_text, - ResponseError, + FORM, + HTML, + PAID, + RECEIVED, + URL, + WAITING, PaymentException, + ResponseError, + force_text, ) __all__ = [ diff --git a/eopayment/__main__.py b/eopayment/__main__.py index ebbf158..5838a2a 100644 --- a/eopayment/__main__.py +++ b/eopayment/__main__.py @@ -25,7 +25,7 @@ import tempfile import click -from . import Payment, FORM, URL +from . import FORM, URL, Payment def option(value): diff --git a/eopayment/cb.py b/eopayment/cb.py index d409394..2497dc5 100644 --- a/eopayment/cb.py +++ b/eopayment/cb.py @@ -16,8 +16,7 @@ '''Responses codes emitted by EMV Card or 'Carte Bleu' in France''' -from . import PAID, CANCELLED, ERROR, DENIED - +from . import CANCELLED, DENIED, ERROR, PAID CB_RESPONSE_CODES = { '00': {'message': 'Transaction approuvée ou traitée avec succès', 'result': PAID}, diff --git a/eopayment/common.py b/eopayment/common.py index 750c5f9..cd0299b 100644 --- a/eopayment/common.py +++ b/eopayment/common.py @@ -14,21 +14,18 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import os.path +import html +import logging import os +import os.path import random import sys -import logging from datetime import date from decimal import ROUND_DOWN, Decimal +from gettext import gettext as _ import six -import html - - -from gettext import gettext as _ - try: if 'django' in sys.modules: from django.utils.translation import ugettext_lazy as _ diff --git a/eopayment/dummy.py b/eopayment/dummy.py index ef46ce1..2c67de1 100644 --- a/eopayment/dummy.py +++ b/eopayment/dummy.py @@ -20,7 +20,7 @@ import warnings from six.moves.urllib.parse import parse_qs, urlencode -from .common import PaymentCommon, PaymentResponse, ResponseError, URL, PAID, ERROR, WAITING, force_text, _ +from .common import ERROR, PAID, URL, WAITING, PaymentCommon, PaymentResponse, ResponseError, _, force_text __all__ = ['Payment'] diff --git a/eopayment/mollie.py b/eopayment/mollie.py index 79e2a21..efc6dc1 100644 --- a/eopayment/mollie.py +++ b/eopayment/mollie.py @@ -14,22 +14,21 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from .common import _ - import requests from six.moves.urllib.parse import parse_qs, urljoin from .common import ( + ACCEPTED, CANCELLED, ERROR, PAID, URL, + WAITING, PaymentCommon, PaymentException, PaymentResponse, ResponseError, - WAITING, - ACCEPTED, + _, ) __all__ = ['Payment'] diff --git a/eopayment/ogone.py b/eopayment/ogone.py index 9910c9a..3c5933e 100644 --- a/eopayment/ogone.py +++ b/eopayment/ogone.py @@ -14,30 +14,30 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from decimal import Decimal, ROUND_HALF_UP -from six.moves.urllib import parse as urlparse import hashlib import uuid +from decimal import ROUND_HALF_UP, Decimal + +from six.moves.urllib import parse as urlparse from .common import ( + ACCEPTED, + CANCELLED, + DENIED, + ERROR, + FORM, + ORDERID_TRANSACTION_SEPARATOR, + PAID, + WAITING, + Form, PaymentCommon, PaymentResponse, - FORM, - CANCELLED, - PAID, - ERROR, - Form, - DENIED, - ACCEPTED, - ORDERID_TRANSACTION_SEPARATOR, - WAITING, ResponseError, + _, force_byte, force_text, - _, ) - ENVIRONMENT_TEST = 'TEST' ENVIRONMENT_TEST_URL = 'https://secure.ogone.com/ncol/test/orderstandard.asp' ENVIRONMENT_PROD = 'PROD' diff --git a/eopayment/paybox.py b/eopayment/paybox.py index 31c671b..cffec55 100644 --- a/eopayment/paybox.py +++ b/eopayment/paybox.py @@ -14,43 +14,40 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import base64 import codecs -from collections import OrderedDict import datetime -import logging import hashlib import hmac +import logging import re -import requests import uuid +import warnings +from collections import OrderedDict import pytz - -from Crypto.Signature import PKCS1_v1_5 -from Crypto.PublicKey import RSA +import requests from Crypto.Hash import SHA - -from six.moves.urllib import parse as urlparse +from Crypto.PublicKey import RSA +from Crypto.Signature import PKCS1_v1_5 from six.moves.urllib import parse as urllib +from six.moves.urllib import parse as urlparse -import base64 -import warnings - +from . import cb from .common import ( - PaymentCommon, - PaymentResponse, - FORM, - PAID, CANCELLED, DENIED, ERROR, + FORM, + PAID, Form, + PaymentCommon, + PaymentResponse, ResponseError, - force_text, - force_byte, _, + force_byte, + force_text, ) -from . import cb __all__ = ['sign', 'Payment'] diff --git a/eopayment/payfip_ws.py b/eopayment/payfip_ws.py index 16e2c34..65fbaf8 100644 --- a/eopayment/payfip_ws.py +++ b/eopayment/payfip_ws.py @@ -16,40 +16,38 @@ import copy -import decimal import datetime +import decimal import functools import os import random import re -import requests import unicodedata import xml.etree.ElementTree as ET import pytz - +import requests import six -from six.moves.urllib.parse import parse_qs - import zeep import zeep.exceptions +from six.moves.urllib.parse import parse_qs -from .systempayv2 import isonow from .common import ( - PaymentCommon, - PaymentResponse, - URL, - PAID, - DENIED, CANCELLED, + DENIED, ERROR, - ResponseError, - PaymentException, - WAITING, EXPIRED, - force_text, + PAID, + URL, + WAITING, + PaymentCommon, + PaymentException, + PaymentResponse, + ResponseError, _, + force_text, ) +from .systempayv2 import isonow # The URL of the WSDL published in the documentation is still wrong, it # references XSD files which are not resolvable :/ we must use this other URL diff --git a/eopayment/saga.py b/eopayment/saga.py index ca8aad9..243aeb2 100644 --- a/eopayment/saga.py +++ b/eopayment/saga.py @@ -17,22 +17,21 @@ import functools -from six.moves.urllib.parse import urljoin, parse_qs - import lxml.etree as ET import zeep import zeep.exceptions +from six.moves.urllib.parse import parse_qs, urljoin from .common import ( - PaymentException, - PaymentCommon, - ResponseError, - URL, - PAID, - DENIED, CANCELLED, + DENIED, ERROR, + PAID, + URL, + PaymentCommon, + PaymentException, PaymentResponse, + ResponseError, ) _zeep_transport = None diff --git a/eopayment/sips2.py b/eopayment/sips2.py index 131f9d6..82d895f 100644 --- a/eopayment/sips2.py +++ b/eopayment/sips2.py @@ -14,31 +14,29 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import datetime import collections +import datetime import hashlib import hmac import json import uuid import warnings +import pytz +import requests from six.moves.urllib import parse as urlparse -import requests - -import pytz - from .common import ( - PaymentCommon, - FORM, - Form, - PaymentResponse, - PAID, - ERROR, CANCELED, + ERROR, + FORM, + PAID, + Form, + PaymentCommon, + PaymentResponse, ResponseError, - force_text, _, + force_text, ) __all__ = ['Payment'] diff --git a/eopayment/systempayv2.py b/eopayment/systempayv2.py index a2a7e1a..45f5bfd 100644 --- a/eopayment/systempayv2.py +++ b/eopayment/systempayv2.py @@ -15,31 +15,32 @@ # along with this program. If not, see . import base64 -import pytz import datetime as dt import hashlib import hmac import random import re import string -from six.moves.urllib import parse as urlparse import warnings +import pytz +from six.moves.urllib import parse as urlparse + +from .cb import translate_cb_error_code from .common import ( - PaymentCommon, - PaymentResponse, - PAID, - DENIED, CANCELLED, + DENIED, ERROR, FORM, + PAID, Form, + PaymentCommon, + PaymentResponse, ResponseError, - force_text, - force_byte, _, + force_byte, + force_text, ) -from .cb import translate_cb_error_code __all__ = ['Payment'] diff --git a/eopayment/tipi.py b/eopayment/tipi.py index a056e82..4bec0ef 100644 --- a/eopayment/tipi.py +++ b/eopayment/tipi.py @@ -16,16 +16,15 @@ import datetime import decimal -import re +import logging import random +import re +import warnings import pytz +from six.moves.urllib.parse import parse_qs, urlencode -from .common import PaymentCommon, PaymentResponse, URL, PAID, DENIED, CANCELLED, ERROR, ResponseError, _ -from six.moves.urllib.parse import urlencode, parse_qs - -import logging -import warnings +from .common import CANCELLED, DENIED, ERROR, PAID, URL, PaymentCommon, PaymentResponse, ResponseError, _ __all__ = ['Payment'] diff --git a/setup.py b/setup.py index 0c053af..c2116b8 100755 --- a/setup.py +++ b/setup.py @@ -4,25 +4,24 @@ Setup script for eopayment ''' +import distutils +import distutils.core +import doctest import io import os import subprocess - -import distutils -import distutils.core -from distutils.command.build import build as _build from distutils.cmd import Command +from distutils.command.build import build as _build from distutils.spawn import find_executable +from glob import glob +from os.path import basename +from os.path import join as pjoin +from os.path import splitext +from unittest import TestLoader, TextTestRunner import setuptools -from setuptools.command.sdist import sdist from setuptools.command.install_lib import install_lib as _install_lib - -from glob import glob -from os.path import splitext, basename, join as pjoin -import os -from unittest import TextTestRunner, TestLoader -import doctest +from setuptools.command.sdist import sdist class TestCommand(distutils.core.Command): diff --git a/tests/conftest.py b/tests/conftest.py index ec3a2fa..f1b11fe 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -16,13 +16,11 @@ import json -import pytest - import httmock import lxml.etree as ET - -from requests.adapters import HTTPAdapter +import pytest from requests import Session +from requests.adapters import HTTPAdapter def pytest_addoption(parser): diff --git a/tests/test_base_payment.py b/tests/test_base_payment.py index 6887ac4..9c48e11 100644 --- a/tests/test_base_payment.py +++ b/tests/test_base_payment.py @@ -15,8 +15,8 @@ # along with this program. If not, see . from datetime import date, datetime, timedelta - from unittest import mock + import pytest import eopayment diff --git a/tests/test_dummy.py b/tests/test_dummy.py index ad88320..f70a402 100644 --- a/tests/test_dummy.py +++ b/tests/test_dummy.py @@ -14,11 +14,12 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from six.moves.urllib.parse import urlparse, parse_qs import datetime -import eopayment import pytest +from six.moves.urllib.parse import parse_qs, urlparse + +import eopayment @pytest.fixture diff --git a/tests/test_keyware.py b/tests/test_keyware.py index 276e62d..8ddb232 100644 --- a/tests/test_keyware.py +++ b/tests/test_keyware.py @@ -18,7 +18,7 @@ import json import pytest import requests -from httmock import response, urlmatch, HTTMock, with_httmock, all_requests, remember_called +from httmock import HTTMock, all_requests, remember_called, response, urlmatch, with_httmock import eopayment from eopayment.keyware import Payment diff --git a/tests/test_mollie.py b/tests/test_mollie.py index fb9e41c..38e629e 100644 --- a/tests/test_mollie.py +++ b/tests/test_mollie.py @@ -16,12 +16,12 @@ import json +import pytest import requests +from httmock import remember_called, response, urlmatch, with_httmock import eopayment -import pytest from eopayment.mollie import Payment -from httmock import remember_called, response, urlmatch, with_httmock WEBHOOK_URL = 'https://callback.example.com' RETURN_URL = 'https://return.example.com' diff --git a/tests/test_paybox.py b/tests/test_paybox.py index 98ef74f..b9092b0 100644 --- a/tests/test_paybox.py +++ b/tests/test_paybox.py @@ -15,19 +15,17 @@ # along with this program. If not, see . -import codecs -from unittest import TestCase -from decimal import Decimal import base64 -from unittest import mock -from six.moves.urllib import parse as urllib +import codecs +from decimal import Decimal +from unittest import TestCase, mock from xml.etree import ElementTree as ET import pytest +from six.moves.urllib import parse as urllib -import eopayment.paybox as paybox import eopayment - +import eopayment.paybox as paybox BACKEND_PARAMS = { 'platform': 'test', diff --git a/tests/test_payfip_ws.py b/tests/test_payfip_ws.py index 87c29f0..d141849 100644 --- a/tests/test_payfip_ws.py +++ b/tests/test_payfip_ws.py @@ -18,20 +18,17 @@ import datetime import json -import lxml.etree as ET from unittest import mock -import pytz - import httmock +import lxml.etree as ET import pytest - +import pytz from zeep.plugins import HistoryPlugin import eopayment from eopayment.payfip_ws import PayFiP, PayFiPError, normalize_objet - NUMCLI = '090909' NOTIF_URL = 'https://notif.payfip.example.com/' REDIRECT_URL = 'https://redirect.payfip.example.com/' diff --git a/tests/test_saga.py b/tests/test_saga.py index 055d150..adc53ba 100644 --- a/tests/test_saga.py +++ b/tests/test_saga.py @@ -19,7 +19,6 @@ import json import pytest - import zeep.transports import eopayment diff --git a/tests/test_sips2.py b/tests/test_sips2.py index f5386bd..f57f43f 100644 --- a/tests/test_sips2.py +++ b/tests/test_sips2.py @@ -15,9 +15,10 @@ # along with this program. If not, see . -import eopayment import pytest +import eopayment + def test_build_request(): backend = eopayment.Payment('sips2', {}) diff --git a/tests/test_systempayv2.py b/tests/test_systempayv2.py index af1d46a..fb3d986 100644 --- a/tests/test_systempayv2.py +++ b/tests/test_systempayv2.py @@ -21,8 +21,8 @@ import pytest from six.moves.urllib import parse as urlparse import eopayment -from eopayment.systempayv2 import Payment, VADS_CUST_FIRST_NAME, VADS_CUST_LAST_NAME, PAID from eopayment import ResponseError +from eopayment.systempayv2 import PAID, VADS_CUST_FIRST_NAME, VADS_CUST_LAST_NAME, Payment PARAMS = { 'secret_test': '1122334455667788', diff --git a/tests/test_tipi.py b/tests/test_tipi.py index a92d92e..6c483e1 100644 --- a/tests/test_tipi.py +++ b/tests/test_tipi.py @@ -16,13 +16,13 @@ import datetime from decimal import Decimal -from six.moves.urllib.parse import urlparse, parse_qs +import pytest import pytz +from six.moves.urllib.parse import parse_qs, urlparse import eopayment import eopayment.tipi -import pytest def test_tipi():