summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2011-05-27 13:57:12 (GMT)
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2011-05-27 13:57:12 (GMT)
commit9be5d93776ee3e9da63419a441c4e0a58597a5d6 (patch)
treeb6abedb49406e7fbf156c03f3edd92ca233664ca
parent9f72272089d04c2da46fe3378b6833053b6d3342 (diff)
downloadeopayment-cybermut.zip
eopayment-cybermut.tar.gz
eopayment-cybermut.tar.bz2
Start of the cybermut backendcybermut
-rw-r--r--eopayment/cybermut.py71
1 files changed, 71 insertions, 0 deletions
diff --git a/eopayment/cybermut.py b/eopayment/cybermut.py
new file mode 100644
index 0000000..d7fcb3d
--- /dev/null
+++ b/eopayment/cybermut.py
@@ -0,0 +1,71 @@
+from common import PaymentCommon, FORM
+from collections import namedtuple
+import hmac
+import hashlib
+
+CREDIT_MUTUEL = 'Credit Mutuel'
+CIC = 'CIC'
+OBC = 'OBC'
+
+TEST = 'test'
+PRODUCTION = 'production'
+
+URL_BANQUES = {
+ CREDIT_MUTUEL: {
+ TEST: 'https://paiement.creditmutuel.fr/test/paiement.cgi',
+ },
+ CIC: {
+ TEST: 'https://ssl.paiement.cic-banques.fr/test/paiement.cgi',
+ },
+ OBC: {
+ TEST: 'https://ssl.paiement.banque-obc.fr/test/paiement.cgi',
+ },
+}
+
+Parameter = namedtuple('Parameter', ['name', 'default', 'sign'])
+
+class Payment(PaymentCommon):
+ REQUEST_FIELDS = [
+ Parameter('TPE', '', True),
+ Parameter('date', '', True),
+ Parameter('montant', '', True),
+ Parameter('reference', '', True),
+ Parameter('texte_libre', '', True),
+ Parameter('version', '1.2open', True),
+ Parameter('lgue', 'FR', True),
+ Parameter('societe', '', True),
+ Parameter('url_retour', '', False),
+ Parameter('url_retour_ok', '', False),
+ Parameter('url_retour_err', '', False),
+ ]
+
+
+ def __init__(self, options):
+ self.cle = options.pop('cle')
+ banque = options.pop('banque')
+ plateforme = options.pop('plateforme')
+ try:
+ self.url = URL_BANQUES[banque][plateforme]
+ except KeyError:
+ raise RuntimeError('cybermut: there is no %s URL for bank %s' % (plateforme, banque))
+ self.tpe = options.pop('tpe')
+ self.options = options
+
+ def cybermut_request(self, **parameters):
+ datagramme = []
+ form = {}
+ data = self.options.copy()
+ data.update(parameters)
+ for parameter in self.REQUEST_FIELDS:
+ value = data.get(parameter.name, parameter.default)
+ if parameter.sign:
+ datagramme.append(value)
+ form[parameter.name] = value
+ datagramme = '*'.join(datagramme)
+ form['MAC'] = hmac.new(self.cle, datagramme, hashlib.sha1
+ 1;4
+ 1;2P
+
+
+
+ def request(self,