From e8d556e5b24232691e192182ad873fe4fb652180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 29 Dec 2016 09:57:29 +0100 Subject: [PATCH] sips2: set statementReference with custom info or order id (#14454) --- eopayment/sips2.py | 4 ++++ tests/test_sips2.py | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/eopayment/sips2.py b/eopayment/sips2.py index b3cfe20..6675781 100644 --- a/eopayment/sips2.py +++ b/eopayment/sips2.py @@ -174,6 +174,10 @@ class Payment(PaymentCommon): transaction_id = self.transaction_id(6, string.digits, 'sips2', data['merchantId']) data['transactionReference'] = unicode(transaction_id) data['orderId'] = orderid or unicode(uuid.uuid4()).replace('-', '') + if info1: + data['statementReference'] = unicode(info1) + else: + data['statementReference'] = data['transactionReference'] data['amount'] = unicode(int(Decimal(amount) * 100)) if email: data['billingContact.email'] = email diff --git a/tests/test_sips2.py b/tests/test_sips2.py index e2d77ba..a2250b4 100644 --- a/tests/test_sips2.py +++ b/tests/test_sips2.py @@ -9,6 +9,14 @@ def test_build_request(): data = [f for f in form.fields if f['name'] == 'Data'] assert not u'lix000000' in data[0]['value'] + transaction, f, form = backend.request(amount=u'12') + data = [f for f in form.fields if f['name'] == 'Data'] + assert 'statementReference=%s' % transaction in data[0]['value'] + + transaction, f, form = backend.request(amount=u'12', info1='foobar') + data = [f for f in form.fields if f['name'] == 'Data'] + assert 'statementReference=foobar' in data[0]['value'] + def test_options(): payment = eopayment.Payment('sips2', {'capture_mode': u'VALIDATION'}) assert payment.backend.get_data()['captureMode'] == 'VALIDATION'