Module: Adyen::API
- Extended by:
- API
- Included in:
- API
- Defined in:
- lib/adyen/api.rb,
lib/adyen/api/response.rb,
lib/adyen/api/xml_querier.rb,
lib/adyen/api/test_helpers.rb,
lib/adyen/api/payment_service.rb,
lib/adyen/api/recurring_service.rb,
lib/adyen/api/simple_soap_client.rb,
lib/adyen/api/templates/payment_service.rb,
lib/adyen/api/templates/recurring_service.rb
Overview
The API module contains classes that interact with the Adyen SOAP API.
You'll need to provide a username and password to interact with Adyen:
Adyen.configuration.api_username = 'ws@Company.MyAccount'
Adyen.configuration.api_password = 'secret'
Furthermore, you can setup default parameters, which will be used by every API call, by using default_arguments.
The following classes, which handle the SOAP services, are available:
-
PaymentService - for authorisation of, and modification to, payments.
-
RecurringService - for handling recurring contract details.
However, direct use of these classes is discouraged in favor of the shortcut methods defined on the API module. These methods require that you set the :merchant_account beforehand as a default parameter passed in all API calls:
Adyen.configuration.default_api_params[:merchant_account] = 'MerchantAccount'
For Rails apps, you can also set it `application.rb` config block, like this:
config.adyen.default_api_params = { :merchant_account => 'MerchantAccount' }
Note that you'll need an Adyen notification PSP reference for some of the calls. Because of this, store all notifications that Adyen sends to you. Moreover, the responses to these calls do not tell you whether or not the requested action was successful. For this you will also have to check the notification.
Authorising payments
To authorise payments, not recurring ones, the customers payment details will have to pass through your application???s infrastucture. Because of this you will have to contact Adyen and provide the necessary paperwork which says that you???re PCI DSS compliant, before you are given access to Adyen???s API.
Unless you are going to process over twenty thousand payments anually, the PCI DSS Self-Assessment Questionnaire (SAQ) type A will probably suffice.
Defined Under Namespace
Classes: PaymentService, RecurringService, Response, SimpleSOAPClient, XMLQuerier
Instance Method Summary (collapse)
-
- (PaymentService::AuthorisationResponse) authorise_one_click_payment(reference, amount, shopper, card_cvc, recurring_detail_reference)
Authorise a ???one-click??? payment.
-
- (PaymentService::AuthorisationResponse) authorise_payment(reference, amount, shopper, card, enable_recurring_contract = false)
Authorise a payment.
-
- (PaymentService::AuthorisationResponse) authorise_recurring_payment(reference, amount, shopper, recurring_detail_reference = 'LATEST')
Authorise a recurring payment.
-
- (PaymentService::CancelOrRefundResponse) cancel_or_refund_payment(psp_reference)
Cancel or refund a payment.
-
- (PaymentService::CancelResponse) cancel_payment(psp_reference)
Cancel an authorised payment.
-
- (PaymentService::CaptureResponse) capture_payment(psp_reference, amount)
Capture an authorised payment.
-
- (RecurringService::DisableResponse) disable_recurring_contract(shopper_reference, recurring_detail_reference = nil)
Disable the recurring contract details for a shopper.
-
- (RecurringService::ListResponse) list_recurring_details(shopper_reference)
Retrieve the recurring contract details for a shopper.
-
- (PaymentService::RefundResponse) refund_payment(psp_reference, amount)
Refund a captured payment.
-
- (RecurringService::StoreTokenResponse) store_recurring_token(shopper, params)
Stores and tokenises the payment details so that recurring payments can be made in the future.
Instance Method Details
- (PaymentService::AuthorisationResponse) authorise_one_click_payment(reference, amount, shopper, card_cvc, recurring_detail_reference)
Authorise a ???one-click??? payment. A specific contract detail has to be specified.
Of all options, only the shopper???s IP address is optional. But since it???s used in various risk checks, it???s a good idea to supply it anyway.
186 187 188 189 190 191 192 193 194 |
# File 'lib/adyen/api.rb', line 186 def (reference, amount, shopper, card_cvc, recurring_detail_reference) PaymentService.new( :reference => reference, :amount => amount, :shopper => shopper, :card => { :cvc => card_cvc }, :recurring_detail_reference => recurring_detail_reference ). end |
- (PaymentService::AuthorisationResponse) authorise_payment(reference, amount, shopper, card, enable_recurring_contract = false)
Authorise a payment.
Of all options, only the details are optional. But since the IP is???s used in various risk checks, and the email and reference are needed to enable recurring contract, it???s a good idea to supply it anyway.
96 97 98 99 100 101 102 103 104 |
# File 'lib/adyen/api.rb', line 96 def (reference, amount, shopper, card, enable_recurring_contract = false) PaymentService.new( :reference => reference, :amount => amount, :shopper => shopper, :card => card, :recurring => enable_recurring_contract ). end |
- (PaymentService::AuthorisationResponse) authorise_recurring_payment(reference, amount, shopper, recurring_detail_reference = 'LATEST')
Authorise a recurring payment. The contract detail will default to the ???latest???, which is generally what you???d want.
Of all options, only the shopper???s IP address is optional. But since it???s used in various risk checks, it???s a good idea to supply it anyway.
140 141 142 143 144 145 146 147 |
# File 'lib/adyen/api.rb', line 140 def (reference, amount, shopper, recurring_detail_reference = 'LATEST') PaymentService.new( :reference => reference, :amount => amount, :shopper => shopper, :recurring_detail_reference => recurring_detail_reference ). end |
- (PaymentService::CancelOrRefundResponse) cancel_or_refund_payment(psp_reference)
Cancel or refund a payment. Use this if you want to cancel or refund the payment, but are unsure what the current status is.
Note that the response of this request will only indicate whether or not the request has been successfuly received. Check the notitification for the actual mutation status.
248 249 250 |
# File 'lib/adyen/api.rb', line 248 def cancel_or_refund_payment(psp_reference) PaymentService.new(:psp_reference => psp_reference).cancel_or_refund end |
- (PaymentService::CancelResponse) cancel_payment(psp_reference)
Cancel an authorised payment.
Note that the response of this request will only indicate whether or not the request has been successfuly received. Check the notitification for the actual mutation status.
262 263 264 |
# File 'lib/adyen/api.rb', line 262 def cancel_payment(psp_reference) PaymentService.new(:psp_reference => psp_reference).cancel end |
- (PaymentService::CaptureResponse) capture_payment(psp_reference, amount)
Capture an authorised payment.
You can also configure your merchant account to automatically capture authorised payments in the merchant account settings.
Note that the response of this request will only indicate whether or not the request has been successfuly received. Check the notitification for the actual mutation status.
215 216 217 |
# File 'lib/adyen/api.rb', line 215 def capture_payment(psp_reference, amount) PaymentService.new(:psp_reference => psp_reference, :amount => amount).capture end |
- (RecurringService::DisableResponse) disable_recurring_contract(shopper_reference, recurring_detail_reference = nil)
Disable the recurring contract details for a shopper.
284 285 286 287 288 289 |
# File 'lib/adyen/api.rb', line 284 def disable_recurring_contract(shopper_reference, recurring_detail_reference = nil) RecurringService.new({ :shopper => { :reference => shopper_reference }, :recurring_detail_reference => recurring_detail_reference }).disable end |
- (RecurringService::ListResponse) list_recurring_details(shopper_reference)
Retrieve the recurring contract details for a shopper.
272 273 274 |
# File 'lib/adyen/api.rb', line 272 def list_recurring_details(shopper_reference) RecurringService.new(:shopper => { :reference => shopper_reference }).list end |
- (PaymentService::RefundResponse) refund_payment(psp_reference, amount)
Refund a captured payment.
Note that the response of this request will only indicate whether or not the request has been successfuly received. Check the notitification for the actual mutation status.
233 234 235 |
# File 'lib/adyen/api.rb', line 233 def refund_payment(psp_reference, amount) PaymentService.new(:psp_reference => psp_reference, :amount => amount).refund end |
- (RecurringService::StoreTokenResponse) store_recurring_token(shopper, params)
Stores and tokenises the payment details so that recurring payments can be made in the future. It can be either a credit card or ELV (Elektronisches Lastschriftverfahren).
For instance, this is how you would store credit card details:
# @example
response = Adyen::API.store_recurring_token(
{ :reference => user.id, :email => user.email, :ip => '8.8.8.8', :statement => 'invoice number 123456' },
{ :holder_name => "Simon Hopper", :number => '4444333322221111',
:expiry_month => 12, :expiry_year => 2012 }
)
Or use the following to store ELV details:
# @example
response = Adyen::API.store_recurring_token(
{ :reference => user.id, :email => user.email, :ip => '8.8.8.8', :statement => 'invoice number 123456' },
{ :bank_location => "Berlin", :bank_name => "TestBank", :bank_location_id => "12345678",
:holder_name => "Simon Hopper", :number => "1234567890" }
)
response.stored? # => true
# Now we can authorize a payment with the token.
= Adyen::API.(
invoice.id,
{ :currency => 'EUR', :value => invoice.amount },
{ :reference => user.id, :email => user.email, :ip => '8.8.8.8', :statement => 'invoice number 123456' },
response.recurring_detail_reference
)
. # => true
##### Credit card specific options:
##### ELV specific options:
346 347 348 349 350 351 352 |
# File 'lib/adyen/api.rb', line 346 def store_recurring_token(shopper, params) payment_method = params.include?(:bank_location_id) ? :elv : :card RecurringService.new({ :shopper => shopper, payment_method => params }).store_token end |