adyen 1.4.1 → 1.5.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.
@@ -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 = "1.4.1"
4
+ VERSION = "1.5.0"
5
5
  end
@@ -30,7 +30,7 @@ describe Adyen::API do
30
30
  { :expiry_month => 12, :expiry_year => 2012, :holder_name => "Simon Hopper", :number => '4444333322221111', :cvc => '737' }
31
31
  )
32
32
  end
33
-
33
+
34
34
  it "performs a `authorise payment' request with additional :fraud_offset" do
35
35
  should_map_shortcut_to(:authorise_payment,
36
36
  :reference => 'order-id',
@@ -79,7 +79,7 @@ describe Adyen::API do
79
79
  { :reference => 'user-id', :email => 's.hopper@example.com' }
80
80
  )
81
81
  end
82
-
82
+
83
83
  it "performs a `authorise recurring payment' request with specific detail" do
84
84
  should_map_shortcut_to(:authorise_recurring_payment,
85
85
  :reference => 'order-id',
@@ -94,7 +94,7 @@ describe Adyen::API do
94
94
  'recurring-detail-reference'
95
95
  )
96
96
  end
97
-
97
+
98
98
  it "performs a `authorise recurring payment' request with specific detail and fraud offset" do
99
99
  should_map_shortcut_to(:authorise_recurring_payment,
100
100
  :reference => 'order-id',
@@ -123,11 +123,11 @@ describe Adyen::API do
123
123
  Adyen::API.authorise_one_click_payment('order-id',
124
124
  { :currency => 'EUR', :value => 1234 },
125
125
  { :reference => 'user-id', :email => 's.hopper@example.com' },
126
- '737',
126
+ { :cvc => '737' },
127
127
  'recurring-detail-reference'
128
128
  )
129
129
  end
130
-
130
+
131
131
  it "performs a `authorise one-click payment' request with specific detail and fraud offset" do
132
132
  should_map_shortcut_to(:authorise_one_click_payment,
133
133
  :reference => 'order-id',
@@ -140,7 +140,7 @@ describe Adyen::API do
140
140
  Adyen::API.authorise_one_click_payment('order-id',
141
141
  { :currency => 'EUR', :value => 1234 },
142
142
  { :reference => 'user-id', :email => 's.hopper@example.com' },
143
- '737',
143
+ { :cvc => '737' },
144
144
  'recurring-detail-reference',
145
145
  -10
146
146
  )
@@ -23,16 +23,27 @@ shared_examples_for "payment requests" do
23
23
  text('./payment:shopperIP').should == '61.294.12.12'
24
24
  text('./payment:shopperStatement').should == 'invoice number 123456'
25
25
  end
26
-
26
+
27
27
  it "includes the fraud offset" do
28
28
  text('./payment:fraudOffset').should == '30'
29
29
  end
30
-
30
+
31
31
  it "does not include the fraud offset if none is given" do
32
32
  @payment.params.delete(:fraud_offset)
33
33
  xpath('./payment:fraudOffset').should be_empty
34
34
  end
35
35
 
36
+ it "includes the given amount of `installments'" do
37
+ xpath('./payment:installments') do |amount|
38
+ amount.text('./common:value').should == '6'
39
+ end
40
+ end
41
+
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
46
+
36
47
  it "only includes shopper details for given parameters" do
37
48
  # TODO pretty lame, but for now it will do
38
49
  unless @method == "authorise_one_click_payment_request_body" || @method == "authorise_recurring_payment_request_body"
@@ -95,6 +106,9 @@ describe Adyen::API::PaymentService do
95
106
  #:start_month => ,
96
107
  #:start_year => ,
97
108
  },
109
+ :installments => {
110
+ :value => 6
111
+ },
98
112
  :recurring_detail_reference => 'RecurringDetailReference1',
99
113
  :fraud_offset => 30
100
114
  }
@@ -113,7 +127,7 @@ describe Adyen::API::PaymentService do
113
127
  @payment.params[:recurring] = true
114
128
  @payment.params[:shopper] = nil
115
129
  end
116
-
130
+
117
131
  it_should_validate_request_param(:fraud_offset) do
118
132
  @payment.params[:fraud_offset] = ''
119
133
  end
@@ -128,7 +142,7 @@ describe Adyen::API::PaymentService do
128
142
  it "includes the creditcard details" do
129
143
  xpath('./payment:card') do |card|
130
144
  # there's no reason why Nokogiri should escape these characters, but as long as they're correct
131
- card.text('./payment:holderName').should == 'Simon わくわく Hopper'
145
+ card.text('./payment:holderName').should == 'Simon わくわく Hopper'
132
146
  card.text('./payment:number').should == '4444333322221111'
133
147
  card.text('./payment:cvc').should == '737'
134
148
  card.text('./payment:expiryMonth').should == '12'
@@ -153,6 +167,7 @@ describe Adyen::API::PaymentService do
153
167
  :psp_reference => '9876543210987654',
154
168
  :result_code => 'Authorised',
155
169
  :auth_code => '1234',
170
+ :additional_data => { "cardSummary" => "1111" },
156
171
  :refusal_reason => ''
157
172
  })
158
173
 
@@ -226,8 +241,9 @@ describe Adyen::API::PaymentService do
226
241
 
227
242
  it "prepends the error attribute with the given prefix, except for :base" do
228
243
  [
229
- ["validation 101 Invalid card number", [:card_number, 'is not a valid creditcard number']],
230
- ["validation 130 Reference Missing", [:base, "validation 130 Reference Missing"]],
244
+ ["validation 101 Invalid card number", [:card_number, 'is not a valid creditcard number']],
245
+ ["validation 130 Reference Missing", [:base, "validation 130 Reference Missing"]],
246
+ ["validation 152 Invalid number of installments", [:base, "validation 152 Invalid number of installments"]],
231
247
  ].each do |message, error|
232
248
  response_with_fault_message(message).error(:card).should == error
233
249
  end
@@ -274,6 +290,7 @@ describe Adyen::API::PaymentService do
274
290
  :psp_reference => '9876543210987654',
275
291
  :result_code => 'Authorised',
276
292
  :auth_code => '1234',
293
+ :additional_data => { "cardSummary" => "1111" },
277
294
  :refusal_reason => ''
278
295
  })
279
296
  end
@@ -314,6 +331,7 @@ describe Adyen::API::PaymentService do
314
331
  :psp_reference => '9876543210987654',
315
332
  :result_code => 'Authorised',
316
333
  :auth_code => '1234',
334
+ :additional_data => { "cardSummary" => "1111" },
317
335
  :refusal_reason => ''
318
336
  })
319
337
  end
@@ -170,7 +170,7 @@ describe Adyen::API::RecurringService do
170
170
  it "includes the creditcard details" do
171
171
  xpath('./recurring:card') do |card|
172
172
  # there's no reason why Nokogiri should escape these characters, but as long as they're correct
173
- card.text('./payment:holderName').should == 'Simon わくわく Hopper'
173
+ card.text('./payment:holderName').should == 'Simon わくわく Hopper'
174
174
  card.text('./payment:number').should == '4444333322221111'
175
175
  card.text('./payment:cvc').should == '737'
176
176
  card.text('./payment:expiryMonth').should == '12'
@@ -207,7 +207,7 @@ describe Adyen::API::RecurringService do
207
207
  it "includes the ELV details" do
208
208
  xpath('./recurring:elv') do |elv|
209
209
  # there's no reason why Nokogiri should escape these characters, but as long as they're correct
210
- elv.text('./payment:accountHolderName').should == 'Simon わくわく Hopper'
210
+ elv.text('./payment:accountHolderName').should == 'Simon わくわく Hopper'
211
211
  elv.text('./payment:bankAccountNumber').should == '1234567890'
212
212
  elv.text('./payment:bankLocation').should == 'Berlin'
213
213
  elv.text('./payment:bankLocationId').should == '12345678'
@@ -11,7 +11,7 @@ describe Adyen::API::Response do
11
11
 
12
12
  it "returns a XMLQuerier instance with the response body" do
13
13
  @response.xml_querier.should be_instance_of(Adyen::API::XMLQuerier)
14
- @response.xml_querier.to_s.should == AUTHORISE_RESPONSE
14
+ @response.xml_querier.to_s.rstrip.should == AUTHORISE_RESPONSE.rstrip
15
15
  end
16
16
 
17
17
  describe "with a successful HTTP response" do
@@ -73,7 +73,7 @@ describe Adyen::API::SimpleSOAPClient do
73
73
 
74
74
  it "returns an Adyen::API::Response instance" do
75
75
  @response.should be_instance_of(Adyen::API::Response)
76
- @response.xml_querier.to_s.should == AUTHORISE_RESPONSE
76
+ @response.xml_querier.to_s.rstrip.should == AUTHORISE_RESPONSE.rstrip
77
77
  end
78
78
 
79
79
  [
@@ -3,7 +3,6 @@ require 'spec_helper'
3
3
 
4
4
  require 'adyen/api'
5
5
 
6
- require 'rubygems'
7
6
  require 'nokogiri'
8
7
  require 'rexml/document'
9
8
 
@@ -223,7 +222,12 @@ AUTHORISE_RESPONSE = <<EOS
223
222
  <soap:Body>
224
223
  <ns1:authoriseResponse xmlns:ns1="http://payment.services.adyen.com">
225
224
  <ns1:paymentResult>
226
- <additionalData xmlns="http://payment.services.adyen.com" xsi:nil="true"/>
225
+ <additionalData xmlns="http://payment.services.adyen.com">
226
+ <entry>
227
+ <key xsi:type="xsd:string">cardSummary</key>
228
+ <value xsi:type="xsd:string">1111</value>
229
+ </entry>
230
+ </additionalData>
227
231
  <authCode xmlns="http://payment.services.adyen.com">1234</authCode>
228
232
  <dccAmount xmlns="http://payment.services.adyen.com" xsi:nil="true"/>
229
233
  <dccSignature xmlns="http://payment.services.adyen.com" xsi:nil="true"/>
@@ -138,6 +138,30 @@ describe Adyen::Form do
138
138
  end
139
139
  end
140
140
 
141
+ describe 'payment methods available URL' do
142
+ let(:payment_methods_url) do
143
+ @attributes = { :currency_code => 'GBP', :payment_amount => 10000, :ship_before_date => Date.today,
144
+ :merchant_reference => 'Internet Order 12345', :skin => :testing,
145
+ :session_validity => Time.now + 3600 }
146
+
147
+ Adyen::Form.payment_methods_url(@attributes)
148
+ end
149
+
150
+ it "should return an directory URL" do
151
+ payment_methods_url.should =~ %r[^#{Adyen::Form.url(nil, :directory)}]
152
+ end
153
+
154
+ it "should include all provided attributes" do
155
+ params = payment_methods_url.split('?', 2).last.split('&').map { |param| param.split('=', 2).first }
156
+ params.should include(*(@attributes.keys.map { |k| Adyen::Form.camelize(k) }))
157
+ end
158
+
159
+ it "should include the merchant signature" do
160
+ params = payment_methods_url.split('?', 2).last.split('&').map { |param| param.split('=', 2).first }
161
+ params.should include('merchantSig')
162
+ end
163
+ end
164
+
141
165
  describe 'hidden fields generation' do
142
166
  include APISpecHelper
143
167
  subject { %Q'<form action="#{CGI.escapeHTML(Adyen::Form.url)}" method="post">#{Adyen::Form.hidden_fields(@attributes)}</form>' }
@@ -176,12 +200,18 @@ describe Adyen::Form do
176
200
  :ship_before_date => '2007-10-20', :merchant_reference => 'Internet Order 12345',
177
201
  :skin => :testing, :session_validity => '2007-10-11T11:00:00Z',
178
202
  :billing_address => {
179
- :street => 'Alexanderplatz',
180
- :house_number_or_name => '0815',
181
- :city => 'Berlin',
182
- :postal_code => '10119',
183
- :state_or_province => 'Berlin',
184
- :country => 'Germany',
203
+ :street => 'Alexanderplatz',
204
+ :house_number_or_name => '0815',
205
+ :city => 'Berlin',
206
+ :postal_code => '10119',
207
+ :state_or_province => 'Berlin',
208
+ :country => 'Germany',
209
+ },
210
+ :shopper => {
211
+ :telephone_number => '1234512345',
212
+ :first_name => 'John',
213
+ :last_name => 'Doe',
214
+ :social_security_number => '123-45-1234'
185
215
  }
186
216
  }
187
217
 
@@ -194,7 +224,6 @@ describe Adyen::Form do
194
224
 
195
225
  signature_string = Adyen::Form.calculate_signature_string(@parameters.merge(:merchant_return_data => 'testing123'))
196
226
  signature_string.should == "10000GBP2007-10-20Internet Order 123454aD37dJATestMerchant2007-10-11T11:00:00Ztesting123"
197
-
198
227
  end
199
228
 
200
229
  it "should calculate the signature correctly" do
@@ -243,6 +272,28 @@ describe Adyen::Form do
243
272
  signature = Adyen::Form.calculate_billing_address_signature(@parameters)
244
273
  end.to raise_error ArgumentError
245
274
  end
275
+
276
+ end
277
+
278
+ context 'shopper' do
279
+
280
+ it "should construct the signature base string correctly" do
281
+ signature_string = Adyen::Form.calculate_shopper_signature_string(@parameters[:shopper])
282
+ signature_string.should == "JohnDoe1234512345"
283
+ end
284
+
285
+ it "should calculate the signature correctly" do
286
+ signature = Adyen::Form.calculate_shopper_signature(@parameters)
287
+ signature.should == 'rb2GEs1kGKuLh255a3QRPBYXmsQ='
288
+ end
289
+
290
+ it "should raise ArgumentError on empty shared_secret" do
291
+ expect do
292
+ @parameters.delete(:shared_secret)
293
+ signature = Adyen::Form.calculate_shopper_signature(@parameters)
294
+ end.to raise_error ArgumentError
295
+ end
296
+
246
297
  end
247
298
 
248
299
  end
@@ -12,7 +12,7 @@ if File.exist?(API_SPEC_INITIALIZER)
12
12
  require API_SPEC_INITIALIZER
13
13
  Net::HTTP.stubbing_enabled = false
14
14
  @order_id = @user_id = Time.now.to_i
15
- perform_payment_request
15
+ @payment_response = perform_payment_request
16
16
  end
17
17
 
18
18
  after :all do
@@ -20,7 +20,7 @@ if File.exist?(API_SPEC_INITIALIZER)
20
20
  end
21
21
 
22
22
  def perform_payment_request
23
- @payment_response = Adyen::API.authorise_payment(
23
+ Adyen::API.authorise_payment(
24
24
  @order_id,
25
25
  { :currency => 'EUR', :value => '1234' },
26
26
  { :email => "#{@user_id}@example.com", :reference => @user_id },
@@ -29,33 +29,36 @@ if File.exist?(API_SPEC_INITIALIZER)
29
29
  )
30
30
  end
31
31
 
32
- it "performs a payment request" do
33
- @payment_response.should be_authorized
34
- @payment_response.psp_reference.should_not be_empty
35
- end
32
+ # TODO disabled for now: https://github.com/wvanbergen/adyen/issues/29
33
+ # it "performs a payment request" do
34
+ # @payment_response.should be_authorized
35
+ # @payment_response.psp_reference.should_not be_empty
36
+ # end
36
37
 
37
- it "performs a recurring payment request" do
38
- response = Adyen::API.authorise_recurring_payment(
39
- @order_id,
40
- { :currency => 'EUR', :value => '1234' },
41
- { :email => "#{@user_id}@example.com", :reference => @user_id }
42
- )
43
- response.should be_authorized
44
- response.psp_reference.should_not be_empty
45
- end
38
+ # TODO disabled for now: https://github.com/wvanbergen/adyen/issues/29
39
+ # it "performs a recurring payment request" do
40
+ # response = Adyen::API.authorise_recurring_payment(
41
+ # @order_id,
42
+ # { :currency => 'EUR', :value => '1234' },
43
+ # { :email => "#{@user_id}@example.com", :reference => @user_id }
44
+ # )
45
+ # response.should be_authorized
46
+ # response.psp_reference.should_not be_empty
47
+ # end
46
48
 
47
- it "performs a one-click payment request" do
48
- detail = Adyen::API.list_recurring_details(@user_id).references.last
49
- response = Adyen::API.authorise_one_click_payment(
50
- @order_id,
51
- { :currency => 'EUR', :value => '1234' },
52
- { :email => "#{@user_id}@example.com", :reference => @user_id },
53
- '737',
54
- detail
55
- )
56
- response.should be_authorized
57
- response.psp_reference.should_not be_empty
58
- end
49
+ # TODO disabled for now: https://github.com/wvanbergen/adyen/issues/29
50
+ # it "performs a one-click payment request" do
51
+ # detail = Adyen::API.list_recurring_details(@user_id).references.last
52
+ # response = Adyen::API.authorise_one_click_payment(
53
+ # @order_id,
54
+ # { :currency => 'EUR', :value => '1234' },
55
+ # { :email => "#{@user_id}@example.com", :reference => @user_id },
56
+ # '737',
57
+ # detail
58
+ # )
59
+ # response.should be_authorized
60
+ # response.psp_reference.should_not be_empty
61
+ # end
59
62
 
60
63
  # TODO disabled for now: https://github.com/wvanbergen/adyen/issues/29
61
64
  #it "stores the provided ELV account details" do
@@ -95,11 +98,12 @@ if File.exist?(API_SPEC_INITIALIZER)
95
98
  response.should be_success
96
99
  end
97
100
 
98
- it "disables a recurring contract" do
99
- response = Adyen::API.disable_recurring_contract(@user_id)
100
- response.should be_success
101
- response.should be_disabled
102
- end
101
+ # TODO disabled for now: https://github.com/wvanbergen/adyen/issues/29
102
+ # it "disables a recurring contract" do
103
+ # response = Adyen::API.disable_recurring_contract(@user_id)
104
+ # response.should be_success
105
+ # response.should be_disabled
106
+ # end
103
107
  end
104
108
 
105
109
  else
@@ -0,0 +1,3 @@
1
+ Adyen.configuration.default_api_params = { :merchant_account => ENV['ADYEN_MERCHANT_ACCOUNT'] }
2
+ Adyen.configuration.api_username = ENV['ADYEN_API_USERNAME']
3
+ Adyen.configuration.api_password = ENV['ADYEN_API_PASSWORD']
@@ -1,3 +1,3 @@
1
- Adyen.configuration.default_api_params = { :merchant_account => 'SuperShopper' }
2
- Adyen.configuration.api_username = 'SuperShopper'
3
- Adyen.configuration.api_password = 'secret'
1
+ Adyen.configuration.default_api_params = { :merchant_account => 'SuperShopperCOM' }
2
+ Adyen.configuration.api_username = 'ws@company.SuperShopper'
3
+ Adyen.configuration.api_password = '$ecret'
@@ -1,7 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require 'rubygems'
4
-
5
3
  require 'rspec'
6
4
  require 'adyen'
7
5
  require 'adyen/matchers'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adyen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willem van Bergen
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-02-11 00:00:00.000000000 Z
14
+ date: 2014-09-14 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake
@@ -47,28 +47,28 @@ dependencies:
47
47
  requirements:
48
48
  - - '>='
49
49
  - !ruby/object:Gem::Version
50
- version: '2.3'
50
+ version: '3.2'
51
51
  type: :development
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - '>='
56
56
  - !ruby/object:Gem::Version
57
- version: '2.3'
57
+ version: '3.2'
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: nokogiri
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - ~>
62
+ - - '>='
63
63
  - !ruby/object:Gem::Version
64
- version: 1.6.0
64
+ version: 1.6.1
65
65
  type: :development
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - ~>
69
+ - - '>='
70
70
  - !ruby/object:Gem::Version
71
- version: 1.6.0
71
+ version: 1.6.1
72
72
  description: " Package to simplify including the Adyen payments services into a
73
73
  Ruby on Rails application.\n The package provides functionality to create payment
74
74
  forms, handling and storing notifications \n sent by Adyen and consuming the
@@ -124,6 +124,7 @@ files:
124
124
  - spec/api/test_helpers_spec.rb
125
125
  - spec/form_spec.rb
126
126
  - spec/functional/api_spec.rb
127
+ - spec/functional/initializer.rb.ci
127
128
  - spec/functional/initializer.rb.sample
128
129
  - spec/spec_helper.rb
129
130
  - yard_extensions.rb
@@ -145,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
146
  requirements:
146
147
  - - '>='
147
148
  - !ruby/object:Gem::Version
148
- version: '0'
149
+ version: 1.9.3
149
150
  required_rubygems_version: !ruby/object:Gem::Requirement
150
151
  requirements:
151
152
  - - '>='
@@ -169,5 +170,6 @@ test_files:
169
170
  - spec/api/test_helpers_spec.rb
170
171
  - spec/form_spec.rb
171
172
  - spec/functional/api_spec.rb
173
+ - spec/functional/initializer.rb.ci
172
174
  - spec/functional/initializer.rb.sample
173
175
  - spec/spec_helper.rb