0001-add-a-message-in-ResponseErrors-25773.patch
eopayment/dummy.py | ||
---|---|---|
120 | 120 |
def response(self, query_string, logger=LOGGER, **kwargs): |
121 | 121 |
form = parse_qs(force_text(query_string)) |
122 | 122 |
if not 'transaction_id' in form: |
123 |
raise ResponseError() |
|
123 |
raise ResponseError('missing transaction_id')
|
|
124 | 124 |
transaction_id = form.get('transaction_id',[''])[0] |
125 | 125 |
form[self.BANK_ID] = transaction_id |
126 | 126 |
eopayment/ogone.py | ||
---|---|---|
540 | 540 |
params = urlparse.parse_qs(query_string, True) |
541 | 541 |
params = dict((key.upper(), params[key][0]) for key in params) |
542 | 542 |
if not set(params) >= set(['ORDERID', 'PAYID', 'STATUS', 'NCERROR']): |
543 |
raise ResponseError() |
|
543 |
raise ResponseError('missing ORDERID, PAYID, STATUS or NCERROR')
|
|
544 | 544 | |
545 | 545 |
# uniformize iso-8859-1 encoded values |
546 | 546 |
for key in params: |
eopayment/paybox.py | ||
---|---|---|
264 | 264 |
def response(self, query_string, callback=False, **kwargs): |
265 | 265 |
d = urlparse.parse_qs(query_string, True, False) |
266 | 266 |
if not set(d) >= set(['erreur', 'reference']): |
267 |
raise ResponseError() |
|
267 |
raise ResponseError('missing erreur or reference')
|
|
268 | 268 |
signed = False |
269 | 269 |
if 'signature' in d: |
270 | 270 |
sig = d['signature'][0] |
eopayment/sips.py | ||
---|---|---|
160 | 160 |
def response(self, query_string, **kwargs): |
161 | 161 |
form = urlparse.parse_qs(query_string) |
162 | 162 |
if not DATA in form: |
163 |
raise ResponseError() |
|
163 |
raise ResponseError('missing %s' % DATA)
|
|
164 | 164 |
params = {'message': form[DATA][0]} |
165 | 165 |
result = self.execute('response', params) |
166 | 166 |
d = dict(zip(RESPONSE_PARAMS, result)) |
eopayment/sips2.py | ||
---|---|---|
229 | 229 |
def response(self, query_string, **kwargs): |
230 | 230 |
form = urlparse.parse_qs(query_string) |
231 | 231 |
if not set(form) >= set(['Data', 'Seal', 'InterfaceVersion']): |
232 |
raise ResponseError() |
|
232 |
raise ResponseError('missing Data, Seal or InterfaceVersion')
|
|
233 | 233 |
self.logger.debug('received query string %r', form) |
234 | 234 |
data = self.decode_data(form['Data'][0]) |
235 | 235 |
seal = form['Seal'][0] |
eopayment/spplus.py | ||
---|---|---|
177 | 177 |
def response(self, query_string, logger=LOGGER, **kwargs): |
178 | 178 |
form = urlparse.parse_qs(query_string) |
179 | 179 |
if not set(form) >= set([REFERENCE, ETAT, REFSFP]): |
180 |
raise ResponseError() |
|
180 |
raise ResponseError('missing %s, %s or %s' % (REFERENCE, ETAT, REFSFP))
|
|
181 | 181 |
for key, value in form.items(): |
182 | 182 |
form[key] = value[0] |
183 | 183 |
logger.debug('received query_string %s' % query_string) |
eopayment/systempayv2.py | ||
---|---|---|
352 | 352 |
def response(self, query_string, **kwargs): |
353 | 353 |
fields = urlparse.parse_qs(query_string, True) |
354 | 354 |
if not set(fields) >= set([SIGNATURE, VADS_CTX_MODE, VADS_AUTH_RESULT]): |
355 |
raise ResponseError() |
|
355 |
raise ResponseError('missing %s, %s or %s' % (SIGNATURE, VADS_CTX_MODE, |
|
356 |
VADS_AUTH_RESULT)) |
|
356 | 357 |
for key, value in fields.items(): |
357 | 358 |
fields[key] = value[0] |
358 | 359 |
copy = fields.copy() |
eopayment/tipi.py | ||
---|---|---|
145 | 145 |
def response(self, query_string, **kwargs): |
146 | 146 |
fields = parse_qs(query_string, True) |
147 | 147 |
if not set(fields) >= set(['refdet', 'resultrans']): |
148 |
raise ResponseError() |
|
148 |
raise ResponseError('missing refdet or resultrans')
|
|
149 | 149 |
for key, value in fields.items(): |
150 | 150 |
fields[key] = value[0] |
151 | 151 |
refdet = fields.get('refdet') |
152 | 152 |
if refdet is None: |
153 |
raise ValueError('refdet is missing')
|
|
153 |
raise ResponseError('refdet is missing')
|
|
154 | 154 |
if 'objet' in fields: |
155 | 155 |
iso_now = fields['objet'] |
156 | 156 |
else: |
tests/test_dummy.py | ||
---|---|---|
1 | 1 |
import eopayment |
2 |
import pytest |
|
2 | 3 | |
3 | 4 |
def test_dummy(): |
4 | 5 |
options = { |
... | ... | |
17 | 18 |
assert r.signed |
18 | 19 |
assert r.transaction_id == '6Tfw2e1bPyYnz7CedZqvdHt7T9XX6T' |
19 | 20 |
assert r.return_content == 'signature ok' |
21 | ||
22 |
data = {'foo': 'bar'} |
|
23 |
with pytest.raises(eopayment.ResponseError, match='missing transaction_id'): |
|
24 |
p.response('foo=bar') |
tests/test_ogone.py | ||
---|---|---|
76 | 76 |
ogone_backend = eopayment.Payment('ogone', BACKEND_PARAMS) |
77 | 77 |
order_id = 'myorder' |
78 | 78 |
data = {'payid': '32100123', 'status': 9, 'ncerror': 0} |
79 |
with self.assertRaises(ResponseError):
|
|
79 |
with self.assertRaisesRegexp(ResponseError, 'missing ORDERID, PAYID, STATUS or NCERROR'):
|
|
80 | 80 |
response = ogone_backend.response(urllib.urlencode(data)) |
81 | 81 | |
82 | 82 |
def test_bank_transfer_response(self): |
tests/test_paybox.py | ||
---|---|---|
92 | 92 |
response = backend.response(urllib.urlencode(data)) |
93 | 93 |
self.assertEqual(response.order_id, order_id) |
94 | 94 | |
95 |
with self.assertRaisesRegexp(eopayment.ResponseError, 'missing erreur or reference'): |
|
96 |
backend.response('foo=bar') |
|
97 | ||
95 | 98 |
def test_rsa_signature_validation(self): |
96 | 99 |
pkey = '''-----BEGIN PUBLIC KEY----- |
97 | 100 |
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDUgYufHuheMztK1LhQSG6xsOzb |
tests/test_sips2.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 | |
3 | 3 |
import eopayment |
4 |
import pytest |
|
5 | ||
4 | 6 | |
5 | 7 |
def test_build_request(): |
6 | 8 |
backend = eopayment.Payment('sips2', {}) |
... | ... | |
31 | 33 |
qs = '''Data=captureDay%3D0%7CcaptureMode%3DAUTHOR_CAPTURE%7CcurrencyCode%3D978%7CmerchantId%3D002001000000001%7CorderChannel%3DINTERNET%7CresponseCode%3D00%7CtransactionDateTime%3D2016-02-01T17%3A44%3A20%2B01%3A00%7CtransactionReference%3D668930%7CkeyVersion%3D1%7CacquirerResponseCode%3D00%7Camount%3D1200%7CauthorisationId%3D12345%7CcardCSCResultCode%3D4E%7CpanExpiryDate%3D201605%7CpaymentMeanBrand%3DMASTERCARD%7CpaymentMeanType%3DCARD%7CcustomerIpAddress%3D82.244.203.243%7CmaskedPan%3D5100%23%23%23%23%23%23%23%23%23%23%23%2300%7CorderId%3Dd4903de7027f4d56ac01634fd7ab9526%7CholderAuthentRelegation%3DN%7CholderAuthentStatus%3D3D_ERROR%7CtransactionOrigin%3DINTERNET%7CpaymentPattern%3DONE_SHOT&Seal=6ca3247765a19b45d25ad54ef4076483e7d55583166bd5ac9c64357aac097602&InterfaceVersion=HP_2.0&Encode=''' |
32 | 34 |
backend = eopayment.Payment('sips2', {}) |
33 | 35 |
assert backend.response(qs) |
36 | ||
37 |
with pytest.raises(eopayment.ResponseError, match='missing Data, Seal or InterfaceVersion'): |
|
38 |
backend.response('foo=bar') |
tests/test_spplus.py | ||
---|---|---|
1 | 1 |
from unittest import TestCase |
2 | 2 |
import eopayment.spplus as spplus |
3 |
from eopayment import ResponseError |
|
3 | 4 | |
4 | 5 |
class SPPlustTest(TestCase): |
5 | 6 |
ntkey = b'58 6d fc 9c 34 91 9b 86 3f ' \ |
... | ... | |
14 | 15 | |
15 | 16 |
for query, result in self.tests: |
16 | 17 |
self.assertEqual(spplus.sign_ntkey_query(self.ntkey, query).lower(), result) |
18 | ||
19 |
with self.assertRaisesRegexp(ResponseError, 'missing reference, etat or refsfp'): |
|
20 |
payment.response('foo=bar') |
tests/test_systempayv2.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 | |
3 |
import pytest |
|
3 | 4 |
from six.moves.urllib import parse as urlparse |
4 | 5 | |
5 | 6 |
from eopayment.systempayv2 import Payment, VADS_CUST_FIRST_NAME, \ |
6 | 7 |
VADS_CUST_LAST_NAME, PAID |
8 |
from eopayment import ResponseError |
|
7 | 9 | |
8 | 10 |
PARAMS = { |
9 | 11 |
'secret_test': u'1122334455667788', |
... | ... | |
43 | 45 |
'&signature=62a4fb6738ebadebf9cc720164bc70e47282d36e' |
44 | 46 |
response = p.response(response_qs) |
45 | 47 |
assert response.result == PAID |
48 | ||
49 |
# bad response |
|
50 |
with pytest.raises(ResponseError, match='missing signature, vads_ctx_mode or vads_auth_result'): |
|
51 |
p.response('foo=bar') |
tests/test_tipi.py | ||
---|---|---|
1 | 1 |
from decimal import Decimal |
2 | 2 |
from six.moves.urllib.parse import urlparse, parse_qs |
3 | 3 |
import eopayment |
4 |
import pytest |
|
4 | 5 | |
5 | 6 |
def test_tipi(): |
6 | 7 |
p = eopayment.Payment('tipi', {'numcli': '12345'}) |
... | ... | |
23 | 24 |
response = p.response('objet=tout+a+fait&montant=12312&saisie=T&mel=info%40entrouvert.com&numcli=12345&exer=9999&refdet=999900000000999999&resultrans=P') |
24 | 25 |
assert response.signed # ... |
25 | 26 |
assert response.result == eopayment.PAID |
27 | ||
28 |
with pytest.raises(eopayment.ResponseError, match='missing refdet or resultrans'): |
|
29 |
p.response('foo=bar') |
|
26 |
- |