adyen 2.2.0 → 2.3.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.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.travis.yml +12 -5
- data/CHANGELOG.md +5 -2
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +4 -0
- data/README.md +0 -2
- data/Rakefile +2 -8
- data/adyen.gemspec +4 -5
- data/lib/adyen/api.rb +14 -10
- data/lib/adyen/api/payment_service.rb +35 -4
- data/lib/adyen/api/templates/payment_service.rb +5 -0
- data/lib/adyen/form.rb +1 -1
- data/lib/adyen/hpp/request.rb +8 -6
- data/lib/adyen/rest.rb +21 -8
- data/lib/adyen/rest/client.rb +13 -0
- data/lib/adyen/templates/notification_migration.rb +1 -1
- data/lib/adyen/templates/notification_model.rb +2 -2
- data/lib/adyen/version.rb +1 -1
- data/{spec/functional/api_spec.rb → test/functional/api_test.rb} +38 -33
- data/{spec → test}/functional/initializer.rb.ci +0 -0
- data/{spec → test}/functional/initializer.rb.sample +0 -0
- data/test/helpers/views/hpp.erb +15 -15
- data/test/test_helper.rb +1 -0
- data/{spec/api/api_spec.rb → test/unit/api/api_test.rb} +7 -7
- data/{spec/api/payment_service_spec.rb → test/unit/api/payment_service_test.rb} +149 -117
- data/{spec/api/recurring_service_spec.rb → test/unit/api/recurring_service_test.rb} +49 -46
- data/{spec/api/response_spec.rb → test/unit/api/response_test.rb} +12 -12
- data/{spec/api/simple_soap_client_spec.rb → test/unit/api/simple_soap_client_test.rb} +27 -30
- data/{spec/api/spec_helper.rb → test/unit/api/test_helper.rb} +44 -35
- data/{spec/api/test_helpers_spec.rb → test/unit/api/test_helpers_test.rb} +11 -11
- data/test/{form_test.rb → unit/form_test.rb} +0 -0
- data/test/unit/hpp/request_test.rb +68 -0
- data/test/{hpp → unit/hpp}/signature_test.rb +0 -0
- data/test/{hpp_test.rb → unit/hpp_test.rb} +0 -0
- data/test/{rest → unit/rest}/signature_test.rb +0 -0
- data/test/{rest_list_recurring_details_response_test.rb → unit/rest_list_recurring_details_response_test.rb} +0 -0
- data/test/{rest_request_test.rb → unit/rest_request_test.rb} +0 -0
- data/test/{rest_response_test.rb → unit/rest_response_test.rb} +0 -0
- data/test/{signature_test.rb → unit/signature_test.rb} +0 -0
- data/test/{util_test.rb → unit/util_test.rb} +0 -0
- metadata +53 -61
- data/spec/spec_helper.rb +0 -8
@@ -23,8 +23,8 @@ class AdyenNotification < ActiveRecord::Base
|
|
23
23
|
validates_presence_of :psp_reference
|
24
24
|
|
25
25
|
# A notification should be unique using the composed key of
|
26
|
-
# [:psp_reference, :event_code, :success]
|
27
|
-
validates_uniqueness_of :success, :scope => [:psp_reference, :event_code]
|
26
|
+
# [:merchant_account_code, :psp_reference, :event_code, :success]
|
27
|
+
validates_uniqueness_of :success, :scope => [:merchant_account_code, :psp_reference, :event_code]
|
28
28
|
|
29
29
|
# Make sure we don't end up with an original_reference with an empty string
|
30
30
|
before_validation { |notification| notification.original_reference = nil if notification.original_reference.blank? }
|
data/lib/adyen/version.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require '
|
2
|
+
require 'test_helper'
|
3
3
|
require 'nokogiri'
|
4
|
+
require 'adyen/api'
|
4
5
|
|
5
6
|
API_SPEC_INITIALIZER = File.expand_path("../initializer.rb", __FILE__)
|
6
7
|
|
@@ -8,22 +9,6 @@ if File.exist?(API_SPEC_INITIALIZER)
|
|
8
9
|
|
9
10
|
describe Adyen::API, "with an actual remote connection" do
|
10
11
|
|
11
|
-
before :all do
|
12
|
-
require API_SPEC_INITIALIZER
|
13
|
-
Net::HTTP.stubbing_enabled = false
|
14
|
-
@order_id = @user_id = Time.now.to_i
|
15
|
-
@payment_response = perform_payment_request
|
16
|
-
end
|
17
|
-
|
18
|
-
after :all do
|
19
|
-
Net::HTTP.stubbing_enabled = true
|
20
|
-
end
|
21
|
-
|
22
|
-
it "performs a payment request" do
|
23
|
-
@payment_response.should be_authorized
|
24
|
-
@payment_response.psp_reference.should_not be_empty
|
25
|
-
end
|
26
|
-
|
27
12
|
def perform_payment_request
|
28
13
|
Adyen::API.authorise_payment(
|
29
14
|
@order_id,
|
@@ -34,17 +19,34 @@ if File.exist?(API_SPEC_INITIALIZER)
|
|
34
19
|
)
|
35
20
|
end
|
36
21
|
|
22
|
+
before :all do
|
23
|
+
require API_SPEC_INITIALIZER
|
24
|
+
@order_id = @user_id = Time.now.to_i
|
25
|
+
@payment_response = perform_payment_request
|
26
|
+
end
|
27
|
+
|
28
|
+
it "performs a payment request" do
|
29
|
+
skip("test is currently failing because it gets marked as fraud by Adyen")
|
30
|
+
|
31
|
+
@payment_response.must_be :authorized?
|
32
|
+
@payment_response.psp_reference.wont_be :empty?
|
33
|
+
end
|
34
|
+
|
37
35
|
it "performs a recurring payment request" do
|
36
|
+
skip("test is currently failing because it gets marked as fraud by Adyen")
|
37
|
+
|
38
38
|
response = Adyen::API.authorise_recurring_payment(
|
39
39
|
@order_id,
|
40
40
|
{ :currency => 'EUR', :value => '1234' },
|
41
41
|
{ :email => "#{@user_id}@example.com", :reference => @user_id }
|
42
42
|
)
|
43
|
-
response.
|
44
|
-
response.psp_reference.
|
43
|
+
response.must_be :authorized?
|
44
|
+
response.psp_reference.wont_be :empty?
|
45
45
|
end
|
46
46
|
|
47
47
|
it "performs a one-click payment request" do
|
48
|
+
skip("test is currently failing because it gets marked as fraud by Adyen")
|
49
|
+
|
48
50
|
detail = Adyen::API.list_recurring_details(@user_id).references.last
|
49
51
|
response = Adyen::API.authorise_one_click_payment(
|
50
52
|
@order_id,
|
@@ -53,8 +55,8 @@ if File.exist?(API_SPEC_INITIALIZER)
|
|
53
55
|
{ :cvc => '737' },
|
54
56
|
detail
|
55
57
|
)
|
56
|
-
response.
|
57
|
-
response.psp_reference.
|
58
|
+
response.must_be :authorized?
|
59
|
+
response.psp_reference.wont_be :empty?
|
58
60
|
end
|
59
61
|
|
60
62
|
it "stores the provided ELV account details" do
|
@@ -62,8 +64,8 @@ if File.exist?(API_SPEC_INITIALIZER)
|
|
62
64
|
{ :email => "#{@user_id}@example.com", :reference => @user_id },
|
63
65
|
{ :bank_location => "Berlin", :bank_name => "TestBank", :bank_location_id => "12345678", :holder_name => "Simon #{@user_id} Hopper", :number => "1234567890" }
|
64
66
|
)
|
65
|
-
response.
|
66
|
-
response.recurring_detail_reference.
|
67
|
+
response.must_be :stored?
|
68
|
+
response.recurring_detail_reference.wont_be :empty?
|
67
69
|
end
|
68
70
|
|
69
71
|
it "stores the provided creditcard details" do
|
@@ -71,34 +73,36 @@ if File.exist?(API_SPEC_INITIALIZER)
|
|
71
73
|
{ :email => "#{@user_id}@example.com", :reference => @user_id },
|
72
74
|
{ :expiry_month => '08', :expiry_year => '2018', :holder_name => "Simon #{@user_id} Hopper", :number => '4111111111111111' }
|
73
75
|
)
|
74
|
-
response.
|
75
|
-
response.recurring_detail_reference.
|
76
|
+
response.must_be :stored?
|
77
|
+
response.recurring_detail_reference.wont_be :empty?
|
76
78
|
end
|
77
79
|
|
78
80
|
it "disables a recurring contract" do
|
81
|
+
skip("test is currently failing because it depends on the skipped tests being run")
|
82
|
+
|
79
83
|
response = Adyen::API.disable_recurring_contract(@user_id)
|
80
|
-
response.
|
81
|
-
response.
|
84
|
+
response.must_be :success?
|
85
|
+
response.must_be :disabled?
|
82
86
|
end
|
83
87
|
|
84
88
|
it "captures a payment" do
|
85
89
|
response = Adyen::API.capture_payment(@payment_response.psp_reference, { :currency => 'EUR', :value => '1234' })
|
86
|
-
response.
|
90
|
+
response.must_be :success?
|
87
91
|
end
|
88
92
|
|
89
93
|
it "refunds a payment" do
|
90
94
|
response = Adyen::API.refund_payment(@payment_response.psp_reference, { :currency => 'EUR', :value => '1234' })
|
91
|
-
response.
|
95
|
+
response.must_be :success?
|
92
96
|
end
|
93
97
|
|
94
98
|
it "cancels or refunds a payment" do
|
95
99
|
response = Adyen::API.cancel_or_refund_payment(@payment_response.psp_reference)
|
96
|
-
response.
|
100
|
+
response.must_be :success?
|
97
101
|
end
|
98
102
|
|
99
103
|
it "cancels a payment" do
|
100
104
|
response = Adyen::API.cancel_payment(@payment_response.psp_reference)
|
101
|
-
response.
|
105
|
+
response.must_be :success?
|
102
106
|
end
|
103
107
|
|
104
108
|
it "generates a billet" do
|
@@ -107,8 +111,9 @@ if File.exist?(API_SPEC_INITIALIZER)
|
|
107
111
|
{ first_name: "Jow", last_name: "Silver" },
|
108
112
|
"19762003691",
|
109
113
|
"boletobancario_santander",
|
110
|
-
"2014-07-16T18:16:11Z"
|
111
|
-
|
114
|
+
"2014-07-16T18:16:11Z",
|
115
|
+
"free-text billet payment instructions")
|
116
|
+
response.must_be :success?
|
112
117
|
end
|
113
118
|
end
|
114
119
|
|
File without changes
|
File without changes
|
data/test/helpers/views/hpp.erb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
<html>
|
2
|
-
<head>
|
3
|
-
|
4
|
-
</head>
|
5
|
-
<body>
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
2
|
+
<head>
|
3
|
+
<title> HPP Payment</title>
|
4
|
+
</head>
|
5
|
+
<body>
|
6
|
+
<% hpp_request = Adyen::HPP::Request.new(@payment, environment: :test, skin: :testing) %>
|
7
|
+
<form action="<%= hpp_request.url %>" method="post">
|
8
|
+
<p> Price: <strong>EUR 43.21</strong>. </p>
|
9
|
+
<p>
|
10
|
+
<%= hpp_request.hidden_fields %>
|
11
|
+
<input type="submit" value="Pay" />
|
12
|
+
</p>
|
13
|
+
</form>
|
14
14
|
|
15
|
-
|
15
|
+
<p>If you are using the test account of this library, you will be redirected back
|
16
16
|
to <strong>example.com</strong> after you complete the payment on Adyen's hosted
|
17
17
|
payment pages. This is due to how the test account is configured.
|
18
|
-
|
19
|
-
</body>
|
18
|
+
</p>
|
19
|
+
</body>
|
20
20
|
</html>
|
data/test/test_helper.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require 'api/
|
2
|
+
require 'unit/api/test_helper'
|
3
3
|
|
4
4
|
describe Adyen::API do
|
5
5
|
include APISpecHelper
|
@@ -7,12 +7,12 @@ describe Adyen::API do
|
|
7
7
|
describe "shortcut methods" do
|
8
8
|
describe "for the PaymentService" do
|
9
9
|
before do
|
10
|
-
@payment =
|
10
|
+
@payment = mock('PaymentService')
|
11
11
|
end
|
12
12
|
|
13
13
|
def should_map_shortcut_to(method, params)
|
14
|
-
Adyen::API::PaymentService.
|
15
|
-
@payment.
|
14
|
+
Adyen::API::PaymentService.expects(:new).with(params).returns(@payment)
|
15
|
+
@payment.expects(method)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "performs a `authorise payment' request without enabling :recurring" do
|
@@ -182,12 +182,12 @@ describe Adyen::API do
|
|
182
182
|
|
183
183
|
describe "for the RecurringService" do
|
184
184
|
before do
|
185
|
-
@recurring =
|
185
|
+
@recurring = mock('RecurringService')
|
186
186
|
end
|
187
187
|
|
188
188
|
def should_map_shortcut_to(method, params)
|
189
|
-
Adyen::API::RecurringService.
|
190
|
-
@recurring.
|
189
|
+
Adyen::API::RecurringService.expects(:new).with(params).returns(@recurring)
|
190
|
+
@recurring.expects(method)
|
191
191
|
end
|
192
192
|
|
193
193
|
it "performs a `tokenize creditcard details' request" do
|
@@ -1,86 +1,107 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require 'api/
|
2
|
+
require 'unit/api/test_helper'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
module SharedExamples
|
5
|
+
def it_behaves_like_a_payment_request
|
6
|
+
it "includes the merchant account handle" do
|
7
|
+
text('./payment:merchantAccount').must_equal 'SuperShopper'
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
it "includes the payment reference of the merchant" do
|
11
|
+
text('./payment:reference').must_equal 'order-id'
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
it "includes the given amount of `currency'" do
|
15
|
+
xpath('./payment:amount') do |amount|
|
16
|
+
amount.text('./common:currency').must_equal 'EUR'
|
17
|
+
amount.text('./common:value').must_equal '1234'
|
18
|
+
end
|
17
19
|
end
|
18
|
-
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
it "includes the shopper's details" do
|
22
|
+
text('./payment:shopperReference').must_equal 'user-id'
|
23
|
+
text('./payment:shopperEmail').must_equal 's.hopper@example.com'
|
24
|
+
text('./payment:shopperIP').must_equal '61.294.12.12'
|
25
|
+
text('./payment:shopperStatement').must_equal 'invoice number 123456'
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
it "includes the fraud offset" do
|
29
|
+
text('./payment:fraudOffset').must_equal '30'
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
it "does not include the fraud offset if none is given" do
|
33
|
+
@payment.params.delete(:fraud_offset)
|
34
|
+
xpath('./payment:fraudOffset').must_be :empty?
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
it "includes the given amount of `installments'" do
|
38
|
+
xpath('./payment:installments') do |amount|
|
39
|
+
amount.text('./common:value').must_equal '6'
|
40
|
+
end
|
39
41
|
end
|
40
|
-
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
it "does not include the installments amount if none is given" do
|
44
|
+
@payment.params.delete(:installments)
|
45
|
+
xpath('./payment:installments').must_be :empty?
|
46
|
+
end
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
48
|
+
it "does not includes shopper reference if none set" do
|
49
|
+
# TODO pretty lame, but for now it will do
|
50
|
+
unless @method == "authorise_one_click_payment_request_body" || @method == "authorise_recurring_payment_request_body"
|
51
|
+
@payment.params[:shopper].delete(:reference)
|
52
|
+
xpath('./payment:shopperReference').must_be :empty?
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it "does not include shopper email if none given" do
|
57
|
+
# TODO pretty lame, but for now it will do
|
58
|
+
unless @method == "authorise_one_click_payment_request_body" || @method == "authorise_recurring_payment_request_body"
|
59
|
+
@payment.params[:shopper].delete(:email)
|
60
|
+
xpath('./payment:shopperEmail').must_be :empty?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it "does not include shopper IP if none given" do
|
65
|
+
# TODO pretty lame, but for now it will do
|
66
|
+
unless @method == "authorise_one_click_payment_request_body" || @method == "authorise_recurring_payment_request_body"
|
67
|
+
@payment.params[:shopper].delete(:ip)
|
68
|
+
xpath('./payment:shopperIP').must_be :empty?
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it "does not include shopper statement if none given" do
|
73
|
+
# TODO pretty lame, but for now it will do
|
74
|
+
unless @method == "authorise_one_click_payment_request_body" || @method == "authorise_recurring_payment_request_body"
|
75
|
+
@payment.params[:shopper].delete(:statement)
|
76
|
+
xpath('./payment:shopperStatement').must_be :empty?
|
77
|
+
end
|
58
78
|
end
|
59
|
-
end
|
60
79
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
80
|
+
it "does not include any shopper details if none are given" do
|
81
|
+
# TODO pretty lame, but for now it will do
|
82
|
+
unless @method == "authorise_one_click_payment_request_body" || @method == "authorise_recurring_payment_request_body"
|
83
|
+
@payment.params.delete(:shopper)
|
84
|
+
xpath('./payment:shopperReference').must_be :empty?
|
85
|
+
xpath('./payment:shopperEmail').must_be :empty?
|
86
|
+
xpath('./payment:shopperIP').must_be :empty?
|
87
|
+
xpath('./payment:statement').must_be :empty?
|
88
|
+
end
|
69
89
|
end
|
70
90
|
end
|
71
|
-
end
|
72
91
|
|
73
|
-
|
74
|
-
|
92
|
+
def it_behaves_like_a_recurring_payment_request
|
93
|
+
it_behaves_like_a_payment_request
|
75
94
|
|
76
|
-
|
77
|
-
|
78
|
-
|
95
|
+
it "uses the given recurring detail reference" do
|
96
|
+
@payment.params[:recurring_detail_reference] = 'RecurringDetailReference1'
|
97
|
+
text('./payment:selectedRecurringDetailReference').must_equal 'RecurringDetailReference1'
|
98
|
+
end
|
79
99
|
end
|
80
100
|
end
|
81
101
|
|
82
102
|
describe Adyen::API::PaymentService do
|
83
103
|
include APISpecHelper
|
104
|
+
extend SharedExamples
|
84
105
|
|
85
106
|
before do
|
86
107
|
@params = {
|
@@ -116,7 +137,7 @@ describe Adyen::API::PaymentService do
|
|
116
137
|
end
|
117
138
|
|
118
139
|
describe_request_body_of :authorise_payment do
|
119
|
-
|
140
|
+
it_behaves_like_a_payment_request
|
120
141
|
|
121
142
|
it_should_validate_request_parameters :merchant_account,
|
122
143
|
:reference,
|
@@ -142,36 +163,43 @@ describe Adyen::API::PaymentService do
|
|
142
163
|
it "includes the creditcard details" do
|
143
164
|
xpath('./payment:card') do |card|
|
144
165
|
# there's no reason why Nokogiri should escape these characters, but as long as they're correct
|
145
|
-
card.text('./payment:holderName').
|
146
|
-
card.text('./payment:number').
|
147
|
-
card.text('./payment:cvc').
|
148
|
-
card.text('./payment:expiryMonth').
|
149
|
-
card.text('./payment:expiryYear').
|
166
|
+
card.text('./payment:holderName').must_equal 'Simon わくわく Hopper'
|
167
|
+
card.text('./payment:number').must_equal '4444333322221111'
|
168
|
+
card.text('./payment:cvc').must_equal '737'
|
169
|
+
card.text('./payment:expiryMonth').must_equal '12'
|
170
|
+
card.text('./payment:expiryYear').must_equal '2012'
|
150
171
|
end
|
151
172
|
end
|
152
173
|
|
153
|
-
it "formats the creditcard
|
174
|
+
it "formats the creditcard's expiry month as a two digit number" do
|
154
175
|
@payment.params[:card][:expiry_month] = 6
|
155
|
-
text('./payment:card/payment:expiryMonth').
|
176
|
+
text('./payment:card/payment:expiryMonth').must_equal '06'
|
177
|
+
end
|
178
|
+
|
179
|
+
it "does not include recurring and one-click contract info if the `:recurring' param is false" do
|
180
|
+
xpath('./payment:recurring/payment:contract').must_be :empty?
|
156
181
|
end
|
157
182
|
|
158
183
|
it "includes the necessary recurring and one-click contract info if the `:recurring' param is truthful" do
|
159
|
-
xpath('./payment:recurring/payment:contract').should be_empty
|
160
184
|
@payment.params[:recurring] = true
|
161
|
-
text('./payment:recurring/payment:contract').
|
185
|
+
text('./payment:recurring/payment:contract').must_equal 'RECURRING,ONECLICK'
|
162
186
|
end
|
163
187
|
end
|
164
188
|
|
165
189
|
describe_response_from :generate_billet, BILLET_RECEIVED_RESPONSE do
|
166
190
|
it_should_return_params_for_each_xml_backend({
|
167
|
-
:psp_reference => "
|
191
|
+
:psp_reference => "8814737173377729",
|
168
192
|
:result_code => "Received",
|
169
|
-
:billet_url => "https://test.adyen.com/hpp/generationBoleto.shtml?data=
|
193
|
+
:billet_url => "https://test.adyen.com/hpp/generationBoleto.shtml?data=BQABAQA8M3ewKqDwrdIK%2Bq9mDvlF%2BX0IszPCAG9Tg2jmOJn0%2Fm6T%2BPABVpyI8%2FhFeY3xTN3B7yEffj6ehx0ADQh5sLT9ndkqu1UuHTZjlxBiJ9UcMOAl8rkPSLEJU1Dw1tLWGQ7PKRqB8bv3k%2FVbPGliXZVxEvzxAOZdZ1dpHeVZfA1XT8a9%2BZQtJFPAHOhgYpPBmYkiVnavJfwbNMKddQY0CZxC1V2Hndx9yDl%2FS0IJ1hLgiwxr8eE6QkeDBYZ5uKKyiIVpPxKwDe1o3sq2v76s7cQvdfGn%2FmAr6jWiNl%2BrQU92%2FYlFuR4rHhZdOyUkNofTeTRcpuSaTsK1L9MS1UNqTAWbEMmlqUgNZ6B7HtiYP61sbMIAAECcYbKVpl%2BRN3hpP3HqHc0%2FxkOShfnE4bYOtDGVDMf4dt9kAM6%2BXDOyk8iu%2F%2FdbHvrZnenLFsKhcdDEjiXRrLHMVxQI9BN%2F5Yy4hnGN7k%2FXI1mANMhNpKWLdPBCt94GzaiI830xKsh5KlgFrenU%2B4x2p0pbeAQUokTLKHEUUzmNmlplxhADBHmTAEwC0vbbGjWFh3PS0zGRwas2TpLNRtQznTmdfoI7j0dlSVHCQQ%3D%3D",
|
194
|
+
:barcode => "03399.33335 33887.371731 37772.301026 8 69200000009314",
|
195
|
+
:due_date => Date.parse("2016-09-17"),
|
196
|
+
:expiration_date => Date.parse("2016-10-02"),
|
197
|
+
:refusal_reason => ""
|
170
198
|
})
|
171
199
|
|
172
200
|
describe "with a received billet" do
|
173
201
|
it "returns that the request was successful" do
|
174
|
-
@response.
|
202
|
+
@response.must_be :success?
|
175
203
|
end
|
176
204
|
end
|
177
205
|
end
|
@@ -180,12 +208,16 @@ describe Adyen::API::PaymentService do
|
|
180
208
|
it_should_return_params_for_each_xml_backend({
|
181
209
|
:psp_reference => "8514038928235061",
|
182
210
|
:result_code => "Refused",
|
183
|
-
:billet_url => ""
|
211
|
+
:billet_url => "",
|
212
|
+
:barcode => "",
|
213
|
+
:due_date => nil,
|
214
|
+
:expiration_date => nil,
|
215
|
+
:refusal_reason => "102 Unable to determine variant"
|
184
216
|
})
|
185
217
|
|
186
218
|
describe "with a received billet" do
|
187
219
|
it "returns that the request was successful" do
|
188
|
-
@response.
|
220
|
+
@response.wont_be :success?
|
189
221
|
end
|
190
222
|
end
|
191
223
|
end
|
@@ -196,13 +228,13 @@ describe Adyen::API::PaymentService do
|
|
196
228
|
:result_code => 'Authorised',
|
197
229
|
:auth_code => '1234',
|
198
230
|
:additional_data => { "cardSummary" => "1111" },
|
199
|
-
:refusal_reason =>
|
231
|
+
:refusal_reason => ""
|
200
232
|
})
|
201
233
|
|
202
234
|
describe "with a authorized response" do
|
203
235
|
it "returns that the request was authorised" do
|
204
|
-
@response.
|
205
|
-
@response.
|
236
|
+
@response.must_be :success?
|
237
|
+
@response.must_be :authorized?
|
206
238
|
end
|
207
239
|
end
|
208
240
|
|
@@ -213,8 +245,8 @@ describe Adyen::API::PaymentService do
|
|
213
245
|
end
|
214
246
|
|
215
247
|
it "returns that the request was not authorised" do
|
216
|
-
@response.
|
217
|
-
@response.
|
248
|
+
@response.wont_be :success?
|
249
|
+
@response.wont_be :authorized?
|
218
250
|
end
|
219
251
|
end
|
220
252
|
|
@@ -225,8 +257,8 @@ describe Adyen::API::PaymentService do
|
|
225
257
|
end
|
226
258
|
|
227
259
|
it "returns that the payment was refused" do
|
228
|
-
@response.
|
229
|
-
@response.error.
|
260
|
+
@response.must_be :refused?
|
261
|
+
@response.error.must_equal [:base, 'Transaction was refused.']
|
230
262
|
end
|
231
263
|
end
|
232
264
|
|
@@ -237,17 +269,17 @@ describe Adyen::API::PaymentService do
|
|
237
269
|
end
|
238
270
|
|
239
271
|
it "returns that the request was not authorised" do
|
240
|
-
@response.
|
241
|
-
@response.
|
272
|
+
@response.wont_be :success?
|
273
|
+
@response.wont_be :authorized?
|
242
274
|
end
|
243
275
|
|
244
276
|
it "it returns that the request was invalid" do
|
245
|
-
@response.
|
277
|
+
@response.must_be :invalid_request?
|
246
278
|
end
|
247
279
|
|
248
280
|
it "returns the fault message from #refusal_reason" do
|
249
|
-
@response.refusal_reason.
|
250
|
-
@response.params[:refusal_reason].
|
281
|
+
@response.refusal_reason.must_equal 'validation 101 Invalid card number'
|
282
|
+
@response.params[:refusal_reason].must_equal 'validation 101 Invalid card number'
|
251
283
|
end
|
252
284
|
|
253
285
|
it "returns creditcard validation errors" do
|
@@ -258,13 +290,13 @@ describe Adyen::API::PaymentService do
|
|
258
290
|
["validation Couldn't parse expiry year", [:expiry_year, 'could not be recognized']],
|
259
291
|
["validation Expiry month should be between 1 and 12 inclusive", [:expiry_month, 'could not be recognized']],
|
260
292
|
].each do |message, error|
|
261
|
-
response_with_fault_message(message).error.
|
293
|
+
response_with_fault_message(message).error.must_equal error
|
262
294
|
end
|
263
295
|
end
|
264
296
|
|
265
297
|
it "returns any other fault messages on `base'" do
|
266
298
|
message = "validation 130 Reference Missing"
|
267
|
-
response_with_fault_message(message).error.
|
299
|
+
response_with_fault_message(message).error.must_equal [:base, message]
|
268
300
|
end
|
269
301
|
|
270
302
|
it "prepends the error attribute with the given prefix, except for :base" do
|
@@ -273,7 +305,7 @@ describe Adyen::API::PaymentService do
|
|
273
305
|
["validation 130 Reference Missing", [:base, "validation 130 Reference Missing"]],
|
274
306
|
["validation 152 Invalid number of installments", [:base, "validation 152 Invalid number of installments"]],
|
275
307
|
].each do |message, error|
|
276
|
-
response_with_fault_message(message).error(:card).
|
308
|
+
response_with_fault_message(message).error(:card).must_equal error
|
277
309
|
end
|
278
310
|
end
|
279
311
|
|
@@ -287,7 +319,7 @@ describe Adyen::API::PaymentService do
|
|
287
319
|
end
|
288
320
|
|
289
321
|
describe_request_body_of :authorise_recurring_payment do
|
290
|
-
|
322
|
+
it_behaves_like_a_recurring_payment_request
|
291
323
|
|
292
324
|
it_should_validate_request_parameters :merchant_account,
|
293
325
|
:reference,
|
@@ -296,20 +328,20 @@ describe Adyen::API::PaymentService do
|
|
296
328
|
:shopper => [:reference, :email]
|
297
329
|
|
298
330
|
it "includes the contract type, which is `RECURRING'" do
|
299
|
-
text('./payment:recurring/payment:contract').
|
331
|
+
text('./payment:recurring/payment:contract').must_equal 'RECURRING'
|
300
332
|
end
|
301
333
|
|
302
334
|
it "uses the latest recurring detail reference, by default" do
|
303
335
|
@payment.params[:recurring_detail_reference] = nil
|
304
|
-
text('./payment:selectedRecurringDetailReference').
|
336
|
+
text('./payment:selectedRecurringDetailReference').must_equal 'LATEST'
|
305
337
|
end
|
306
338
|
|
307
|
-
it "obviously includes the obligatory self
|
308
|
-
text('./payment:shopperInteraction').
|
339
|
+
it "obviously includes the obligatory self-'describing' nonsense parameters" do
|
340
|
+
text('./payment:shopperInteraction').must_equal 'ContAuth'
|
309
341
|
end
|
310
342
|
|
311
343
|
it "does not include any creditcard details" do
|
312
|
-
xpath('./payment:card').
|
344
|
+
xpath('./payment:card').must_be :empty?
|
313
345
|
end
|
314
346
|
end
|
315
347
|
|
@@ -324,7 +356,7 @@ describe Adyen::API::PaymentService do
|
|
324
356
|
end
|
325
357
|
|
326
358
|
describe_request_body_of :authorise_one_click_payment do
|
327
|
-
|
359
|
+
it_behaves_like_a_recurring_payment_request
|
328
360
|
|
329
361
|
it_should_validate_request_parameters :merchant_account,
|
330
362
|
:reference,
|
@@ -335,21 +367,21 @@ describe Adyen::API::PaymentService do
|
|
335
367
|
:card => [:cvc]
|
336
368
|
|
337
369
|
it "includes the contract type, which is `ONECLICK'" do
|
338
|
-
text('./payment:recurring/payment:contract').
|
370
|
+
text('./payment:recurring/payment:contract').must_equal 'ONECLICK'
|
339
371
|
end
|
340
372
|
|
341
|
-
it "does not include the self
|
342
|
-
xpath('./payment:shopperInteraction').
|
373
|
+
it "does not include the self-'describing' nonsense parameters" do
|
374
|
+
xpath('./payment:shopperInteraction').must_be :empty?
|
343
375
|
end
|
344
376
|
|
345
377
|
it "includes only the creditcard's CVC code" do
|
346
378
|
xpath('./payment:card') do |card|
|
347
|
-
card.text('./payment:cvc').
|
379
|
+
card.text('./payment:cvc').must_equal '737'
|
348
380
|
|
349
|
-
card.xpath('./payment:holderName').
|
350
|
-
card.xpath('./payment:number').
|
351
|
-
card.xpath('./payment:expiryMonth').
|
352
|
-
card.xpath('./payment:expiryYear').
|
381
|
+
card.xpath('./payment:holderName').must_be :empty?
|
382
|
+
card.xpath('./payment:number').must_be :empty?
|
383
|
+
card.xpath('./payment:expiryMonth').must_be :empty?
|
384
|
+
card.xpath('./payment:expiryYear').must_be :empty?
|
353
385
|
end
|
354
386
|
end
|
355
387
|
end
|
@@ -371,8 +403,8 @@ describe Adyen::API::PaymentService do
|
|
371
403
|
|
372
404
|
it "includes the amount to capture" do
|
373
405
|
xpath('./payment:modificationAmount') do |amount|
|
374
|
-
amount.text('./common:currency').
|
375
|
-
amount.text('./common:value').
|
406
|
+
amount.text('./common:currency').must_equal 'EUR'
|
407
|
+
amount.text('./common:value').must_equal '1234'
|
376
408
|
end
|
377
409
|
end
|
378
410
|
end
|
@@ -385,7 +417,7 @@ describe Adyen::API::PaymentService do
|
|
385
417
|
|
386
418
|
describe "with a successful response" do
|
387
419
|
it "returns that the request was received successfully" do
|
388
|
-
@response.
|
420
|
+
@response.must_be :success?
|
389
421
|
end
|
390
422
|
end
|
391
423
|
|
@@ -396,7 +428,7 @@ describe Adyen::API::PaymentService do
|
|
396
428
|
end
|
397
429
|
|
398
430
|
it "returns that the request was not received successfully" do
|
399
|
-
@response.
|
431
|
+
@response.wont_be :success?
|
400
432
|
end
|
401
433
|
end
|
402
434
|
end
|
@@ -408,8 +440,8 @@ describe Adyen::API::PaymentService do
|
|
408
440
|
|
409
441
|
it "includes the amount to refund" do
|
410
442
|
xpath('./payment:modificationAmount') do |amount|
|
411
|
-
amount.text('./common:currency').
|
412
|
-
amount.text('./common:value').
|
443
|
+
amount.text('./common:currency').must_equal 'EUR'
|
444
|
+
amount.text('./common:value').must_equal '1234'
|
413
445
|
end
|
414
446
|
end
|
415
447
|
end
|
@@ -422,7 +454,7 @@ describe Adyen::API::PaymentService do
|
|
422
454
|
|
423
455
|
describe "with a successful response" do
|
424
456
|
it "returns that the request was received successfully" do
|
425
|
-
@response.
|
457
|
+
@response.must_be :success?
|
426
458
|
end
|
427
459
|
end
|
428
460
|
|
@@ -433,7 +465,7 @@ describe Adyen::API::PaymentService do
|
|
433
465
|
end
|
434
466
|
|
435
467
|
it "returns that the request was not received successfully" do
|
436
|
-
@response.
|
468
|
+
@response.wont_be :success?
|
437
469
|
end
|
438
470
|
end
|
439
471
|
end
|
@@ -451,7 +483,7 @@ describe Adyen::API::PaymentService do
|
|
451
483
|
|
452
484
|
describe "with a successful response" do
|
453
485
|
it "returns that the request was received successfully" do
|
454
|
-
@response.
|
486
|
+
@response.must_be :success?
|
455
487
|
end
|
456
488
|
end
|
457
489
|
|
@@ -462,7 +494,7 @@ describe Adyen::API::PaymentService do
|
|
462
494
|
end
|
463
495
|
|
464
496
|
it "returns that the request was not received successfully" do
|
465
|
-
@response.
|
497
|
+
@response.wont_be :success?
|
466
498
|
end
|
467
499
|
end
|
468
500
|
end
|
@@ -480,7 +512,7 @@ describe Adyen::API::PaymentService do
|
|
480
512
|
|
481
513
|
describe "with a successful response" do
|
482
514
|
it "returns that the request was received successfully" do
|
483
|
-
@response.
|
515
|
+
@response.must_be :success?
|
484
516
|
end
|
485
517
|
end
|
486
518
|
|
@@ -491,7 +523,7 @@ describe Adyen::API::PaymentService do
|
|
491
523
|
end
|
492
524
|
|
493
525
|
it "returns that the request was not received successfully" do
|
494
|
-
@response.
|
526
|
+
@response.wont_be :success?
|
495
527
|
end
|
496
528
|
end
|
497
529
|
end
|