adyen 0.3.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/.kick +35 -0
- data/LICENSE +3 -2
- data/README.rdoc +8 -4
- data/Rakefile +10 -0
- data/TODO +14 -4
- data/adyen.gemspec +9 -15
- data/lib/adyen.rb +10 -59
- data/lib/adyen/api.rb +281 -0
- data/lib/adyen/api/cacert.pem +3509 -0
- data/lib/adyen/api/payment_service.rb +258 -0
- data/lib/adyen/api/recurring_service.rb +126 -0
- data/lib/adyen/api/response.rb +54 -0
- data/lib/adyen/api/simple_soap_client.rb +118 -0
- data/lib/adyen/api/templates/payment_service.rb +103 -0
- data/lib/adyen/api/templates/recurring_service.rb +34 -0
- data/lib/adyen/api/test_helpers.rb +133 -0
- data/lib/adyen/api/xml_querier.rb +94 -0
- data/lib/adyen/configuration.rb +139 -0
- data/lib/adyen/form.rb +37 -109
- data/lib/adyen/formatter.rb +0 -10
- data/lib/adyen/matchers.rb +1 -1
- data/lib/adyen/notification_generator.rb +30 -0
- data/lib/adyen/railtie.rb +13 -0
- data/lib/adyen/templates/notification_migration.rb +29 -0
- data/lib/adyen/templates/notification_model.rb +70 -0
- data/spec/adyen_spec.rb +3 -45
- data/spec/api/api_spec.rb +139 -0
- data/spec/api/payment_service_spec.rb +439 -0
- data/spec/api/recurring_service_spec.rb +105 -0
- data/spec/api/response_spec.rb +35 -0
- data/spec/api/simple_soap_client_spec.rb +91 -0
- data/spec/api/spec_helper.rb +417 -0
- data/spec/api/test_helpers_spec.rb +83 -0
- data/spec/form_spec.rb +27 -23
- data/spec/functional/api_spec.rb +90 -0
- data/spec/functional/initializer.rb.sample +3 -0
- data/spec/spec_helper.rb +5 -5
- data/tasks/github-gem.rake +49 -55
- data/yard_extensions.rb +16 -0
- metadata +63 -82
- data/init.rb +0 -1
- data/lib/adyen/notification.rb +0 -151
- data/lib/adyen/soap.rb +0 -649
- data/spec/notification_spec.rb +0 -97
- data/spec/soap_spec.rb +0 -340
data/.gitignore
CHANGED
data/.kick
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
options.on('--doc', 'Also generate docs.') do
|
2
|
+
process do |files|
|
3
|
+
if files.any? { |f| f =~ /lib\/.+\.rb$/ }
|
4
|
+
execute "yardoc --no-private"
|
5
|
+
execute(%{osascript -e 'tell application "Safari"
|
6
|
+
do JavaScript "window.location.reload()" in first document
|
7
|
+
end tell'})
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
recipe :ruby
|
13
|
+
|
14
|
+
process do |files|
|
15
|
+
specs = files.take_and_map do |file|
|
16
|
+
case file
|
17
|
+
when "spec/spec_helper.rb"
|
18
|
+
Dir.glob("spec/**/*_spec.rb")
|
19
|
+
when "spec/api/spec_helper.rb"
|
20
|
+
Dir.glob("spec/api/*_spec.rb")
|
21
|
+
when "lib/adyen/api.rb"
|
22
|
+
"spec/api/api_spec.rb"
|
23
|
+
when "lib/adyen/api/xml_querier.rb"
|
24
|
+
["spec/api/payment_service_spec.rb", "spec/api/recurring_service_spec.rb"]
|
25
|
+
when "lib/adyen/api/simple_soap_client.rb"
|
26
|
+
["spec/api/simple_soap_client_spec.rb", "spec/api/payment_service_spec.rb", "spec/api/recurring_service_spec.rb"]
|
27
|
+
when "lib/adyen/api/response.rb"
|
28
|
+
["spec/api/response_spec.rb", "spec/api/payment_service_spec.rb", "spec/api/recurring_service_spec.rb"]
|
29
|
+
when %r{lib/adyen/api/templates/(.+)\.rb$}, %r{lib/adyen/api/(.+)\.rb$}
|
30
|
+
"spec/api/#{$1}_spec.rb"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
Ruby.run_tests(specs)
|
34
|
+
end
|
35
|
+
|
data/LICENSE
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
Copyright (c) 2008 -
|
1
|
+
Copyright (c) 2008 - 2011
|
2
|
+
Willem van Bergen, Michel Barbosa, Stefan Borsje & Eloy Duran
|
2
3
|
|
3
4
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
5
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +18,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
18
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
19
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
20
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -24,11 +24,15 @@ to make the Adyen functionality available in your Rails project:
|
|
24
24
|
|
25
25
|
config.gem 'adyen'
|
26
26
|
|
27
|
-
|
27
|
+
The Adyen gem will happily use REXML for communication with Adyen’s SOAP API, however, if
|
28
|
+
you have the Nokogiri gem installed and required the gem will use that for performance.
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
== Generators
|
31
|
+
|
32
|
+
The gem ships with a generator for Rails 3. To create an ActiveRecord migration, mode, and
|
33
|
+
ActionController for the notifications send by Adyen, run the following:
|
34
|
+
|
35
|
+
$ rails generate adyen:notification
|
32
36
|
|
33
37
|
== Usage
|
34
38
|
|
data/Rakefile
CHANGED
@@ -2,4 +2,14 @@ Dir[File.dirname(__FILE__) + "/tasks/*.rake"].each { |file| load(file) }
|
|
2
2
|
|
3
3
|
GithubGem::RakeTasks.new(:gem)
|
4
4
|
|
5
|
+
begin
|
6
|
+
require 'rubygems'
|
7
|
+
require 'yard'
|
8
|
+
require File.expand_path('../yard_extensions', __FILE__)
|
9
|
+
YARD::Rake::YardocTask.new do |y|
|
10
|
+
y.options << '--no-private' << '--title' << 'The ‘Adyen payment service’ library for Ruby'
|
11
|
+
end
|
12
|
+
rescue LoadError
|
13
|
+
end
|
14
|
+
|
5
15
|
task :default => "spec:specdoc"
|
data/TODO
CHANGED
@@ -1,7 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
*
|
1
|
+
1.0
|
2
|
+
===
|
3
|
+
|
4
|
+
* Screen documentation
|
5
|
+
|
6
|
+
Possible/Later
|
7
|
+
==============
|
8
|
+
|
9
|
+
* Add a capture! method to an authorisation response from the PaymentService.
|
10
|
+
|
11
|
+
* Add iDEAL API. To get started, see the `iDEAL' topic-branch which contains `ideal-scratchpad.rb' and a stub for a functional spec.
|
12
|
+
|
13
|
+
* Add the DirectDebit API.
|
14
|
+
|
5
15
|
* Add ActiveMerchant integration
|
6
16
|
|
7
17
|
* Split up gem to have more explicit dependency requirements, e.g.:
|
data/adyen.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'adyen'
|
3
|
-
s.version = "0.
|
4
|
-
s.date = "
|
3
|
+
s.version = "1.0.0"
|
4
|
+
s.date = "2011-01-22"
|
5
5
|
|
6
6
|
s.summary = "Integrate Adyen payment services in your Ruby on Rails application."
|
7
7
|
s.description = <<-EOS
|
@@ -13,24 +13,18 @@ Gem::Specification.new do |s|
|
|
13
13
|
|
14
14
|
s.authors = ['Willem van Bergen', 'Michel Barbosa', 'Stefan Borsje', 'Eloy Duran']
|
15
15
|
s.email = ['willem@vanbergen.org', 'cicaboo@gmail.com', 'mail@sborsje.nl', 'eloy.de.enige@gmail.com']
|
16
|
-
s.homepage = 'http://
|
16
|
+
s.homepage = 'http://github.com/wvanbergen/adyen/wiki'
|
17
17
|
|
18
18
|
s.add_development_dependency('rake')
|
19
|
-
s.add_development_dependency('rspec', '
|
20
|
-
s.add_development_dependency('git', '>= 1.1.0')
|
21
|
-
s.add_development_dependency('gemcutter')
|
22
|
-
|
23
|
-
# Drop or make runtime dependency.
|
24
|
-
s.add_development_dependency('activerecord')
|
25
|
-
s.add_development_dependency('handsoap')
|
19
|
+
s.add_development_dependency('rspec', '~> 2.0')
|
26
20
|
s.add_development_dependency('nokogiri')
|
27
|
-
|
28
|
-
|
29
|
-
s.requirements << '
|
21
|
+
s.add_development_dependency('rails', '>= 2.3')
|
22
|
+
|
23
|
+
s.requirements << 'Having Nokogiri installed will speed up XML handling when using the SOAP API.'
|
30
24
|
|
31
25
|
s.rdoc_options << '--title' << s.name << '--main' << 'README.rdoc' << '--line-numbers' << '--inline-source'
|
32
26
|
s.extra_rdoc_files = ['README.rdoc']
|
33
27
|
|
34
|
-
s.files = %w(
|
35
|
-
s.test_files = %w(spec/adyen_spec.rb spec/
|
28
|
+
s.files = %w(.gitignore .kick LICENSE README.rdoc Rakefile TODO adyen.gemspec lib/adyen.rb lib/adyen/api.rb lib/adyen/api/cacert.pem lib/adyen/api/payment_service.rb lib/adyen/api/recurring_service.rb lib/adyen/api/response.rb lib/adyen/api/simple_soap_client.rb lib/adyen/api/templates/payment_service.rb lib/adyen/api/templates/recurring_service.rb lib/adyen/api/test_helpers.rb lib/adyen/api/xml_querier.rb lib/adyen/configuration.rb lib/adyen/encoding.rb lib/adyen/form.rb lib/adyen/formatter.rb lib/adyen/matchers.rb lib/adyen/notification_generator.rb lib/adyen/railtie.rb lib/adyen/templates/notification_migration.rb lib/adyen/templates/notification_model.rb spec/adyen_spec.rb spec/api/api_spec.rb spec/api/payment_service_spec.rb spec/api/recurring_service_spec.rb spec/api/response_spec.rb spec/api/simple_soap_client_spec.rb spec/api/spec_helper.rb spec/api/test_helpers_spec.rb spec/form_spec.rb spec/functional/api_spec.rb spec/functional/initializer.rb.sample spec/spec_helper.rb tasks/github-gem.rake yard_extensions.rb)
|
29
|
+
s.test_files = %w(spec/adyen_spec.rb spec/api/api_spec.rb spec/api/payment_service_spec.rb spec/api/recurring_service_spec.rb spec/api/response_spec.rb spec/api/simple_soap_client_spec.rb spec/api/test_helpers_spec.rb spec/form_spec.rb spec/functional/api_spec.rb)
|
36
30
|
end
|
data/lib/adyen.rb
CHANGED
@@ -5,73 +5,24 @@
|
|
5
5
|
# The most important submodules are:
|
6
6
|
# * {Adyen::Form} for generating payment form fields, generating redirect URLs
|
7
7
|
# to the Adyen payment system, and generating and checking of signatures.
|
8
|
-
# * {Adyen::
|
9
|
-
#
|
10
|
-
# maintenance and issuing recurring payments.
|
8
|
+
# * {Adyen::API} for communicating with the Adyen SOAP services for issuing
|
9
|
+
# (recurring) payments and recurring contract maintenance.
|
11
10
|
module Adyen
|
12
11
|
|
13
12
|
# Version constant for the Adyen plugin.
|
14
13
|
# DO NOT CHANGE THIS VALUE BY HAND. It will be updated automatically by
|
15
14
|
# the gem:release rake task.
|
16
|
-
VERSION = "0.
|
15
|
+
VERSION = "1.0.0"
|
17
16
|
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
# @param [Module] mod The current working module. This parameter is used
|
22
|
-
# to recursively traverse the hash for submodules.
|
23
|
-
# @raise [StandardError] An exception is raised of an unkown configuration
|
24
|
-
# setting is encountered in the hash.
|
25
|
-
def self.load_config(hash, mod = Adyen)
|
26
|
-
hash.each do |key, value|
|
27
|
-
if key.to_s =~ /^[a-z]/ && mod.respond_to?(:"#{key}=")
|
28
|
-
mod.send(:"#{key}=", value)
|
29
|
-
elsif key.to_s =~ /^[A-Z]/
|
30
|
-
self.load_config(value, mod.const_get(key))
|
31
|
-
else
|
32
|
-
raise "Unknown configuration variable: '#{key}' for #{mod}"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# The Rails environment for which to use to Adyen "live" environment.
|
38
|
-
LIVE_RAILS_ENVIRONMENTS = ['production']
|
39
|
-
|
40
|
-
# Setter voor the current Adyen environment.
|
41
|
-
# @param ['test', 'live'] env The Adyen environment to use
|
42
|
-
def self.environment=(env)
|
43
|
-
@environment = env
|
44
|
-
end
|
45
|
-
|
46
|
-
# Returns the current Adyen environment, either test or live.
|
47
|
-
#
|
48
|
-
# It will return the +override+ value if set, it will return the value set
|
49
|
-
# using {Adyen.environment=} otherwise. If this value also isn't set, the
|
50
|
-
# environment is determined with {Adyen.autodetect_environment}.
|
51
|
-
#
|
52
|
-
# @param ['test', 'live'] override An environment to override the default with.
|
53
|
-
# @return ['test', 'live'] The Adyen environment that is currently being used.
|
54
|
-
def self.environment(override = nil)
|
55
|
-
override || @environment || Adyen.autodetect_environment
|
56
|
-
end
|
57
|
-
|
58
|
-
# Autodetects the Adyen environment based on the RAILS_ENV constant.
|
59
|
-
# @return ['test', 'live'] The Adyen environment that corresponds to the Rails environment
|
60
|
-
def self.autodetect_environment
|
61
|
-
(defined?(RAILS_ENV) && Adyen::LIVE_RAILS_ENVIRONMENTS.include?(RAILS_ENV.to_s.downcase)) ? 'live' : 'test'
|
62
|
-
end
|
63
|
-
|
64
|
-
# Loads submodules on demand, so that dependencies are not required.
|
65
|
-
# @param [Symbol] sym The name of the submodule
|
66
|
-
# @return [Module] The actual loaded submodule.
|
67
|
-
# @raise [LoadError, NameError] If the submodule cannot be loaded
|
68
|
-
def self.const_missing(sym)
|
69
|
-
require "adyen/#{sym.to_s.downcase}"
|
70
|
-
return Adyen.const_get(sym)
|
71
|
-
rescue Exception
|
72
|
-
super(sym)
|
17
|
+
# @return [Configuration] The configuration singleton.
|
18
|
+
def self.configuration
|
19
|
+
@configuration ||= Adyen::Configuration.new
|
73
20
|
end
|
74
21
|
end
|
75
22
|
|
23
|
+
require 'adyen/configuration'
|
76
24
|
require 'adyen/encoding'
|
77
25
|
require 'adyen/formatter'
|
26
|
+
require 'adyen/form'
|
27
|
+
|
28
|
+
require 'adyen/railtie' if defined?(::Rails) && ::Rails::VERSION::MAJOR >= 3
|
data/lib/adyen/api.rb
ADDED
@@ -0,0 +1,281 @@
|
|
1
|
+
require 'adyen'
|
2
|
+
require 'adyen/api/simple_soap_client'
|
3
|
+
require 'adyen/api/payment_service'
|
4
|
+
require 'adyen/api/recurring_service'
|
5
|
+
|
6
|
+
module Adyen
|
7
|
+
# The API module contains classes that interact with the Adyen SOAP API.
|
8
|
+
#
|
9
|
+
# You'll need to provide a username and password to interact with Adyen:
|
10
|
+
#
|
11
|
+
# Adyen.configuration.api_username = 'ws@Company.MyAccount'
|
12
|
+
# Adyen.configuration.api_password = 'secret'
|
13
|
+
#
|
14
|
+
# Furthermore, you can setup default parameters, which will be used by every API call, by using
|
15
|
+
# {Adyen::API.default_arguments}.
|
16
|
+
#
|
17
|
+
# The following classes, which handle the SOAP services, are available:
|
18
|
+
#
|
19
|
+
# * {PaymentService} - for authorisation of, and modification to, payments.
|
20
|
+
# * {RecurringService} - for handling recurring contract details.
|
21
|
+
#
|
22
|
+
# *However*, direct use of these classes is discouraged in favor of the shortcut methods defined
|
23
|
+
# on the API module. These methods *expect* that you set the :merchant_account as a default
|
24
|
+
# parameter.
|
25
|
+
#
|
26
|
+
# Note that you'll need an Adyen notification PSP reference for some of the calls. Because of
|
27
|
+
# this, store all notifications that Adyen sends to you. Moreover, the responses to these calls
|
28
|
+
# do *not* tell you whether or not the requested action was successful. For this you will also
|
29
|
+
# have to check the notification.
|
30
|
+
#
|
31
|
+
# = Authorising payments
|
32
|
+
#
|
33
|
+
# To authorise payments, not recurring ones, the customers payment details will have to pass
|
34
|
+
# through your application’s infrastucture. Because of this you will have to contact Adyen and
|
35
|
+
# provide the necessary paperwork which says that you’re PCI DSS compliant, before you are given
|
36
|
+
# access to Adyen’s API.
|
37
|
+
#
|
38
|
+
# Unless you are going to process over twenty thousand payments anually, the PCI DSS
|
39
|
+
# Self-Assessment Questionnaire (SAQ) type A will _probably_ suffice.
|
40
|
+
#
|
41
|
+
# @see http://en.wikipedia.org/wiki/Payment_Card_Industry_Data_Security_Standard
|
42
|
+
# @see https://www.pcisecuritystandards.org/saq/instructions_dss.shtml
|
43
|
+
# @see http://usa.visa.com/merchants/risk_management/cisp_merchants.html
|
44
|
+
module API
|
45
|
+
extend self
|
46
|
+
|
47
|
+
# Authorise a payment.
|
48
|
+
#
|
49
|
+
# @see capture_payment
|
50
|
+
#
|
51
|
+
# Of all options, only the details are optional. But since the IP is’s used in various risk
|
52
|
+
# checks, and the email and reference are needed to enable recurring contract, it’s a good
|
53
|
+
# idea to supply it anyway.
|
54
|
+
#
|
55
|
+
# @example
|
56
|
+
# response = Adyen::API.authorise_payment(
|
57
|
+
# invoice.id,
|
58
|
+
# { :currency => 'EUR', :value => invoice.amount },
|
59
|
+
# { :reference => user.id, :email => user.email, :ip => '8.8.8.8' },
|
60
|
+
# { :holder_name => "Simon Hopper", :number => '4444333322221111', :cvc => '737', :expiry_month => 12, :expiry_year => 2012 }
|
61
|
+
# )
|
62
|
+
# response.authorised? # => true
|
63
|
+
#
|
64
|
+
# @param [Numeric,String] reference Your reference (ID) for this payment.
|
65
|
+
# @param [Hash] amount A hash describing the money to charge.
|
66
|
+
# @param [Hash] shopper A hash describing the shopper.
|
67
|
+
# @param [Hash] card A hash describing the creditcard details.
|
68
|
+
#
|
69
|
+
# @option amount [String] :currency The ISO currency code (EUR, GBP, USD, etc).
|
70
|
+
# @option amount [Integer] :value The value of the payment in discrete cents,
|
71
|
+
# unless the currency does not have cents.
|
72
|
+
#
|
73
|
+
# @option shopper [Numeric,String] :reference The shopper’s reference (ID).
|
74
|
+
# @option shopper [String] :email The shopper’s email address.
|
75
|
+
# @option shopper [String] :ip The shopper’s IP address.
|
76
|
+
#
|
77
|
+
# @option card [String] :holder_name The full name on the card.
|
78
|
+
# @option card [String] :number The card number.
|
79
|
+
# @option card [String] :cvc The card’s verification code.
|
80
|
+
# @option card [Numeric,String] :expiry_month The month in which the card expires.
|
81
|
+
# @option card [Numeric,String] :expiry_year The year in which the card expires.
|
82
|
+
#
|
83
|
+
# @param [Boolean] enable_recurring_contract Store the payment details at Adyen for
|
84
|
+
# future recurring or one-click payments.
|
85
|
+
#
|
86
|
+
# @return [PaymentService::AuthorisationResponse] The response object which holds the
|
87
|
+
# authorisation status.
|
88
|
+
def authorise_payment(reference, amount, shopper, card, enable_recurring_contract = false)
|
89
|
+
PaymentService.new(
|
90
|
+
:reference => reference,
|
91
|
+
:amount => amount,
|
92
|
+
:shopper => shopper,
|
93
|
+
:card => card,
|
94
|
+
:recurring => enable_recurring_contract
|
95
|
+
).authorise_payment
|
96
|
+
end
|
97
|
+
|
98
|
+
# Authorise a recurring payment. The contract detail will default to the ‘+latest+’, which
|
99
|
+
# is generally what you’d want.
|
100
|
+
#
|
101
|
+
# @see capture_payment
|
102
|
+
#
|
103
|
+
# Of all options, only the shopper’s IP address is optional. But since it’s used in various
|
104
|
+
# risk checks, it’s a good idea to supply it anyway.
|
105
|
+
#
|
106
|
+
# @example
|
107
|
+
# response = Adyen::API.authorise_recurring_payment(
|
108
|
+
# invoice.id,
|
109
|
+
# { :currency => 'EUR', :value => invoice.amount },
|
110
|
+
# { :reference => user.id, :email => user.email, :ip => '8.8.8.8' }
|
111
|
+
# )
|
112
|
+
# response.authorised? # => true
|
113
|
+
#
|
114
|
+
# @param [Numeric,String] reference Your reference (ID) for this payment.
|
115
|
+
# @param [Hash] amount A hash describing the money to charge.
|
116
|
+
# @param [Hash] shopper A hash describing the shopper.
|
117
|
+
#
|
118
|
+
# @option amount [String] :currency The ISO currency code (EUR, GBP, USD, etc).
|
119
|
+
# @option amount [Integer] :value The value of the payment in discrete cents,
|
120
|
+
# unless the currency does not have cents.
|
121
|
+
#
|
122
|
+
# @option shopper [Numeric,String] :reference The shopper’s reference (ID).
|
123
|
+
# @option shopper [String] :email The shopper’s email address.
|
124
|
+
# @option shopper [String] :ip The shopper’s IP address.
|
125
|
+
#
|
126
|
+
# @param [String] recurring_detail_reference The recurring contract reference to use.
|
127
|
+
# @see list_recurring_details
|
128
|
+
#
|
129
|
+
# @return [PaymentService::AuthorisationResponse] The response object which holds the
|
130
|
+
# authorisation status.
|
131
|
+
def authorise_recurring_payment(reference, amount, shopper, recurring_detail_reference = 'LATEST')
|
132
|
+
PaymentService.new(
|
133
|
+
:reference => reference,
|
134
|
+
:amount => amount,
|
135
|
+
:shopper => shopper,
|
136
|
+
:recurring_detail_reference => recurring_detail_reference
|
137
|
+
).authorise_recurring_payment
|
138
|
+
end
|
139
|
+
|
140
|
+
# Authorise a ‘one-click’ payment. A specific contract detail *has* to be specified.
|
141
|
+
#
|
142
|
+
# @see capture_payment
|
143
|
+
#
|
144
|
+
# Of all options, only the shopper’s IP address is optional. But since it’s used in various
|
145
|
+
# risk checks, it’s a good idea to supply it anyway.
|
146
|
+
#
|
147
|
+
# @example
|
148
|
+
# detail = Adyen::API.list_recurring_details(user.id).details.last[:recurring_detail_reference]
|
149
|
+
# payment = Adyen::API.authorise_one_click_payment(
|
150
|
+
# invoice.id,
|
151
|
+
# { :currency => 'EUR', :value => invoice.amount },
|
152
|
+
# { :reference => user.id, :email => user.email, :ip => '8.8.8.8' },
|
153
|
+
# '737',
|
154
|
+
# detail
|
155
|
+
# )
|
156
|
+
# payment.authorised? # => true
|
157
|
+
#
|
158
|
+
# @param [Numeric,String] reference Your reference (ID) for this payment.
|
159
|
+
# @param [Hash] amount A hash describing the money to charge.
|
160
|
+
# @param [Hash] shopper A hash describing the shopper.
|
161
|
+
# @param [String] card_cvc The card’s verification code.
|
162
|
+
#
|
163
|
+
# @option amount [String] :currency The ISO currency code (EUR, GBP, USD, etc).
|
164
|
+
# @option amount [Integer] :value The value of the payment in discrete cents,
|
165
|
+
# unless the currency does not have cents.
|
166
|
+
#
|
167
|
+
# @option shopper [Numeric,String] :reference The shopper’s reference (ID).
|
168
|
+
# @option shopper [String] :email The shopper’s email address.
|
169
|
+
# @option shopper [String] :ip The shopper’s IP address.
|
170
|
+
#
|
171
|
+
# @param [String] recurring_detail_reference The recurring contract reference to use.
|
172
|
+
# @see list_recurring_details
|
173
|
+
#
|
174
|
+
# @return [PaymentService::AuthorisationResponse] The response object which holds the
|
175
|
+
# authorisation status.
|
176
|
+
def authorise_one_click_payment(reference, amount, shopper, card_cvc, recurring_detail_reference)
|
177
|
+
PaymentService.new(
|
178
|
+
:reference => reference,
|
179
|
+
:amount => amount,
|
180
|
+
:shopper => shopper,
|
181
|
+
:card => { :cvc => card_cvc },
|
182
|
+
:recurring_detail_reference => recurring_detail_reference
|
183
|
+
).authorise_one_click_payment
|
184
|
+
end
|
185
|
+
|
186
|
+
# Capture an authorised payment.
|
187
|
+
#
|
188
|
+
# You can also configure your merchant account to automatically capture authorised payments
|
189
|
+
# in the merchant account settings.
|
190
|
+
#
|
191
|
+
# @see https://ca-test.adyen.com/ca/ca/accounts/manageMerchantAccount.shtml
|
192
|
+
#
|
193
|
+
# Note that the response of this request will only indicate whether or
|
194
|
+
# not the request has been successfuly received. Check the notitification
|
195
|
+
# for the actual mutation status.
|
196
|
+
#
|
197
|
+
# @param [String] psp_reference The PSP reference, from Adyen, of the
|
198
|
+
# previously authorised request.
|
199
|
+
# @param [Hash] amount A hash describing the money to charge.
|
200
|
+
# @option amount [String] :currency The ISO currency code (EUR, GBP, USD, etc).
|
201
|
+
# @option amount [Integer] :value The value of the payment in discrete cents,
|
202
|
+
# unless the currency does not have cents.
|
203
|
+
#
|
204
|
+
# @return [PaymentService::CaptureResponse] The response object.
|
205
|
+
def capture_payment(psp_reference, amount)
|
206
|
+
PaymentService.new(:psp_reference => psp_reference, :amount => amount).capture
|
207
|
+
end
|
208
|
+
|
209
|
+
# Refund a captured payment.
|
210
|
+
#
|
211
|
+
# Note that the response of this request will only indicate whether or
|
212
|
+
# not the request has been successfuly received. Check the notitification
|
213
|
+
# for the actual mutation status.
|
214
|
+
#
|
215
|
+
# @param [String] psp_reference The PSP reference, from Adyen, of the
|
216
|
+
# previously authorised request.
|
217
|
+
# @param [Hash] amount A hash describing the money to charge.
|
218
|
+
# @option amount [String] :currency The ISO currency code (EUR, GBP, USD, etc).
|
219
|
+
# @option amount [Integer] :value The value of the payment in discrete cents,
|
220
|
+
# unless the currency does not have cents.
|
221
|
+
#
|
222
|
+
# @return [PaymentService::RefundResponse] The response object.
|
223
|
+
def refund_payment(psp_reference, amount)
|
224
|
+
PaymentService.new(:psp_reference => psp_reference, :amount => amount).refund
|
225
|
+
end
|
226
|
+
|
227
|
+
# Cancel or refund a payment. Use this if you want to cancel or refund
|
228
|
+
# the payment, but are unsure what the current status is.
|
229
|
+
#
|
230
|
+
# Note that the response of this request will only indicate whether or
|
231
|
+
# not the request has been successfuly received. Check the notitification
|
232
|
+
# for the actual mutation status.
|
233
|
+
#
|
234
|
+
# @param [String] psp_reference The PSP reference, from Adyen, of the
|
235
|
+
# previously authorised request.
|
236
|
+
#
|
237
|
+
# @return [PaymentService::CancelOrRefundResponse] The response object.
|
238
|
+
def cancel_or_refund_payment(psp_reference)
|
239
|
+
PaymentService.new(:psp_reference => psp_reference).cancel_or_refund
|
240
|
+
end
|
241
|
+
|
242
|
+
# Cancel an authorised payment.
|
243
|
+
#
|
244
|
+
# Note that the response of this request will only indicate whether or
|
245
|
+
# not the request has been successfuly received. Check the notitification
|
246
|
+
# for the actual mutation status.
|
247
|
+
#
|
248
|
+
# @param [String] psp_reference The PSP reference, from Adyen, of the
|
249
|
+
# previously authorised request.
|
250
|
+
#
|
251
|
+
# @return [PaymentService::CancelResponse] The response object.
|
252
|
+
def cancel_payment(psp_reference)
|
253
|
+
PaymentService.new(:psp_reference => psp_reference).cancel
|
254
|
+
end
|
255
|
+
|
256
|
+
# Retrieve the recurring contract details for a shopper.
|
257
|
+
#
|
258
|
+
# @param [String] shopper_reference The ID used to store payment details for
|
259
|
+
# this shopper.
|
260
|
+
#
|
261
|
+
# @return [RecurringService::ListResponse] The response object.
|
262
|
+
def list_recurring_details(shopper_reference)
|
263
|
+
RecurringService.new(:shopper => { :reference => shopper_reference }).list
|
264
|
+
end
|
265
|
+
|
266
|
+
# Disable the recurring contract details for a shopper.
|
267
|
+
#
|
268
|
+
# @param [String] shopper_reference The ID used to store payment details for
|
269
|
+
# this shopper.
|
270
|
+
# @param [String,nil] recurring_detail_reference The ID of a specific recurring contract.
|
271
|
+
# Defaults to all.
|
272
|
+
#
|
273
|
+
# @return [RecurringService::DisableResponse] The response object.
|
274
|
+
def disable_recurring_contract(shopper_reference, recurring_detail_reference = nil)
|
275
|
+
RecurringService.new({
|
276
|
+
:shopper => { :reference => shopper_reference },
|
277
|
+
:recurring_detail_reference => recurring_detail_reference
|
278
|
+
}).disable
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|