From d80f9e9cb0dc609255c37846df0c3c8ddd225106 Mon Sep 17 00:00:00 2001 From: Serghei Mihai Date: Mon, 8 Feb 2016 18:40:45 +0100 Subject: [PATCH] pass order id to all backends (#9941) --- eopayment/dummy.py | 10 ++++------ eopayment/paybox.py | 4 ++-- eopayment/sips.py | 6 +++--- eopayment/sips2.py | 6 +++--- eopayment/spplus.py | 7 ++++--- eopayment/systempayv2.py | 5 ++++- eopayment/tipi.py | 5 +++-- 7 files changed, 23 insertions(+), 20 deletions(-) diff --git a/eopayment/dummy.py b/eopayment/dummy.py index 8c0f367..11d1d63 100644 --- a/eopayment/dummy.py +++ b/eopayment/dummy.py @@ -72,7 +72,7 @@ class Payment(PaymentCommon): } def request(self, amount, name=None, address=None, email=None, phone=None, - info1=None, info2=None, info3=None, next_url=None, **kwargs): + orderid=None, info1=None, info2=None, info3=None, next_url=None, **kwargs): self.logger.debug('%s amount %s name %s address %s email %s phone %s' ' next_url %s info1 %s info2 %s info3 %s kwargs: %s', __name__, amount, name, address, email, phone, info1, info2, info3, next_url, kwargs) @@ -89,7 +89,7 @@ class Payment(PaymentCommon): 'origin': self.origin } query.update(dict(name=name, address=address, email=email, phone=phone, - info1=info1, info2=info2, info3=info3)) + orderid=orderid, info1=info1, info2=info2, info3=info3)) for key in query.keys(): if query[key] is None: del query[key] @@ -128,13 +128,11 @@ if __name__ == '__main__': p = Payment(options) retour = 'http://example.com/retour?amount=10.0&direct_notification_url=http%3A%2F%2Fexample.com%2Fdirect_notification_url&email=toto%40example.com&transaction_id=6Tfw2e1bPyYnz7CedZqvdHt7T9XX6T&return_url=http%3A%2F%2Fexample.com%2Fretour&nok=1' r = p.response(retour.split('?',1)[1]) - assert not r[0] + assert not r[0] assert r[1] == '6Tfw2e1bPyYnz7CedZqvdHt7T9XX6T' assert r[3] is None retour = 'http://example.com/retour?amount=10.0&direct_notification_url=http%3A%2F%2Fexample.com%2Fdirect_notification_url&email=toto%40example.com&transaction_id=6Tfw2e1bPyYnz7CedZqvdHt7T9XX6T&return_url=http%3A%2F%2Fexample.com%2Fretour&ok=1&signed=1' r = p.response(retour.split('?',1)[1]) - assert r[0] + assert r[0] assert r[1] == '6Tfw2e1bPyYnz7CedZqvdHt7T9XX6T' assert r[3] == 'signature ok' - - diff --git a/eopayment/paybox.py b/eopayment/paybox.py index 20e3b43..b09a12d 100644 --- a/eopayment/paybox.py +++ b/eopayment/paybox.py @@ -192,7 +192,7 @@ class Payment(PaymentCommon): ] } - def request(self, amount, email, name=None, **kwargs): + def request(self, amount, email, name=None, orderid=None, **kwargs): d = OrderedDict() d['PBX_SITE'] = unicode(self.site) d['PBX_RANG'] = unicode(self.rang).strip()[-2:] @@ -202,7 +202,7 @@ class Payment(PaymentCommon): transaction_id = kwargs.get('transaction_id') or \ self.transaction_id(12, string.digits, 'paybox', self.site, self.rang, self.identifiant) - d['PBX_CMD'] = unicode(transaction_id) + d['PBX_CMD'] = orderid or unicode(transaction_id) d['PBX_PORTEUR'] = unicode(email) d['PBX_RETOUR'] = 'montant:M;reference:R;code_autorisation:A;erreur:E;signature:K' d['PBX_HASH'] = 'SHA512' diff --git a/eopayment/sips.py b/eopayment/sips.py index 028a8f6..40cd1b0 100644 --- a/eopayment/sips.py +++ b/eopayment/sips.py @@ -132,13 +132,13 @@ class Payment(PaymentCommon): params.update(self.options) return params - def request(self, amount, name=None, address=None, email=None, phone=None, info1=None, - info2=None, info3=None, next_url=None, **kwargs): + def request(self, amount, name=None, address=None, email=None, phone=None, orderid=None, + info1=None, info2=None, info3=None, next_url=None, **kwargs): params = self.get_request_params() transaction_id = self.transaction_id(6, string.digits, 'sips', params[MERCHANT_ID]) params[TRANSACTION_ID] = transaction_id - params[ORDER_ID] = str(uuid.uuid4()).replace('-', '') + params[ORDER_ID] = orderid or str(uuid.uuid4()).replace('-', '') params['amount'] = str(int(Decimal(amount) * 100)) if email: params['customer_email'] = email diff --git a/eopayment/sips2.py b/eopayment/sips2.py index 156b4d7..2522028 100644 --- a/eopayment/sips2.py +++ b/eopayment/sips2.py @@ -135,12 +135,12 @@ class Payment(PaymentCommon): def get_url(self): return self.URL[self.platform] - def request(self, amount, name=None, address=None, email=None, phone=None, info1=None, - info2=None, info3=None, next_url=None, **kwargs): + def request(self, amount, name=None, address=None, email=None, phone=None, + orderid=None, info1=None, info2=None, info3=None, next_url=None, **kwargs): data = self.get_data() transaction_id = self.transaction_id(6, string.digits, 'sips2', data['merchantId']) data['transactionReference'] = unicode(transaction_id) - data['orderId'] = unicode(uuid.uuid4()).replace('-', '') + data['orderId'] = orderid or unicode(uuid.uuid4()).replace('-', '') data['amount'] = unicode(int(Decimal(amount) * 100)) if email: data['billingContact.email'] = email diff --git a/eopayment/spplus.py b/eopayment/spplus.py index 57e1e5c..1e9b11c 100644 --- a/eopayment/spplus.py +++ b/eopayment/spplus.py @@ -122,8 +122,9 @@ class Payment(PaymentCommon): } devise = '978' - def request(self, amount, name=None, address=None, email=None, phone=None, info1=None, - info2=None, info3=None, next_url=None, logger=LOGGER, **kwargs): + def request(self, amount, name=None, address=None, email=None, phone=None, + orderid=None, info1=None, info2=None, info3=None, next_url=None, + logger=LOGGER, **kwargs): logger.debug('requesting spplus payment with montant %s email=%s and \ next_url=%s' % (amount, email, next_url)) reference = self.transaction_id(20, ALPHANUM, 'spplus', self.siret) @@ -134,7 +135,7 @@ next_url=%s' % (amount, email, next_url)) 'langue': self.langue, 'taxe': self.taxe, 'montant': str(Decimal(amount)), - REFERENCE: reference, + REFERENCE: orderid or reference, 'validite': validite, 'version': '1', 'modalite': self.modalite, diff --git a/eopayment/systempayv2.py b/eopayment/systempayv2.py index f975b16..c1743c5 100644 --- a/eopayment/systempayv2.py +++ b/eopayment/systempayv2.py @@ -252,7 +252,8 @@ class Payment(PaymentCommon): self.logger = logger or logging.getLogger(__name__) def request(self, amount, name=None, address=None, email=None, phone=None, - info1=None, info2=None, info3=None, next_url=None, **kwargs): + orderid=None, info1=None, info2=None, info3=None, + next_url=None, **kwargs): ''' Create the URL string to send a request to SystemPay ''' @@ -281,6 +282,8 @@ class Payment(PaymentCommon): kwargs['vads_order_info2'] = unicode(info2) if info3 is not None: kwargs['vads_order_info3'] = unicode(info3) + if orderid is not None: + kwargs['vads_order_id'] = unicode(orderid) transaction_id = self.transaction_id(6, string.digits, 'systempay', self.options[VADS_SITE_ID]) diff --git a/eopayment/tipi.py b/eopayment/tipi.py index 7bb5aaf..763cfa8 100644 --- a/eopayment/tipi.py +++ b/eopayment/tipi.py @@ -48,8 +48,8 @@ class Payment(PaymentCommon): self.numcli = options.pop('numcli', '') self.logger = logger - def request(self, amount, next_url=None, exer=None, refdet=None, - objet=None, email=None, saisie=None, **kwargs): + def request(self, amount, next_url=None, exer=None, orderid=None, + refdet=None, objet=None, email=None, saisie=None, **kwargs): try: montant = Decimal(amount) if Decimal('0') > montant > Decimal('9999.99'): @@ -73,6 +73,7 @@ class Payment(PaymentCommon): except ValueError: raise ValueError('EXER format invalide') try: + refdet = orderid or refdet refdet = str(refdet) if 6 > len(refdet) > 30: raise ValueError('len(REFDET) < 6 or > 30') -- 2.7.0