adyen.gateway module

class adyen.gateway.BaseInteraction

Bases: object

HASH_FIELD = None
HASH_KEYS = ()
OPTIONAL_FIELDS = ()
REQUIRED_FIELDS = ()
check_fields()

Validate required and optional fields for both requests and responses.

hash()
validate()
class adyen.gateway.BaseResponse(client, params)

Bases: adyen.gateway.BaseInteraction

process()
class adyen.gateway.Constants

Bases: object

ACCEPTED_NOTIFICATION = '[accepted]'
ACTION_URL = 'action_url'
ADDITIONAL_DATA_PREFIX = 'additionalData.'
ADYEN = 'adyen'
ALLOWED_METHODS = 'allowedMethods'
AUTH_RESULT = 'authResult'
BILLING_ADDRESS_TYPE = 'billingAddressType'
BLOCKED_METHODS = 'blockedMethods'
COUNTRY_CODE = 'countryCode'
CURRENCY = 'currency'
CURRENCY_CODE = 'currencyCode'
DELIVERY_ADDRESS_TYPE = 'deliveryAddressType'
EVENT_CODE = 'eventCode'
EVENT_CODE_AUTHORISATION = 'AUTHORISATION'
EVENT_DATE = 'eventDate'
FALSE = 'false'
IDENTIFIER = 'identifier'
LIVE = 'live'
MERCHANT_ACCOUNT = 'merchantAccount'
MERCHANT_ACCOUNT_CODE = 'merchantAccountCode'
MERCHANT_REFERENCE = 'merchantReference'
MERCHANT_RETURN_DATA = 'merchantReturnData'
MERCHANT_RETURN_URL = 'resURL'
MERCHANT_SIG = 'merchantSig'
OFFSET = 'offset'
OPERATIONS = 'operations'
ORIGINAL_REFERENCE = 'originalReference'
PAYMENT_AMOUNT = 'paymentAmount'
PAYMENT_METHOD = 'paymentMethod'
PAYMENT_RESULT_AUTHORISED = 'AUTHORISED'
PAYMENT_RESULT_CANCELLED = 'CANCELLED'
PAYMENT_RESULT_ERROR = 'ERROR'
PAYMENT_RESULT_PENDING = 'PENDING'
PAYMENT_RESULT_REFUSED = 'REFUSED'
PSP_REFERENCE = 'pspReference'
REASON = 'reason'
RECURRING_CONTRACT = 'recurringContract'
SECRET_KEY = 'secret_key'
SEPARATOR = ':'
SESSION_VALIDITY = 'sessionValidity'
SHIP_BEFORE_DATE = 'shipBeforeDate'
SHOPPER_EMAIL = 'shopperEmail'
SHOPPER_LOCALE = 'shopperLocale'
SHOPPER_REFERENCE = 'shopperReference'
SHOPPER_STATEMENT = 'shopperStatement'
SHOPPER_TYPE = 'shopperType'
SKIN_CODE = 'skinCode'
SUCCESS = 'success'
TEST = 'test'
TEST_REFERENCE_PREFIX = 'test_AUTHORISATION'
TRUE = 'true'
VALUE = 'value'
class adyen.gateway.Gateway(settings=None)

Bases: object

MANDATORY_SETTINGS = ('identifier', 'secret_key', 'action_url')
build_payment_form_fields(params)
exception adyen.gateway.InvalidTransactionException

Bases: ValueError

exception adyen.gateway.MissingFieldException

Bases: ValueError

exception adyen.gateway.MissingParameterException

Bases: ValueError

class adyen.gateway.PaymentFormRequest(client, params=None)

Bases: adyen.gateway.BaseInteraction

HASH_FIELD = 'merchantSig'
HASH_KEYS = ('paymentAmount', 'currencyCode', 'shipBeforeDate', 'merchantReference', 'skinCode', 'merchantAccount', 'sessionValidity', 'shopperEmail', 'shopperReference', 'recurringContract', 'allowedMethods', 'blockedMethods', 'shopperStatement', 'merchantReturnData', 'billingAddressType', 'deliveryAddressType', 'shopperType', 'offset')
OPTIONAL_FIELDS = ('merchantSig', 'skinCode', 'recurringContract', 'allowedMethods', 'blockedMethods', 'shopperStatement', 'shopperLocale', 'countryCode', 'resURL', 'merchantReturnData', 'billingAddressType', 'deliveryAddressType', 'shopperType', 'offset')
REQUIRED_FIELDS = ('merchantAccount', 'merchantReference', 'shopperReference', 'shopperEmail', 'currencyCode', 'paymentAmount', 'sessionValidity', 'shipBeforeDate')
build_form_fields()
class adyen.gateway.PaymentNotification(client, params)

Bases: adyen.gateway.BaseResponse

Process payment notifications (HTTPS POST from Adyen to our servers).

Payment notifications can have multiple fields. They fall into four categories:

  • required: Must be included.
  • optional: Can be included.
  • additional data: Can be included. Format is ‘additionalData.VALUE’ and we don’t need the data at the moment, so it’s ignored.
  • unexpected: We loudly complain.
OPTIONAL_FIELDS = ('operations', 'originalReference')
REQUIRED_FIELDS = ('currency', 'eventCode', 'eventDate', 'live', 'merchantAccountCode', 'merchantReference', 'paymentMethod', 'pspReference', 'reason', 'success', 'value')
check_fields()

Delete unneeded additional data before validating.

Adyen’s payment notification can come with additional data. It can mostly be turned on and off in the notifications settings, but some bits always seem to be delivered with the new “System communication” setup (instead of the old “notifications” tab in the settings). We currently don’t need any of that data, so we just drop it before validating the notification. :return:

process()
class adyen.gateway.PaymentRedirection(client, params)

Bases: adyen.gateway.BaseResponse

Process payment feedback from the user

When they paid on Adyen and get redirected back to our site. HTTP GET from user’s browser.

HASH_FIELD = 'merchantSig'
HASH_KEYS = ('authResult', 'pspReference', 'merchantReference', 'skinCode', 'merchantReturnData')
OPTIONAL_FIELDS = ('merchantReturnData', 'paymentMethod', 'pspReference')
REQUIRED_FIELDS = ('authResult', 'merchantReference', 'merchantSig', 'shopperLocale', 'skinCode')
process()
validate()
exception adyen.gateway.UnexpectedFieldException

Bases: ValueError