Skip to content
svdgraaf edited this page Dec 7, 2012 · 2 revisions
from py_adyen.adyen import Adyen
data = {
    'merchantReference': '1337',           # your internal reference for this payment
    'paymentAmount': 100,                  # amount in cents
    'currencyCode': 'EUR',                 # currency, in the 3 letter format (see Adyen docs)
    'shipBeforeDate': datetime.now(),      # useful for lookups (I guess)
    'shopperEmail': '[email protected]',  # useful for recurring payments etc.
    'shopperReference': 'user-42',         # your internal reference for (recurring) lookups etc.
    'sessionValidity': datetime.now(),     # how long is the payment session valid
}

a = Adyen(data)
a.sign()
form = a.get_form()

print form                  # form with hidden items
print a.get_action()        # action url for the form
print a.get_redirect_url()  # useable for redirecting (uses GET args)

After the user is redirected back, you can use the is_valid() method for checking whether the data is valid. It is advised to use the fields from the Adyen notifications though.

from py_adyen.adyen import Adyen
data = request.POST.dict()
a = Adyen(data)
a.is_valid()  # True when the signature is valid, False if not
Clone this wiki locally