summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2021-06-04 10:54:24 (GMT)
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2021-06-11 04:37:17 (GMT)
commitdb914636879c1f428a04105f9258722e89ef1da1 (patch)
treec0a9e74173af09b4633b1f4d29dc26fc5eb1546f
parent8406ab8be887d0cbcf3c2e9b6e2784a5c93e25a5 (diff)
downloadeopayment-1.70.zip
eopayment-1.70.tar.gz
eopayment-1.70.tar.bz2
tipi/payfip_ws: remove URL backend parameters (#46688)v1.70
-rw-r--r--eopayment/payfip_ws.py43
-rw-r--r--eopayment/tipi.py10
2 files changed, 13 insertions, 40 deletions
diff --git a/eopayment/payfip_ws.py b/eopayment/payfip_ws.py
index 984e7dc..1503462 100644
--- a/eopayment/payfip_ws.py
+++ b/eopayment/payfip_ws.py
@@ -38,10 +38,13 @@ from .common import (PaymentCommon, PaymentResponse, URL, PAID, DENIED,
CANCELLED, ERROR, ResponseError, PaymentException,
WAITING, EXPIRED, force_text, _)
+# 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
+# where the XSD files are resolvable. To not depend too much on those files, we
+# provide copy in eopayment and we patch them to fix the service binding URL
+# and the path of XSD files. The PayFiP development team is full of morons.
WSDL_URL = 'https://www.payfip.gouv.fr/tpa/services/mas_securite/contrat_paiement_securise/PaiementSecuriseService?wsdl' # noqa: E501
-
SERVICE_URL = 'https://www.payfip.gouv.fr/tpa/services/securite' # noqa: E501
-
PAYMENT_URL = 'https://www.payfip.gouv.fr/tpa/paiementws.web'
REFDET_RE = re.compile(r'^[A-Za-z0-9]{1,30}$')
@@ -86,7 +89,11 @@ class PayFiPError(PaymentException):
class PayFiP(object):
'''Encapsulate SOAP web-services of PayFiP'''
- def __init__(self, wsdl_url=None, service_url=None, zeep_client_kwargs=None):
+ def __init__(self, wsdl_url=None, service_url=None, zeep_client_kwargs=None, use_local_wsdl=True):
+ # use cached WSDL
+ if (not wsdl_url or (wsdl_url == WSDL_URL)) and use_local_wsdl:
+ base_path = os.path.join(os.path.dirname(__file__), 'resource', 'PaiementSecuriseService.wsdl')
+ wsdl_url = 'file://%s' % base_path
self.wsdl_url = wsdl_url
self.service_url = service_url
self.zeep_client_kwargs = zeep_client_kwargs
@@ -170,27 +177,6 @@ class Payment(PaymentCommon):
'required': True,
},
{
- 'name': 'service_url',
- 'default': SERVICE_URL,
- 'caption': _(u'PayFIP WS service URL'),
- 'help_text': _(u'do not modify if you do not know'),
- 'validation': lambda x: x.startswith('http'),
- },
- {
- 'name': 'wsdl_url',
- 'default': WSDL_URL,
- 'caption': _(u'PayFIP WS WSDL URL'),
- 'help_text': _(u'do not modify if you do not know'),
- 'validation': lambda x: x.startswith('http'),
- },
- {
- 'name': 'payment_url',
- 'default': PAYMENT_URL,
- 'caption': _(u'PayFiP payment URL'),
- 'help_text': _(u'do not modify if you do not know'),
- 'validation': lambda x: x.startswith('http'),
- },
- {
'name': 'saisie',
'caption': _('Payment type'),
'default': 'T',
@@ -217,12 +203,7 @@ class Payment(PaymentCommon):
def __init__(self, *args, **kwargs):
super(Payment, self).__init__(*args, **kwargs)
- wsdl_url = self.wsdl_url
- # use cached WSDL
- if wsdl_url == WSDL_URL:
- base_path = os.path.join(os.path.dirname(__file__), 'resource', 'PaiementSecuriseService.wsdl')
- wsdl_url = 'file://%s' % base_path
- self.payfip = PayFiP(wsdl_url=wsdl_url, service_url=self.service_url)
+ self.payfip = PayFiP()
def _generate_refdet(self):
return '%s%010d' % (isonow(), random.randint(1, 1000000000))
@@ -280,7 +261,7 @@ class Payment(PaymentCommon):
url_notification=urlnotif,
url_redirect=urlredirect)
- return str(idop), URL, self.payment_url + '?idop=%s' % idop
+ return str(idop), URL, PAYMENT_URL + '?idop=%s' % idop
def payment_status(self, transaction_id, transaction_date=None, **kwargs):
# idop are valid for 15 minutes after their generation
diff --git a/eopayment/tipi.py b/eopayment/tipi.py
index c78010c..c734db2 100644
--- a/eopayment/tipi.py
+++ b/eopayment/tipi.py
@@ -50,14 +50,6 @@ class Payment(PaymentCommon):
'required': True,
},
{
- 'name': 'service_url',
- 'default': TIPI_URL,
- 'caption': _(u'TIPI service URL'),
- 'help_text': _(u'do not modify if you do not know'),
- 'validation': lambda x: x.startswith('http'),
- 'required': True,
- },
- {
'name': 'normal_return_url',
'caption': _('Normal return URL (unused by TIPI)'),
'required': False,
@@ -157,7 +149,7 @@ class Payment(PaymentCommon):
params['objet'] = objet
if automatic_return_url:
params['urlcl'] = automatic_return_url
- url = '%s?%s' % (self.service_url, urlencode(params))
+ url = '%s?%s' % (TIPI_URL, urlencode(params))
return transaction_id, URL, url
def response(self, query_string, **kwargs):