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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.travis.yml +12 -5
  4. data/CHANGELOG.md +5 -2
  5. data/CONTRIBUTING.md +1 -1
  6. data/Gemfile +4 -0
  7. data/README.md +0 -2
  8. data/Rakefile +2 -8
  9. data/adyen.gemspec +4 -5
  10. data/lib/adyen/api.rb +14 -10
  11. data/lib/adyen/api/payment_service.rb +35 -4
  12. data/lib/adyen/api/templates/payment_service.rb +5 -0
  13. data/lib/adyen/form.rb +1 -1
  14. data/lib/adyen/hpp/request.rb +8 -6
  15. data/lib/adyen/rest.rb +21 -8
  16. data/lib/adyen/rest/client.rb +13 -0
  17. data/lib/adyen/templates/notification_migration.rb +1 -1
  18. data/lib/adyen/templates/notification_model.rb +2 -2
  19. data/lib/adyen/version.rb +1 -1
  20. data/{spec/functional/api_spec.rb → test/functional/api_test.rb} +38 -33
  21. data/{spec → test}/functional/initializer.rb.ci +0 -0
  22. data/{spec → test}/functional/initializer.rb.sample +0 -0
  23. data/test/helpers/views/hpp.erb +15 -15
  24. data/test/test_helper.rb +1 -0
  25. data/{spec/api/api_spec.rb → test/unit/api/api_test.rb} +7 -7
  26. data/{spec/api/payment_service_spec.rb → test/unit/api/payment_service_test.rb} +149 -117
  27. data/{spec/api/recurring_service_spec.rb → test/unit/api/recurring_service_test.rb} +49 -46
  28. data/{spec/api/response_spec.rb → test/unit/api/response_test.rb} +12 -12
  29. data/{spec/api/simple_soap_client_spec.rb → test/unit/api/simple_soap_client_test.rb} +27 -30
  30. data/{spec/api/spec_helper.rb → test/unit/api/test_helper.rb} +44 -35
  31. data/{spec/api/test_helpers_spec.rb → test/unit/api/test_helpers_test.rb} +11 -11
  32. data/test/{form_test.rb → unit/form_test.rb} +0 -0
  33. data/test/unit/hpp/request_test.rb +68 -0
  34. data/test/{hpp → unit/hpp}/signature_test.rb +0 -0
  35. data/test/{hpp_test.rb → unit/hpp_test.rb} +0 -0
  36. data/test/{rest → unit/rest}/signature_test.rb +0 -0
  37. data/test/{rest_list_recurring_details_response_test.rb → unit/rest_list_recurring_details_response_test.rb} +0 -0
  38. data/test/{rest_request_test.rb → unit/rest_request_test.rb} +0 -0
  39. data/test/{rest_response_test.rb → unit/rest_response_test.rb} +0 -0
  40. data/test/{signature_test.rb → unit/signature_test.rb} +0 -0
  41. data/test/{util_test.rb → unit/util_test.rb} +0 -0
  42. metadata +53 -61
  43. 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? }
@@ -1,5 +1,5 @@
1
1
  module Adyen
2
2
  # Version constant for the Adyen plugin.
3
3
  # Set it & commit the change before running rake release.
4
- VERSION = "2.2.0"
4
+ VERSION = "2.3.0"
5
5
  end
@@ -1,6 +1,7 @@
1
1
  # encoding: UTF-8
2
- require 'api/spec_helper'
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.should be_authorized
44
- response.psp_reference.should_not be_empty
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.should be_authorized
57
- response.psp_reference.should_not be_empty
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.should be_stored
66
- response.recurring_detail_reference.should_not be_empty
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.should be_stored
75
- response.recurring_detail_reference.should_not be_empty
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.should be_success
81
- response.should be_disabled
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.should be_success
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.should be_success
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.should be_success
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.should be_success
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
- response.should be_success
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
 
@@ -1,20 +1,20 @@
1
1
  <html>
2
- <head>
3
- <title> HPP Payment</title>
4
- </head>
5
- <body>
6
- <% hpp_client = Adyen::HPP::Client.new(:test, :testing) %>
7
- <form action="<%= hpp_client.url %>" method="post">
8
- <p> Price: <strong>EUR 43.21</strong>. </p>
9
- <p>
10
- <%= hpp_client.new_request.hidden_fields(@payment) %>
11
- <input type="submit" value="Pay" />
12
- </p>
13
- </form>
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
- <p>If you are using the test account of this library, you will be redirected back
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
- </p>
19
- </body>
18
+ </p>
19
+ </body>
20
20
  </html>
@@ -10,6 +10,7 @@ require 'helpers/configure_adyen'
10
10
  require 'helpers/test_cards'
11
11
 
12
12
  require 'pp'
13
+ require 'time'
13
14
 
14
15
  module Adyen::Test
15
16
  module Flaky
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
- require 'api/spec_helper'
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 = double('PaymentService')
10
+ @payment = mock('PaymentService')
11
11
  end
12
12
 
13
13
  def should_map_shortcut_to(method, params)
14
- Adyen::API::PaymentService.should_receive(:new).with(params).and_return(@payment)
15
- @payment.should_receive(method)
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 = double('RecurringService')
185
+ @recurring = mock('RecurringService')
186
186
  end
187
187
 
188
188
  def should_map_shortcut_to(method, params)
189
- Adyen::API::RecurringService.should_receive(:new).with(params).and_return(@recurring)
190
- @recurring.should_receive(method)
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/spec_helper'
2
+ require 'unit/api/test_helper'
3
3
 
4
- shared_examples_for "payment requests" do
5
- it "includes the merchant account handle" do
6
- text('./payment:merchantAccount').should == 'SuperShopper'
7
- end
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
- it "includes the payment reference of the merchant" do
10
- text('./payment:reference').should == 'order-id'
11
- end
10
+ it "includes the payment reference of the merchant" do
11
+ text('./payment:reference').must_equal 'order-id'
12
+ end
12
13
 
13
- it "includes the given amount of `currency'" do
14
- xpath('./payment:amount') do |amount|
15
- amount.text('./common:currency').should == 'EUR'
16
- amount.text('./common:value').should == '1234'
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
- it "includes the shoppers details" do
21
- text('./payment:shopperReference').should == 'user-id'
22
- text('./payment:shopperEmail').should == 's.hopper@example.com'
23
- text('./payment:shopperIP').should == '61.294.12.12'
24
- text('./payment:shopperStatement').should == 'invoice number 123456'
25
- end
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
- it "includes the fraud offset" do
28
- text('./payment:fraudOffset').should == '30'
29
- end
28
+ it "includes the fraud offset" do
29
+ text('./payment:fraudOffset').must_equal '30'
30
+ end
30
31
 
31
- it "does not include the fraud offset if none is given" do
32
- @payment.params.delete(:fraud_offset)
33
- xpath('./payment:fraudOffset').should be_empty
34
- end
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
- it "includes the given amount of `installments'" do
37
- xpath('./payment:installments') do |amount|
38
- amount.text('./common:value').should == '6'
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
- it "does not include the installments amount if none is given" do
43
- @payment.params.delete(:installments)
44
- xpath('./payment:installments').should be_empty
45
- end
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
- it "only includes shopper details for given parameters" do
48
- # TODO pretty lame, but for now it will do
49
- unless @method == "authorise_one_click_payment_request_body" || @method == "authorise_recurring_payment_request_body"
50
- @payment.params[:shopper].delete(:reference)
51
- xpath('./payment:shopperReference').should be_empty
52
- @payment.params[:shopper].delete(:email)
53
- xpath('./payment:shopperEmail').should be_empty
54
- @payment.params[:shopper].delete(:ip)
55
- xpath('./payment:shopperIP').should be_empty
56
- @payment.params[:shopper].delete(:statement)
57
- xpath('./payment:shopperStatement').should be_empty
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
- it "does not include any shopper details if none are given" do
62
- # TODO pretty lame, but for now it will do
63
- unless @method == "authorise_one_click_payment_request_body" || @method == "authorise_recurring_payment_request_body"
64
- @payment.params.delete(:shopper)
65
- xpath('./payment:shopperReference').should be_empty
66
- xpath('./payment:shopperEmail').should be_empty
67
- xpath('./payment:shopperIP').should be_empty
68
- xpath('./payment:statement').should be_empty
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
- shared_examples_for "recurring payment requests" do
74
- it_should_behave_like "payment requests"
92
+ def it_behaves_like_a_recurring_payment_request
93
+ it_behaves_like_a_payment_request
75
94
 
76
- it "uses the given recurring detail reference" do
77
- @payment.params[:recurring_detail_reference] = 'RecurringDetailReference1'
78
- text('./payment:selectedRecurringDetailReference').should == 'RecurringDetailReference1'
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
- it_should_behave_like "payment requests"
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').should == 'Simon わくわく Hopper'
146
- card.text('./payment:number').should == '4444333322221111'
147
- card.text('./payment:cvc').should == '737'
148
- card.text('./payment:expiryMonth').should == '12'
149
- card.text('./payment:expiryYear').should == '2012'
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 creditcards expiry month as a two digit number" do
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').should == '06'
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').should == 'RECURRING,ONECLICK'
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 => "8814038837489129",
191
+ :psp_reference => "8814737173377729",
168
192
  :result_code => "Received",
169
- :billet_url => "https://test.adyen.com/hpp/generationBoleto.shtml?data=AgABAQBdYDe9OqdseA79Rfexm2Lz8fRQ1bWqkLhBCf1fHhQEif7bsRKi0otq%2B1ekMAdMIZUiVXeR3QFrAOA8Zy4tpiNLhkMq6f7W2zFqYhVWrByqxQnbQTYuX2FWI7tsu7Vb0MnyOvFfFdFtaxzImZYCli%2BMrqaAJ5HI9ap3egeqBQIsRI%2Fj0zWsu2EGN16lGbwFOLyxl%2By0Pc5jazTo8rnBA7OVPGDIu7Qt%2F2DYIMcB6PXou5W3aJoTC4SldhNdobVqgWUtES8NsWdOYbLGa6I%2BjSwEFXvxyTXwtw4J2E%2BE7ux1UhBiZRj66lMbcvaYlfnR2xWbA%2BKmdLrVvuXTroEHKQ%2B1C%2FuyGuiOk3SmGq6TMgOyCEt%2BmG%2Bq6z5jDi%2BnYLtlLQU4ccMOujgWMfGkViC%2FXDUlqYjKbn8NHwPwoPcelpf1zCDCe%2Fvu6NBTVQbEXbE0oV0j2MT1tLlMdf08iUsDThuQ3MlJbE8VbTMlttOFqoyXhBjepQ42C1eXfswSz1gsZlHanBCTiw1pB69vkvfWPf5IdUSx1cpEr9LJ9PSz%2FeHxEhq%2B8ZdWzrybXqRbEl2mUjLeyhMNuiE%3D"
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.should be_success
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.should_not be_success
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.should be_success
205
- @response.should be_authorized
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.should_not be_success
217
- @response.should_not be_authorized
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.should be_refused
229
- @response.error.should == [:base, 'Transaction was refused.']
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.should_not be_success
241
- @response.should_not be_authorized
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.should be_invalid_request
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.should == 'validation 101 Invalid card number'
250
- @response.params[:refusal_reason].should == 'validation 101 Invalid card number'
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.should == 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.should == [:base, message]
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).should == error
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
- it_should_behave_like "recurring payment requests"
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').should == 'RECURRING'
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').should == 'LATEST'
336
+ text('./payment:selectedRecurringDetailReference').must_equal 'LATEST'
305
337
  end
306
338
 
307
- it "obviously includes the obligatory self-‘describing nonsense parameters" do
308
- text('./payment:shopperInteraction').should == 'ContAuth'
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').should be_empty
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
- it_should_behave_like "recurring payment requests"
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').should == 'ONECLICK'
370
+ text('./payment:recurring/payment:contract').must_equal 'ONECLICK'
339
371
  end
340
372
 
341
- it "does not include the self-‘describing nonsense parameters" do
342
- xpath('./payment:shopperInteraction').should be_empty
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').should == '737'
379
+ card.text('./payment:cvc').must_equal '737'
348
380
 
349
- card.xpath('./payment:holderName').should be_empty
350
- card.xpath('./payment:number').should be_empty
351
- card.xpath('./payment:expiryMonth').should be_empty
352
- card.xpath('./payment:expiryYear').should be_empty
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').should == 'EUR'
375
- amount.text('./common:value').should == '1234'
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.should be_success
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.should_not be_success
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').should == 'EUR'
412
- amount.text('./common:value').should == '1234'
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.should be_success
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.should_not be_success
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.should be_success
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.should_not be_success
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.should be_success
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.should_not be_success
526
+ @response.wont_be :success?
495
527
  end
496
528
  end
497
529
  end