-
Notifications
You must be signed in to change notification settings - Fork 6
Recurring Payments
svdgraaf edited this page Dec 7, 2012
·
5 revisions
Make sure that your account is enabled for recurring payments, as this will otherwise not work
The recurring payments is divided in 3 steps.
- Step 1 is to have the client authorise the first payment, you send a special field with the payment to mark it for recurrence
- Step 2 is to validate the authorisation (via the regular validation)
- Step 3 when a next payment is due, use the api to authorise a new payment, using the details from step 1
Step 1 is roughly the same as the regular step. For a recurring payment, you will need to provided these fields:
data = data + {
'shopperEmail': request.user.email, #
'shopperReference': request.user.id, # Needs to be unique, you'll need this in step 3
'recurringContract': 'RECURRING', # Mark this authorisation for recurring payments
}
Step is the validation step, make sure the authorisation is approved (via either the redirect data, or the notification). For your reference, it is advised to also store the psp data, as you might need it in the future. This is the last step in which the user is needed.
When a new payment is due, call the Adyen api with the used data in step 1:
from py_adyen.api import Api
ws = Api()
reference = 'order445' # internatl reference
statement = 'Subscription Fee October' # public payment statement for user
shopper_email = '[email protected]'
shopper_reference = 'user-42'
amount = 100
currency = 'EUR'
ws.authorise_recurring_payment(reference, statement, amount, currency, shopper_reference, shopper_email, shopper_ip=None, recurring_detail_reference='LATEST')
# (PaymentResult){
# additionalData = None
# authCode = None
# dccAmount = None
# dccSignature = None
# fraudResult = None
# issuerUrl = None
# md = None
# paRequest = None
# pspReference = "xyz"
# refusalReason = None
# resultCode = "Received" # The resultCode will vary
# }
It is advised to store the result data (eg: pspReference) for future reference.