Adyen API Library for ruby
Recurring is authenticated via webservice username and password.
adyen.ws_user = "ws@Company.TestCompany"
adyen.ws_passord = "super_secure_password123"
The Recurring service is used to store and manage payment method details on the Adyen server.
To store details, make a call to the store_token method:
response = adyen.recurring.store_token('{
"card": {
"number": "4111111111111111",
"expiryMonth": "8",
"expiryYear": "2018",
"cvc": "737",
"holderName": "John Smith"
},
"reference": "YOUR_REFERENCE",
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
"shopperReference": "<shopperReference>",
"recurring": {
"contract": "RECURRING,ONECLICK"
}
}')
In the response you will receive a recurringDetailReference which can later be used in conjunction with the shopperReference to create a card on file charge for the shopper:
response = adyen.payments.authorise('{
"amount":{
"value":2000,
"currency":"EUR"
},
"reference":"YOUR_REFERENCE",
"merchantAccount":"YOUR_MERCHANT_ACCOUNT",
"shopperReference":"<shopperReference>",
"selectedRecurringDetailReference":"<recurringDetailReference from store_token response>",
"recurring":{
"contract":"RECURRING"
},
"shopperInteraction":"ContAuth"
}')
To retrieve a list of payment methods associated with a shopper, use the listrecurringdetails method:
response = adyen.recurring.list_recurring_details('{
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
"shopperReference": "<shopperReference>"
}')
If you no longer wish to associate a certain payment detail with a shopper, send a call to the disable method:
response = adyen.recurring.disable('{
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
"shopperReference": "<shopperReference>",
"recurringDetailReference": "<recurringDetailReference>"
}')