Beispiel #1
0
def cancel(request, payment_method, payment_code):
        
    from payments.connector import PaymentConnector

    payment = PaymentConnector.get_connector().lookup(payment_code)
    pp = PaymentProcessor.get_processor(payment_method)

    return pp.cancel(request, payment)
Beispiel #2
0
def success(request, payment_method, payment_code):
    
    from payments.connector import PaymentConnector

    payment = PaymentConnector.get_connector().lookup(payment_code)
    pp = PaymentProcessor.get_processor(payment_method)

    try:
        return pp.success(request, payment)
    except PaymentProcessingError, e:
        return pp.error(request, payment, e)
Beispiel #3
0
class PickledPaymentConnector(PaymentConnector):

    def __init__(self, code, data={}):
        data["code"] = code
        self.code = code
        self.data = data

    def get_value(self, key):
        return self.data[key]

    @classmethod
    def lookup(self, code):
        payment = self(code)
        payment.load()
        return payment

    def load(self):
        import pickle
        fh = open("%s.pickle" % self.code, "r")
        self.data = pickle.load(fh)
        fh.close()

    def save(self):
        import pickle
        fh = open("%s.pickle" % self.code, "w")
        pickle.dump(self.data, fh)
        fh.close()

PaymentConnector.set_connector(PickledPaymentConnector)
Beispiel #4
0
#!/usr/bin/python

"""
An example and testing script. Creates a payment and retrieves a
payment form for each method set for the payment.
"""

import sys
from payments import PaymentProcessor
from payments.connector import PaymentConnector, PickledStorage
from example.PickledPaymentConnector import PickledPaymentConnector

# initialize payment processors with test credentials

PaymentConnector.set_connector(PickledPaymentConnector)

# create a payment instance

payment = PaymentConnector(code="1997060417052135")
#payment = Payment(code="900")
#payment.set_payment_methods(["nordea", "sampo", "op", "samlink", "tapiola"])
payment.set_payment_methods(["nordea"])
payment.set_value("currency", "EUR")
payment.set_value("language", "en")
payment.set_value("message", "Payment test!")
payment.set_value("amount", "13,00")
payment.set_value("fi_reference", "13")
payment.add_item(price="42.00", qty="4", tax="0", description="widget")
payment.add_item(price="12.00", qty="2", tax="0", description="choco")
payment.save()