0001-add-support-for-translation-when-used-as-a-django-ap.patch
debian/control | ||
---|---|---|
5 | 5 |
Build-Depends: debhelper (>= 9), |
6 | 6 |
python-all (>= 2.6), |
7 | 7 |
python-crypto, |
8 |
python-django-common, |
|
8 | 9 |
python-requests, |
9 | 10 |
python-setuptools (>= 0.6b3), |
10 | 11 |
python-six, |
eopayment/common.py | ||
---|---|---|
17 | 17 |
import os.path |
18 | 18 |
import os |
19 | 19 |
import random |
20 |
import sys |
|
20 | 21 |
import logging |
21 | 22 |
from datetime import date |
22 | 23 |
from decimal import ROUND_DOWN, Decimal |
... | ... | |
28 | 29 |
else: |
29 | 30 |
import cgi |
30 | 31 | |
32 | ||
33 |
from gettext import gettext as _ |
|
34 | ||
35 |
try: |
|
36 |
if 'django' in sys.modules: |
|
37 |
from django.utils.translation import ugettext_lazy as _ |
|
38 |
except ImportError: |
|
39 |
pass |
|
40 | ||
41 | ||
31 | 42 |
__all__ = ['PaymentCommon', 'URL', 'HTML', 'RANDOM', 'RECEIVED', 'ACCEPTED', |
32 | 43 |
'PAID', 'ERROR', 'WAITING'] |
33 | 44 |
eopayment/dummy.py | ||
---|---|---|
26 | 26 |
ResponseError, |
27 | 27 |
URL, |
28 | 28 |
PAID, ERROR, WAITING, |
29 |
force_text |
|
29 |
force_text, |
|
30 |
_ |
|
30 | 31 |
) |
31 | 32 | |
32 | 33 |
__all__ = ['Payment'] |
33 | 34 | |
34 | 35 | |
35 |
def N_(message): |
|
36 |
return message |
|
37 | ||
38 | ||
39 | 36 |
SERVICE_URL = 'http://dummy-payment.demo.entrouvert.com/' |
40 | 37 |
LOGGER = logging.getLogger(__name__) |
41 | 38 | |
... | ... | |
65 | 62 |
'parameters': [ |
66 | 63 |
{ |
67 | 64 |
'name': 'normal_return_url', |
68 |
'caption': N_('Normal return URL'),
|
|
65 |
'caption': _('Normal return URL'), |
|
69 | 66 |
'default': '', |
70 | 67 |
'required': True, |
71 | 68 |
}, |
72 | 69 |
{ |
73 | 70 |
'name': 'automatic_return_url', |
74 |
'caption': N_('Automatic return URL'),
|
|
71 |
'caption': _('Automatic return URL'), |
|
75 | 72 |
'required': False, |
76 | 73 |
}, |
77 | 74 |
{ |
78 | 75 |
'name': 'dummy_service_url', |
79 |
'caption': 'URL of the dummy payment service',
|
|
76 |
'caption': _('URL of the dummy payment service'),
|
|
80 | 77 |
'default': SERVICE_URL, |
81 | 78 |
'type': str, |
82 | 79 |
}, |
83 | 80 |
{ |
84 | 81 |
'name': 'origin', |
85 |
'caption': 'name of the requesting service, ' |
|
86 |
'to present in the user interface', |
|
82 |
'caption': _('name of the requesting service, '
|
|
83 |
'to present in the user interface'),
|
|
87 | 84 |
'type': str, |
88 | 85 |
'default': 'origin', |
89 | 86 |
}, |
90 | 87 |
{ |
91 | 88 |
'name': 'consider_all_response_signed', |
92 |
'caption': ( |
|
89 |
'caption': _(
|
|
93 | 90 |
'All response will be considered as signed ' |
94 | 91 |
'(to test payment locally for example, as you ' |
95 | 92 |
'cannot received the signed callback)' |
... | ... | |
115 | 112 |
}, |
116 | 113 |
{ |
117 | 114 |
'name': 'direct_notification_url', |
118 |
'caption': 'direct notification url (replaced by automatic_return_url)',
|
|
115 |
'caption': _('direct notification url (replaced by automatic_return_url)'),
|
|
119 | 116 |
'type': str, |
120 | 117 |
'deprecated': True, |
121 | 118 |
}, |
122 | 119 |
{ |
123 | 120 |
'name': 'next_url (replaced by normal_return_url)', |
124 |
'caption': 'Return URL for the user',
|
|
121 |
'caption': _('Return URL for the user'),
|
|
125 | 122 |
'type': str, |
126 | 123 |
'deprecated': True, |
127 | 124 |
}, |
eopayment/keyware.py | ||
---|---|---|
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 |
from gettext import gettext as _ |
|
18 | ||
19 | 17 |
import requests |
20 | 18 |
from six.moves.urllib.parse import parse_qs, urljoin |
21 | 19 | |
22 | 20 |
from .common import (CANCELLED, ERROR, PAID, URL, WAITING, PaymentCommon, |
23 |
PaymentException, PaymentResponse, ResponseError) |
|
21 |
PaymentException, PaymentResponse, ResponseError, _)
|
|
24 | 22 | |
25 | 23 |
__all__ = ['Payment'] |
26 | 24 | |
... | ... | |
30 | 28 |
service_url = 'https://api.online.emspay.eu/v1/' |
31 | 29 | |
32 | 30 |
description = { |
33 |
'caption': 'Keyware payment backend',
|
|
31 |
'caption': _('Keyware payment backend'),
|
|
34 | 32 |
'parameters': [ |
35 | 33 |
{ |
36 | 34 |
'name': 'normal_return_url', |
eopayment/mollie.py | ||
---|---|---|
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 |
from gettext import gettext as _
|
|
17 |
from .common import _
|
|
18 | 18 | |
19 | 19 |
import requests |
20 | 20 |
from six.moves.urllib.parse import parse_qs, urljoin |
eopayment/ogone.py | ||
---|---|---|
24 | 24 |
from .common import ( |
25 | 25 |
PaymentCommon, PaymentResponse, FORM, CANCELLED, PAID, |
26 | 26 |
ERROR, Form, DENIED, ACCEPTED, ORDERID_TRANSACTION_SEPARATOR, |
27 |
WAITING, ResponseError, force_byte, force_text |
|
27 |
WAITING, ResponseError, force_byte, force_text, _
|
|
28 | 28 |
) |
29 | 29 | |
30 | 30 | |
31 |
def N_(message): |
|
32 |
return message |
|
33 | ||
34 | 31 |
ENVIRONMENT_TEST = 'TEST' |
35 | 32 |
ENVIRONMENT_TEST_URL = 'https://secure.ogone.com/ncol/test/orderstandard.asp' |
36 | 33 |
ENVIRONMENT_PROD = 'PROD' |
... | ... | |
434 | 431 |
class Payment(PaymentCommon): |
435 | 432 |
# See http://payment-services.ingenico.com/fr/fr/ogone/support/guides/integration%20guides/e-commerce |
436 | 433 |
description = { |
437 |
'caption': N_('Système de paiement Ogone / Ingenico Payment System e-Commerce'),
|
|
434 |
'caption': _('Ogone / Ingenico Payment System e-Commerce'),
|
|
438 | 435 |
'parameters': [ |
439 | 436 |
{ |
440 | 437 |
'name': 'normal_return_url', |
441 |
'caption': N_('Normal return URL'),
|
|
438 |
'caption': _('Normal return URL'), |
|
442 | 439 |
'default': '', |
443 | 440 |
'required': True, |
444 | 441 |
}, |
445 | 442 |
{ |
446 | 443 |
'name': 'automatic_return_url', |
447 |
'caption': N_('Automatic return URL (ignored, must be set in Ogone backoffice)'),
|
|
444 |
'caption': _('Automatic return URL (ignored, must be set in Ogone backoffice)'), |
|
448 | 445 |
'required': False, |
449 | 446 |
}, |
450 | 447 |
{ |
451 | 448 |
'name': 'environment', |
452 | 449 |
'default': ENVIRONMENT_TEST, |
453 |
'caption': N_(u'Environnement'),
|
|
450 |
'caption': 'Environnement',
|
|
454 | 451 |
'choices': ENVIRONMENT, |
455 | 452 |
}, |
456 | 453 |
{ |
457 | 454 |
'name': 'pspid', |
458 |
'caption': N_(u"Nom d'affiliation dans le système"),
|
|
455 |
'caption': "Nom d'affiliation dans le système",
|
|
459 | 456 |
'required': True, |
460 | 457 |
}, |
461 | 458 |
{ |
462 | 459 |
'name': 'language', |
463 |
'caption': N_(u'Langage'),
|
|
460 |
'caption': _(u'Language'),
|
|
464 | 461 |
'default': 'fr_FR', |
465 |
'choices': (('fr_FR', N_('français')),),
|
|
462 |
'choices': (('fr_FR', 'français'),),
|
|
466 | 463 |
}, |
467 | 464 |
{ |
468 | 465 |
'name': 'hash_algorithm', |
469 |
'caption': N_(u'Algorithme de hachage'),
|
|
466 |
'caption': 'Algorithme de hachage',
|
|
470 | 467 |
'default': 'sha1', |
471 | 468 |
}, |
472 | 469 |
{ |
473 | 470 |
'name': 'sha_in', |
474 |
'caption': N_(u'Clé SHA-IN'),
|
|
471 |
'caption': 'Clé SHA-IN',
|
|
475 | 472 |
'required': True, |
476 | 473 |
}, |
477 | 474 |
{ |
478 | 475 |
'name': 'sha_out', |
479 |
'caption': N_(u'Clé SHA-OUT'),
|
|
476 |
'caption': 'Clé SHA-OUT',
|
|
480 | 477 |
'required': True, |
481 | 478 |
}, |
482 | 479 |
{ |
483 | 480 |
'name': 'currency', |
484 |
'caption': N_(u'Monnaie'),
|
|
481 |
'caption': 'Monnaie',
|
|
485 | 482 |
'default': 'EUR', |
486 | 483 |
'choices': ('EUR',), |
487 | 484 |
}, |
eopayment/paybox.py | ||
---|---|---|
36 | 36 |
from six.moves.urllib import parse as urllib |
37 | 37 | |
38 | 38 |
import base64 |
39 |
from gettext import gettext as _ |
|
40 | 39 |
import warnings |
41 | 40 | |
42 | 41 |
from .common import (PaymentCommon, PaymentResponse, FORM, PAID, CANCELLED, |
43 | 42 |
DENIED, ERROR, Form, ResponseError, force_text, |
44 |
force_byte) |
|
43 |
force_byte, _)
|
|
45 | 44 |
from . import cb |
46 | 45 | |
47 | 46 |
__all__ = ['sign', 'Payment'] |
... | ... | |
214 | 213 |
}, |
215 | 214 |
{ |
216 | 215 |
'name': 'platform', |
217 |
'caption': _('Plateforme cible'),
|
|
216 |
'caption': 'Plateforme cible',
|
|
218 | 217 |
'default': 'test', |
219 | 218 |
'choices': ( |
220 | 219 |
('test', 'Test'), |
... | ... | |
224 | 223 |
}, |
225 | 224 |
{ |
226 | 225 |
'name': 'site', |
227 |
'caption': _('Numéro de site'),
|
|
226 |
'caption': 'Numéro de site',
|
|
228 | 227 |
'required': True, |
229 | 228 |
'validation': lambda x: isinstance(x, six.string_types) |
230 | 229 |
and x.isdigit() and len(x) == 7, |
... | ... | |
237 | 236 |
}, |
238 | 237 |
{ |
239 | 238 |
'name': 'rang', |
240 |
'caption': _('Numéro de rang'),
|
|
239 |
'caption': 'Numéro de rang',
|
|
241 | 240 |
'required': True, |
242 | 241 |
'validation': lambda x: isinstance(x, six.string_types) |
243 | 242 |
and x.isdigit() and len(x) == 2, |
244 | 243 |
}, |
245 | 244 |
{ |
246 | 245 |
'name': 'identifiant', |
247 |
'caption': _('Identifiant'),
|
|
246 |
'caption': 'Identifiant',
|
|
248 | 247 |
'required': True, |
249 | 248 |
'validation': lambda x: isinstance(x, six.string_types) |
250 | 249 |
and x.isdigit() and (0 < len(x) < 10), |
251 | 250 |
}, |
252 | 251 |
{ |
253 | 252 |
'name': 'shared_secret', |
254 |
'caption': _('Secret partagé (clé HMAC)'),
|
|
253 |
'caption': 'Secret partagé (clé HMAC)',
|
|
255 | 254 |
'validation': lambda x: isinstance(x, str) |
256 | 255 |
and all(a.lower() in '0123456789abcdef' for a in x), |
257 | 256 |
'required': True, |
258 | 257 |
}, |
259 | 258 |
{ |
260 | 259 |
'name': 'devise', |
261 |
'caption': _('Devise'),
|
|
260 |
'caption': 'Devise',
|
|
262 | 261 |
'default': '978', |
263 | 262 |
'choices': ( |
264 | 263 |
('978', 'Euro'), |
... | ... | |
271 | 270 |
}, |
272 | 271 |
{ |
273 | 272 |
'name': 'capture_day', |
274 |
'caption': _('Nombre de jours pour un paiement différé'),
|
|
273 |
'caption': 'Nombre de jours pour un paiement différé',
|
|
275 | 274 |
'default': '', |
276 | 275 |
'required': False, |
277 | 276 |
'validation': lambda x: isinstance(x, six.string_types) |
eopayment/payfip_ws.py | ||
---|---|---|
25 | 25 |
import unicodedata |
26 | 26 |
import xml.etree.ElementTree as ET |
27 | 27 | |
28 |
from gettext import gettext as _ |
|
29 | ||
30 | 28 |
import pytz |
31 | 29 | |
32 | 30 |
import six |
... | ... | |
38 | 36 |
from .systempayv2 import isonow |
39 | 37 |
from .common import (PaymentCommon, PaymentResponse, URL, PAID, DENIED, |
40 | 38 |
CANCELLED, ERROR, ResponseError, PaymentException, |
41 |
WAITING, EXPIRED, force_text) |
|
39 |
WAITING, EXPIRED, force_text, _)
|
|
42 | 40 | |
43 | 41 |
WSDL_URL = 'https://www.tipi.budget.gouv.fr/tpa/services/mas_securite/contrat_paiement_securise/PaiementSecuriseService?wsdl' # noqa: E501 |
44 | 42 |
eopayment/sips2.py | ||
---|---|---|
16 | 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | |
18 | 18 |
import datetime |
19 |
from gettext import gettext as _ |
|
20 | 19 |
import collections |
21 | 20 |
import hashlib |
22 | 21 |
import hmac |
... | ... | |
31 | 30 |
import pytz |
32 | 31 | |
33 | 32 |
from .common import (PaymentCommon, FORM, Form, PaymentResponse, PAID, ERROR, |
34 |
CANCELED, ResponseError, force_text) |
|
33 |
CANCELED, ResponseError, force_text, _)
|
|
35 | 34 | |
36 | 35 |
__all__ = ['Payment'] |
37 | 36 |
eopayment/systempayv2.py | ||
---|---|---|
26 | 26 |
import six |
27 | 27 |
from six.moves.urllib import parse as urlparse |
28 | 28 |
import warnings |
29 |
from gettext import gettext as _ |
|
30 | 29 | |
31 | 30 |
from .common import (PaymentCommon, PaymentResponse, PAID, DENIED, CANCELLED, |
32 |
ERROR, FORM, Form, ResponseError, force_text, force_byte) |
|
31 |
ERROR, FORM, Form, ResponseError, force_text, force_byte, _)
|
|
33 | 32 |
from .cb import translate_cb_error_code |
34 | 33 | |
35 | 34 |
__all__ = ['Payment'] |
... | ... | |
135 | 134 |
Parameter('vads_language', 'a', 12, length=2, default='fr'), |
136 | 135 |
Parameter('vads_order_id', 'an-', 13, max_length=32), |
137 | 136 |
Parameter('vads_order_info', 'an', 14, max_length=255, |
138 |
description=_(u"Complément d'information 1")),
|
|
137 |
description="Complément d'information 1"),
|
|
139 | 138 |
Parameter('vads_order_info2', 'an', 14, max_length=255, |
140 |
description=_(u"Complément d'information 2")),
|
|
139 |
description="Complément d'information 2"),
|
|
141 | 140 |
Parameter('vads_order_info3', 'an', 14, max_length=255, |
142 |
description=_(u"Complément d'information 3")),
|
|
141 |
description="Complément d'information 3"),
|
|
143 | 142 |
Parameter('vads_page_action', None, 46, needed=True, default='PAYMENT', |
144 | 143 |
choices=('PAYMENT',)), |
145 | 144 |
Parameter('vads_payment_cards', 'an;', 8, max_length=127, default='', |
146 |
description=_(u'Liste des cartes de paiement acceptées'),
|
|
147 |
help_text=_(u'vide ou des valeurs sépareés par un point-virgule '
|
|
148 |
'parmi AMEX, AURORE-MULTI, BUYSTER, CB, COFINOGA, '
|
|
149 |
'E-CARTEBLEUE, MASTERCARD, JCB, MAESTRO, ONEY, '
|
|
150 |
'ONEY_SANDBOX, PAYPAL, PAYPAL_SB, PAYSAFECARD, '
|
|
151 |
'VISA')),
|
|
145 |
description='Liste des cartes de paiement acceptées',
|
|
146 |
help_text='vide ou des valeurs sépareés par un point-virgule ' |
|
147 |
'parmi AMEX, AURORE-MULTI, BUYSTER, CB, COFINOGA, ' |
|
148 |
'E-CARTEBLEUE, MASTERCARD, JCB, MAESTRO, ONEY, ' |
|
149 |
'ONEY_SANDBOX, PAYPAL, PAYPAL_SB, PAYSAFECARD, ' |
|
150 |
'VISA'),
|
|
152 | 151 |
# must be SINGLE or MULTI with parameters |
153 | 152 |
Parameter('vads_payment_config', '', 7, default='SINGLE', |
154 | 153 |
choices=('SINGLE', 'MULTI'), needed=True), |
... | ... | |
156 | 155 |
choices=('', 'NONE', 'POST', 'GET')), |
157 | 156 |
Parameter('signature', 'an', None, length=40), |
158 | 157 |
Parameter('vads_site_id', 'n', 2, length=8, needed=True, |
159 |
description=_(u'Identifiant de la boutique')),
|
|
158 |
description='Identifiant de la boutique'),
|
|
160 | 159 |
Parameter('vads_theme_config', 'ans', 32, max_length=255), |
161 | 160 |
Parameter(VADS_TRANS_DATE, 'n', 4, length=14, needed=True, |
162 | 161 |
default=isonow), |
... | ... | |
244 | 243 |
}, |
245 | 244 |
{'name': 'service_url', |
246 | 245 |
'default': service_url, |
247 |
'caption': _(u'URL du service de paiment'),
|
|
248 |
'help_text': _(u'ne pas modifier si vous ne savez pas'),
|
|
246 |
'caption': 'URL du service de paiment',
|
|
247 |
'help_text': 'ne pas modifier si vous ne savez pas',
|
|
249 | 248 |
'validation': lambda x: x.startswith('http'), |
250 | 249 |
'required': True, }, |
251 | 250 |
{'name': 'secret_test', |
252 |
'caption': _(u'Secret pour la configuration de TEST'),
|
|
251 |
'caption': 'Secret pour la configuration de TEST',
|
|
253 | 252 |
'validation': lambda value: str.isalnum(value), |
254 | 253 |
'required': True, }, |
255 | 254 |
{'name': 'secret_production', |
256 |
'caption': _(u'Secret pour la configuration de PRODUCTION'),
|
|
255 |
'caption': 'Secret pour la configuration de PRODUCTION',
|
|
257 | 256 |
'validation': lambda value: str.isalnum(value), }, |
258 | 257 |
{'name': 'signature_algo', |
259 |
'caption': _(u'Algorithme de signature'),
|
|
258 |
'caption': 'Algorithme de signature',
|
|
260 | 259 |
'default': 'sha1', |
261 | 260 |
'choices': ( |
262 | 261 |
('sha1', 'SHA-1'), |
eopayment/tipi.py | ||
---|---|---|
21 | 21 |
import pytz |
22 | 22 | |
23 | 23 |
from .common import (PaymentCommon, PaymentResponse, URL, PAID, DENIED, |
24 |
CANCELLED, ERROR, ResponseError) |
|
24 |
CANCELLED, ERROR, ResponseError, _)
|
|
25 | 25 |
from six.moves.urllib.parse import urlencode, parse_qs |
26 | 26 | |
27 |
from gettext import gettext as _ |
|
28 | 27 |
import logging |
29 | 28 |
import warnings |
30 | 29 |
setup.py | ||
---|---|---|
6 | 6 | |
7 | 7 |
import io |
8 | 8 |
import subprocess |
9 | ||
9 | 10 |
import distutils |
10 | 11 |
import distutils.core |
12 |
from distutils.command.build import build as _build |
|
13 |
from distutils.cmd import Command |
|
14 |
from distutils.spawn import find_executable |
|
15 | ||
11 | 16 |
import setuptools |
12 | 17 |
from setuptools.command.sdist import sdist |
18 |
from setuptools.command.install_lib import install_lib as _install_lib |
|
19 | ||
13 | 20 |
from glob import glob |
14 | 21 |
from os.path import splitext, basename, join as pjoin |
15 | 22 |
import os |
... | ... | |
91 | 98 | |
92 | 99 |
return '0.0.0' |
93 | 100 | |
101 | ||
102 |
class compile_translations(Command): |
|
103 |
description = 'compile message catalogs to MO files via django compilemessages' |
|
104 |
user_options = [] |
|
105 | ||
106 |
def initialize_options(self): |
|
107 |
pass |
|
108 | ||
109 |
def finalize_options(self): |
|
110 |
pass |
|
111 | ||
112 |
def run(self): |
|
113 |
django_admin = find_executable('django-admin') |
|
114 |
if django_admin: |
|
115 |
subprocess.check_call([django_admin, 'compilemessages']) |
|
116 | ||
117 | ||
118 |
class build(_build): |
|
119 |
sub_commands = [('compile_translations', None)] + _build.sub_commands |
|
120 | ||
121 | ||
122 |
class install_lib(_install_lib): |
|
123 |
def run(self): |
|
124 |
self.run_command('compile_translations') |
|
125 |
_install_lib.run(self) |
|
126 | ||
127 | ||
94 | 128 |
setuptools.setup( |
95 | 129 |
name='eopayment', |
96 | 130 |
version=get_version(), |
... | ... | |
128 | 162 |
'zeep >= 2.5', |
129 | 163 |
], |
130 | 164 |
cmdclass={ |
165 |
'build': build, |
|
166 |
'compile_translations': compile_translations, |
|
167 |
'install_lib': install_lib, |
|
131 | 168 |
'sdist': eo_sdist, |
132 | 169 |
} |
133 | 170 |
) |
134 |
- |