38 |
38 |
CANCELLED, ERROR, ResponseError, PaymentException,
|
39 |
39 |
WAITING, EXPIRED, force_text, _)
|
40 |
40 |
|
|
41 |
# The URL of the WSDL published in the documentation is still wrong, it
|
|
42 |
# references XSD files which are not resolvable :/ we must use this other URL
|
|
43 |
# where the XSD files are resolvable. To not depend too much on those files, we
|
|
44 |
# provide copy in eopayment and we patch them to fix the service binding URL
|
|
45 |
# and the path of XSD files. The PayFiP development team is full of morons.
|
41 |
46 |
WSDL_URL = 'https://www.payfip.gouv.fr/tpa/services/mas_securite/contrat_paiement_securise/PaiementSecuriseService?wsdl' # noqa: E501
|
42 |
|
|
43 |
47 |
SERVICE_URL = 'https://www.payfip.gouv.fr/tpa/services/securite' # noqa: E501
|
44 |
|
|
45 |
48 |
PAYMENT_URL = 'https://www.payfip.gouv.fr/tpa/paiementws.web'
|
46 |
49 |
|
47 |
50 |
REFDET_RE = re.compile(r'^[A-Za-z0-9]{1,30}$')
|
... | ... | |
86 |
89 |
class PayFiP(object):
|
87 |
90 |
'''Encapsulate SOAP web-services of PayFiP'''
|
88 |
91 |
|
89 |
|
def __init__(self, wsdl_url=None, service_url=None, zeep_client_kwargs=None):
|
|
92 |
def __init__(self, wsdl_url=None, service_url=None, zeep_client_kwargs=None, use_local_wsdl=True):
|
|
93 |
# use cached WSDL
|
|
94 |
if (not wsdl_url or (wsdl_url == WSDL_URL)) and use_local_wsdl:
|
|
95 |
base_path = os.path.join(os.path.dirname(__file__), 'resource', 'PaiementSecuriseService.wsdl')
|
|
96 |
wsdl_url = 'file://%s' % base_path
|
90 |
97 |
self.wsdl_url = wsdl_url
|
91 |
98 |
self.service_url = service_url
|
92 |
99 |
self.zeep_client_kwargs = zeep_client_kwargs
|
... | ... | |
169 |
176 |
'validation': lambda s: str.isdigit(s) and len(s) == 6,
|
170 |
177 |
'required': True,
|
171 |
178 |
},
|
172 |
|
{
|
173 |
|
'name': 'service_url',
|
174 |
|
'default': SERVICE_URL,
|
175 |
|
'caption': _(u'PayFIP WS service URL'),
|
176 |
|
'help_text': _(u'do not modify if you do not know'),
|
177 |
|
'validation': lambda x: x.startswith('http'),
|
178 |
|
},
|
179 |
|
{
|
180 |
|
'name': 'wsdl_url',
|
181 |
|
'default': WSDL_URL,
|
182 |
|
'caption': _(u'PayFIP WS WSDL URL'),
|
183 |
|
'help_text': _(u'do not modify if you do not know'),
|
184 |
|
'validation': lambda x: x.startswith('http'),
|
185 |
|
},
|
186 |
|
{
|
187 |
|
'name': 'payment_url',
|
188 |
|
'default': PAYMENT_URL,
|
189 |
|
'caption': _(u'PayFiP payment URL'),
|
190 |
|
'help_text': _(u'do not modify if you do not know'),
|
191 |
|
'validation': lambda x: x.startswith('http'),
|
192 |
|
},
|
193 |
179 |
{
|
194 |
180 |
'name': 'saisie',
|
195 |
181 |
'caption': _('Payment type'),
|
... | ... | |
217 |
203 |
|
218 |
204 |
def __init__(self, *args, **kwargs):
|
219 |
205 |
super(Payment, self).__init__(*args, **kwargs)
|
220 |
|
wsdl_url = self.wsdl_url
|
221 |
|
# use cached WSDL
|
222 |
|
if wsdl_url == WSDL_URL:
|
223 |
|
base_path = os.path.join(os.path.dirname(__file__), 'resource', 'PaiementSecuriseService.wsdl')
|
224 |
|
wsdl_url = 'file://%s' % base_path
|
225 |
|
self.payfip = PayFiP(wsdl_url=wsdl_url, service_url=self.service_url)
|
|
206 |
self.payfip = PayFiP()
|
226 |
207 |
|
227 |
208 |
def _generate_refdet(self):
|
228 |
209 |
return '%s%010d' % (isonow(), random.randint(1, 1000000000))
|
... | ... | |
280 |
261 |
url_notification=urlnotif,
|
281 |
262 |
url_redirect=urlredirect)
|
282 |
263 |
|
283 |
|
return str(idop), URL, self.payment_url + '?idop=%s' % idop
|
|
264 |
return str(idop), URL, PAYMENT_URL + '?idop=%s' % idop
|
284 |
265 |
|
285 |
266 |
def payment_status(self, transaction_id, transaction_date=None, **kwargs):
|
286 |
267 |
# idop are valid for 15 minutes after their generation
|