tipi/payfip_ws: remove URL backend parameters (#46688)

This commit is contained in:
Benjamin Dauvergne 2021-06-04 12:54:24 +02:00
parent 8406ab8be8
commit db91463687
2 changed files with 13 additions and 40 deletions

View File

@ -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
@ -169,27 +176,6 @@ class Payment(PaymentCommon):
'validation': lambda s: str.isdigit(s) and len(s) == 6,
'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'),
@ -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

View File

@ -49,14 +49,6 @@ class Payment(PaymentCommon):
'validation': lambda s: str.isdigit(s) and (0 < int(s) < 1000000),
'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)'),
@ -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):