Compare commits
5 Commits
Author | SHA1 | Date |
---|---|---|
Frédéric Péters | e4912d22ea | |
Frédéric Péters | b7507de11a | |
Frédéric Péters | f9c5ca3a01 | |
Frédéric Péters | 2a1c50c136 | |
Frédéric Péters | 179a2e5fc9 |
|
@ -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):
|
||||
'''
|
||||
|
|
|
@ -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)
|
Loading…
Reference in New Issue