Compare commits

...

5 Commits
main ... dummy

Author SHA1 Message Date
Frédéric Péters e4912d22ea removing debugging statement 2011-04-30 21:42:30 +02:00
Frédéric Péters b7507de11a Add a dummy backend 2011-04-30 19:06:19 +02:00
Frédéric Péters f9c5ca3a01 Add a workaround on module import to also work with Quixote custom version 2011-04-30 18:55:35 +02:00
Frédéric Péters 2a1c50c136 Fix import of backend when used from another directory 2011-04-30 18:48:41 +02:00
Frédéric Péters 179a2e5fc9 Pass next_url to backend 2011-04-30 18:30:05 +02:00
2 changed files with 43 additions and 2 deletions

View File

@ -1,11 +1,14 @@
# -*- coding: utf-8 -*-
import logging
import os
import sys
from common import URL, HTML
__all__ = [ 'Payment', 'URL', 'HTML' ]
DUMMY = 'dummy'
SIPS = 'sips'
SYSTEMPAY = 'systempayv2'
SPPLUS = 'spplus'
@ -42,7 +45,14 @@ class Payment(object):
def __init__(self, kind, options):
self.kind = kind
module = __import__(kind)
module_path = __file__
if not os.path.isdir(os.path.realpath(__file__)):
module_path = os.path.dirname(__file__)
sys.path.append(module_path)
try:
module = __import__(kind)
finally:
sys.path.pop()
self.backend = module.Payment(options)
def request(self, amount, email=None, next_url=None):
@ -76,7 +86,7 @@ class Payment(object):
# present the form in HTML to the user
'''
return self.backend.request(amount, email=email)
return self.backend.request(amount, email=email, next_url=next_url)
def response(self, query_string):
'''

31
eopayment/dummy.py Normal file
View File

@ -0,0 +1,31 @@
'''
Dummy payment backend module for debugging
'''
from decimal import Decimal
import string
import urllib2
import urlparse
from common import PaymentCommon, URL
__all__ = [ 'Payment' ]
class Payment(PaymentCommon):
def __init__(self, options):
self.options = options
def request(self, amount, email=None, next_url=None):
transaction_id = self.transaction_id(6, string.digits, 'dummy')
dest_url = 'http://perso.entrouvert.org/~fred/paiement/?return=%s&tid=%s&amount=%s' % (
urllib2.quote(next_url),
transaction_id,
str(Decimal(amount)*100))
return (transaction_id, URL, dest_url)
def response(self, query_string):
form = urlparse.parse_qs(query_string)
return (True, form.get('tid')[0], '', None)