introduce a new "WAITING" status and use it for ogone (#19358)
This commit is contained in:
parent
2d75c65935
commit
fe53eb36df
|
@ -3,11 +3,11 @@
|
|||
import logging
|
||||
|
||||
from common import (URL, HTML, FORM, RECEIVED, ACCEPTED, PAID, DENIED,
|
||||
CANCELED, CANCELLED, ERROR, ResponseError, force_text)
|
||||
CANCELED, CANCELLED, ERROR, WAITING, ResponseError, force_text)
|
||||
|
||||
__all__ = ['Payment', 'URL', 'HTML', 'FORM', 'SIPS',
|
||||
'SYSTEMPAY', 'SPPLUS', 'TIPI', 'DUMMY', 'get_backend', 'RECEIVED', 'ACCEPTED',
|
||||
'PAID', 'DENIED', 'CANCELED', 'CANCELLED', 'ERROR', 'get_backends']
|
||||
'PAID', 'DENIED', 'CANCELED', 'CANCELLED', 'ERROR', 'WAITING', 'get_backends']
|
||||
|
||||
SIPS = 'sips'
|
||||
SIPS2 = 'sips2'
|
||||
|
|
|
@ -6,7 +6,7 @@ import cgi
|
|||
from datetime import date
|
||||
|
||||
__all__ = ['PaymentCommon', 'URL', 'HTML', 'RANDOM', 'RECEIVED', 'ACCEPTED',
|
||||
'PAID', 'ERROR']
|
||||
'PAID', 'ERROR', 'WAITING']
|
||||
|
||||
|
||||
RANDOM = random.SystemRandom()
|
||||
|
@ -21,6 +21,7 @@ PAID = 3
|
|||
DENIED = 4
|
||||
CANCELLED = 5
|
||||
CANCELED = 5 # typo for backward compatibility
|
||||
WAITING = 6
|
||||
ERROR = 99
|
||||
|
||||
# separator between order and transaction ids
|
||||
|
|
|
@ -6,7 +6,7 @@ from decimal import Decimal, ROUND_HALF_UP
|
|||
|
||||
from common import (PaymentCommon, PaymentResponse, FORM, CANCELLED, PAID,
|
||||
ERROR, Form, DENIED, ACCEPTED, ORDERID_TRANSACTION_SEPARATOR,
|
||||
ResponseError, force_byte, force_text)
|
||||
WAITING, ResponseError, force_byte, force_text)
|
||||
def N_(message): return message
|
||||
|
||||
ENVIRONMENT_TEST = 'TEST'
|
||||
|
@ -560,6 +560,12 @@ class Payment(PaymentCommon):
|
|||
result = ACCEPTED
|
||||
elif status == '9':
|
||||
result = PAID
|
||||
elif len(status) == 2 and status[1] == '1':
|
||||
# Statuses with two digits represent either ‘intermediary'
|
||||
# situations or abnormal events. When the second digit is:
|
||||
# 1, this means the payment processing is on hold. (e.g.
|
||||
# status 91: payment waiting/pending)
|
||||
result = WAITING
|
||||
else:
|
||||
self.logger.error('response STATUS=%s NCERROR=%s NCERRORPLUS=%s',
|
||||
status, error, params.get('NCERRORPLUS', ''))
|
||||
|
|
|
@ -72,10 +72,25 @@ class OgoneTests(TestCase):
|
|||
assert response.signed
|
||||
self.assertEqual(response.order_id, order_id)
|
||||
|
||||
|
||||
def test_bad_response(self):
|
||||
ogone_backend = eopayment.Payment('ogone', BACKEND_PARAMS)
|
||||
order_id = 'myorder'
|
||||
data = {'payid': '32100123', 'status': 9, 'ncerror': 0}
|
||||
with self.assertRaises(ResponseError):
|
||||
response = ogone_backend.response(urllib.urlencode(data))
|
||||
|
||||
def test_bank_transfer_response(self):
|
||||
ogone_backend = eopayment.Payment('ogone', BACKEND_PARAMS)
|
||||
order_id = 'myorder'
|
||||
data = {'orderid': u'myorder', 'status': u'41', 'payid': u'3011229363',
|
||||
'cn': u'User', 'ncerror': u'0',
|
||||
'trxdate': u'10/24/16',
|
||||
'brand': 'Bank transfer', 'pm': 'bank transfer',
|
||||
'currency': u'eur', 'amount': u'7.5',
|
||||
'shasign': u'0E35F687ACBEAA6CA769E0ADDBD0863EB6C1678A'}
|
||||
# uniformize to utf-8 first
|
||||
for k in data:
|
||||
data[k] = eopayment.common.force_byte(data[k])
|
||||
response = ogone_backend.response(urllib.urlencode(data))
|
||||
assert response.signed
|
||||
assert response.result == eopayment.WAITING
|
||||
|
|
Loading…
Reference in New Issue