adyen.scaffold module¶
-
class
adyen.scaffold.
Scaffold
¶ Bases:
object
Entry point to handle Adyen HPP.
The
Scaffold
exposes an interface that can be used in any Django Oscar application. It aims to hide the inner complexity of payment form management and payment notification processing.The key methods are:
get_form_action()
and get_form_fields to build the Adyen HPP request submission form,handle_payment_return()
to handle customer coming back from the Adyen HPP after a payment (successful or not)assess_notification_relevance()
,handle_payment_notification()
andbuild_notification_response()
to handle Adyen Payment Notification.
-
ADYEN_TO_COMMON_PAYMENT_STATUSES
= {'PENDING': 'PENDING', 'REFUSED': 'REFUSED', 'ERROR': 'ERROR', 'AUTHORISED': 'ACCEPTED', 'CANCELLED': 'CANCELLED'}¶ This is the mapping between Adyen-specific and these standard statuses
-
PAYMENT_STATUS_ACCEPTED
= 'ACCEPTED'¶
-
PAYMENT_STATUS_CANCELLED
= 'CANCELLED'¶
-
PAYMENT_STATUS_ERROR
= 'ERROR'¶
-
PAYMENT_STATUS_PENDING
= 'PENDING'¶
-
PAYMENT_STATUS_REFUSED
= 'REFUSED'¶
-
assess_notification_relevance
(request)¶ Assess if a notification request is relevant.
Parameters: request – Django HTTP request object. Returns: A 2-value tuple as must_process
andmust_acknowledge
One should call this method when receiving a notification request and they want to know if the notification must:
- Be processed, ie. is a call to
handle_payment()
is relevant, - Be acknowledged with a response to Adyen, using
build_notification_response()
New in version 0.6.0: This method has been added to replace the generic
handle_payment_feedback()
.- Be processed, ie. is a call to
-
build_notification_response
(request)¶ Build a notification response for an Adyen Payment Notification
Parameters: request – Django HTTP request object. Returns: A Django HTTP Response object. From the
Adyen Integration Manual
:The Adyen notification system requires a response within 30 seconds of receipt of the notification, the server is expecting a response of[accepted]
, including the brackets. When our systems receive this response all notifications contained in the message are marked as successfully sent.”This method simply call the
adyen.facade.Facade.build_notification_response()
method and returns its result.
-
get_field_allowed_methods
(request, order_data)¶ Get a string of comma separated allowed payment methods.
Parameters: - request – Django HTTP request object.
- order_data (dict) – Order’s data.
Returns: If defined by the configuration, a string composed of a list of comma separated payment methods (ex.
card,bankTransfert
). OtherwiseNone
.This methods is used to populate the
allowedMethods
field of the payment request form. See Adyen HPP manual for more information.If a
source_type
is available into the providedorder_data
, then it is used as a parameter toadyen.config.AbstractAdyenConfig.get_allowed_methods()
.New in version 0.6.0: Added to handle
allowedMethods
field. May require extra work on the configuration object to work properly.
-
get_field_merchant_return_data
(request, order_data)¶
-
get_field_return_url
(request, order_data)¶
-
get_field_specs
(request, order_data)¶
-
get_form_action
(request)¶ Return the URL where the payment form should be submitted.
-
get_form_fields
(request, order_data)¶ Return the payment form fields as a list of dicts. Expects a large-ish order_data dictionary with details of the order.
-
handle_payment_feedback
(request)¶ Handle payment feedback from return URL or POST notification.
Parameters: request – Django HTTP request object. Returns: A normalized payment feedback. If the
request.method
isPOST
, this method consider we handle an Adyen Payment Notification. Otherwise it considers it is a simple Payment Return case.See also
handle_payment_notification()
andhandle_payment_return()
to see how to handle both cases.Deprecated since version 0.6.0: This method is deprecated in favor of more specific methods and should not be used in plugin user’s code anymore.
-
handle_payment_notification
(request)¶ Handle payment notification.
Parameters: request – Django HTTP request object Returns: A 3-values tuple with success
,status
anddetails
.One should call this method when handling the POST request that come as an Adyen Payment Notification.
New in version 0.6.0: This method has been added to replace the generic
handle_payment_feedback()
.
-
handle_payment_return
(request)¶ Handle payment return.
Parameters: request – Django HTTP request object Returns: A 3-values tuple with success
,status
anddetails
.One should call this method when handling the GET request that come after a redirection from Adyen.
New in version 0.6.0: This method has been added to replace the generic
handle_payment_feedback()
.