summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eopayment/paybox.py12
-rw-r--r--tests/test_paybox.py21
2 files changed, 32 insertions, 1 deletions
diff --git a/eopayment/paybox.py b/eopayment/paybox.py
index d5cd6ce..ec4d479 100644
--- a/eopayment/paybox.py
+++ b/eopayment/paybox.py
@@ -113,6 +113,10 @@ PAYBOX_DIRECT_VERSION_NUMBER = '00104'
PAYBOX_DIRECT_SUCCESS_RESPONSE_CODE = '00000'
+# payment modes
+PAYMENT_MODES = {'AUTHOR_CAPTURE': 'O',
+ 'IMMEDIATE': 'N'}
+
def sign(data, key):
'''Take a list of tuple key, value and sign it by building a string to
@@ -236,6 +240,13 @@ class Payment(PaymentCommon):
'validation': lambda x: isinstance(x, basestring) and
x.isdigit() and (1 <= len(x) <= 2)
},
+ {
+ 'name': 'capture_mode',
+ 'caption': _('Capture Mode'),
+ 'default': 'IMMEDIATE',
+ 'required': False,
+ 'choices': PAYMENT_MODES.keys()
+ },
]
}
@@ -270,6 +281,7 @@ class Payment(PaymentCommon):
automatic_return_url = self.callback
if self.capture_day:
d['PBX_DIFF'] = self.capture_day.zfill(2)
+ d['PBX_AUTOSEULE'] = PAYMENT_MODES[self.capture_mode]
if automatic_return_url:
d['PBX_REPONDRE_A'] = force_text(automatic_return_url)
d = d.items()
diff --git a/tests/test_paybox.py b/tests/test_paybox.py
index a0b8d9a..6f09be1 100644
--- a/tests/test_paybox.py
+++ b/tests/test_paybox.py
@@ -68,9 +68,10 @@ class PayboxTests(TestCase):
'PBX_TOTAL': amount.replace('.', ''),
'PBX_DEVISE': '978',
'PBX_HASH': 'SHA512',
- 'PBX_HMAC': 'D90B0D2B1C8BF67A2FC54AE56A026ABC6ABE17F2B976B993355CD9E6690A0EBB70ED18D67CB8D492B330C4EA76720CB492B8B4D033D8C2163C9B2D012B19BEAA',
+ 'PBX_HMAC': '6C70F35F9C6F6C9AB16D1E766EF981D241CB527C2E547205622DFFAF5B1B6C0F47E1DE2D3A1CE579F97AD19F87C3AE63E89B22F4B6D1E118685F5DD977891668',
'PBX_ARCHIVAGE': '1234',
'PBX_REPONDRE_A': 'http://example.com/callback',
+ 'PBX_AUTOSEULE': 'N'
}
form_params = {}
@@ -104,6 +105,24 @@ class PayboxTests(TestCase):
self.assertIn('PBX_DIFF', form_params)
self.assertEqual(form_params['PBX_DIFF'], '07')
+ def test_request_with_authorization_only(self):
+ params = BACKEND_PARAMS.copy()
+ time = '2018-08-21T10:26:32+02:00'
+ email = 'user@entrouvert.com'
+ order_id = '20180821'
+ transaction = '1234'
+ amount = '42.99'
+
+ params['capture_mode'] = 'AUTHOR_CAPTURE'
+ backend = eopayment.Payment('paybox', params)
+ transaction_id, kind, what = backend.request(
+ Decimal(amount), email=email, orderid=order_id,
+ transaction_id=transaction, time=time)
+ root = ET.fromstring(str(what))
+
+ form_params = dict(((node.attrib['name'], node.attrib['value']) for node in root if node.attrib['type'] == 'hidden'))
+ self.assertEqual(form_params['PBX_AUTOSEULE'], 'O')
+
def test_response(self):
backend = eopayment.Payment('paybox', BACKEND_PARAMS)
order_id = '20160216'