adyen 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008 Willem van Bergen and Michel Barbosa
1
+ Copyright (c) 2008 - 2009 Willem van Bergen and Michel Barbosa
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -2,13 +2,16 @@
2
2
 
3
3
  Package to simplify including the Adyen payments services into a Ruby on Rails application.
4
4
 
5
- Adyen integration relies on three modes of communication between Adyen, your server and your client/customer:
5
+ Adyen integration relies on three modes of communication between Adyen, your server and
6
+ your client/customer:
6
7
 
7
8
  * Client-to-Adyen communication using forms and redirects.
8
9
  * Adyen-to-server communications using notifications.
9
10
  * Server-to-Adyen communication using SOAP services.
10
11
 
11
- This library aims to ease the implementation of all these modes into your application. Moreover, it provides matchers, assertions and mocks to make it easier to implement an automated test suite to assert the integration is working correctly.
12
+ This library aims to ease the implementation of all these modes into your application.
13
+ Moreover, it provides matchers, assertions and mocks to make it easier to implement an
14
+ automated test suite to assert the integration is working correctly.
12
15
 
13
16
  == Installation
14
17
 
@@ -27,6 +30,6 @@ See the project wiki on http://wiki.github.com/wvanbergen/adyen to get started.
27
30
 
28
31
  == About
29
32
 
30
- This package is written by Michel Barbosa and Willem van Bergen for Floorplanner.com,
31
- and made public under the MIT license (see LICENSE). It comes without warranty of any kind,
32
- so use at your own risk.
33
+ This package is written by Michel Barbosa and Willem van Bergen for Floorplanner.com, and
34
+ made public under the MIT license (see LICENSE). It comes without warranty of any kind, so
35
+ use at your own risk.
@@ -1,21 +1,30 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'adyen'
3
- s.version = "0.1.4"
4
- s.date = "2009-09-29"
3
+ s.version = "0.1.5"
4
+ s.date = "2009-10-07"
5
5
 
6
- s.summary = "Integrate Adyen payment services in you Ruby on Rails application"
7
- s.description = "Package to simplify including the Adyen payments services into a Ruby on Rails application."
6
+ s.summary = "Integrate Adyen payment services in you Ruby on Rails application."
7
+ s.description = <<-EOS
8
+ Package to simplify including the Adyen payments services into a Ruby on Rails application.
9
+ The package provides functionality to create payment forms, handling and storing notifications
10
+ sent by Adyen and consuming the SOAP services provided by Adyen. Moreover, it contains helper
11
+ methods, mocks and matchers to simpify writing tests/specsfor your code.
12
+ EOS
8
13
 
9
14
  s.authors = ['Willem van Bergen', 'Michel Barbosa']
10
15
  s.email = ['willem@vanbergen.org', 'cicaboo@gmail.com']
11
- s.homepage = 'http://www.adyen.com'
16
+ s.homepage = 'http://wiki.github.com/wvanbergen/adyen'
12
17
 
13
18
  s.add_development_dependency('rspec', '>= 1.1.4')
14
19
  s.add_development_dependency('git', '>= 1.1.0')
15
20
 
21
+ s.requirements << 'Handsoap is required for accessing the SOAP services. See http://github.com/troelskn/handsoap.'
22
+ s.requirements << 'LibXML is required for using the RSpec matchers.'
23
+ s.requirements << 'ActiveRecord is required for storing the notifications in your database.'
24
+
16
25
  s.rdoc_options << '--title' << s.name << '--main' << 'README.rdoc' << '--line-numbers' << '--inline-source'
17
26
  s.extra_rdoc_files = ['README.rdoc']
18
27
 
19
28
  s.files = %w(spec/spec_helper.rb lib/adyen/form.rb .gitignore LICENSE spec/soap_spec.rb spec/notification_spec.rb lib/adyen/soap.rb init.rb spec/adyen_spec.rb adyen.gemspec Rakefile tasks/github-gem.rake spec/form_spec.rb README.rdoc lib/adyen/notification.rb lib/adyen/matchers.rb lib/adyen/formatter.rb lib/adyen.rb lib/adyen/encoding.rb)
20
29
  s.test_files = %w(spec/soap_spec.rb spec/notification_spec.rb spec/adyen_spec.rb spec/form_spec.rb)
21
- end
30
+ end
@@ -36,10 +36,9 @@ module Adyen
36
36
  attributes[:session_validity] = Adyen::Formatter::DateTime.fmt_time(attributes[:session_validity])
37
37
  end
38
38
 
39
-
40
- def self.hidden_fields(attributes = {})
39
+ def self.payment_fields(attributes = {})
41
40
  do_attribute_transformations!(attributes)
42
-
41
+
43
42
  raise "Cannot generate form: :currency code attribute not found!" unless attributes[:currency_code]
44
43
  raise "Cannot generate form: :payment_amount code attribute not found!" unless attributes[:payment_amount]
45
44
  raise "Cannot generate form: :merchant_account attribute not found!" unless attributes[:merchant_account]
@@ -48,9 +47,16 @@ module Adyen
48
47
 
49
48
  # Merchant signature
50
49
  attributes[:merchant_sig] = calculate_signature(attributes)
50
+ return attributes
51
+ end
52
+
53
+ def self.redirect_url(attributes)
54
+ self.url + '?' + payment_fields(attributes).map { |(k, v)| "#{k.to_s.camelize(:lower)}=#{CGI.escape(v.to_s)}" }.join('&')
55
+ end
51
56
 
57
+ def self.hidden_fields(attributes = {})
52
58
  # Generate hidden input tags
53
- attributes.map { |key, value|
59
+ payment_fields(attributes).map { |key, value|
54
60
  self.tag(:input, :type => 'hidden', :name => key.to_s.camelize(:lower), :value => value)
55
61
  }.join("\n")
56
62
  end
@@ -50,8 +50,10 @@ module Adyen
50
50
  # Setup basic auth headers in the HTTP client
51
51
  def on_after_create_http_client(http_client)
52
52
  debug { |logger| logger.puts "Authorization: #{Adyen::SOAP.username}:#{Adyen::SOAP.password}..." }
53
- # http_client.userpwd = "#{Adyen::SOAP.username}:#{Adyen::SOAP.password}"
54
- http_client.set_auth Adyen::SOAP.username, Adyen::SOAP.password
53
+ # Handsoap BUG: Setting headers does not work, using a Curb specific method for now.
54
+ # auth = Base64.encode64("#{Adyen::SOAP.username}:#{Adyen::SOAP.password}").chomp
55
+ # http_client.headers['Authorization'] = "Basic #{auth}"
56
+ http_client.userpwd = "#{Adyen::SOAP.username}:#{Adyen::SOAP.password}"
55
57
  end
56
58
 
57
59
  # Setup XML namespaces for SOAP request body
@@ -63,6 +63,30 @@ describe Adyen::Form do
63
63
 
64
64
  end
65
65
 
66
+ describe 'redirect URL generation' do
67
+ before(:each) do
68
+ @attributes = { :currency_code => 'GBP', :payment_amount => 10000, :ship_before_date => Date.today,
69
+ :merchant_reference => 'Internet Order 12345', :skin_code => '4aD37dJA',
70
+ :merchant_account => 'TestMerchant', :session_validity => 1.hour.from_now }
71
+
72
+ @redirect_url = Adyen::Form.redirect_url(@attributes.merge(:shared_secret => 'secret'))
73
+ end
74
+
75
+ it "should return an URL pointing to the adyen server" do
76
+ @redirect_url.should =~ %r[^#{Adyen::Form.url}]
77
+ end
78
+
79
+ it "should include all provided attributes" do
80
+ params = @redirect_url.split('?', 2).last.split('&').map { |param| param.split('=', 2).first }
81
+ params.should include(*(@attributes.keys.map { |k| k.to_s.camelize(:lower) }))
82
+ end
83
+
84
+ it "should include the merchant signature" do
85
+ params = @redirect_url.split('?', 2).last.split('&').map { |param| param.split('=', 2).first }
86
+ params.should include('merchantSig')
87
+ end
88
+ end
89
+
66
90
  describe 'hidden fields generation' do
67
91
 
68
92
  include ActionView::Helpers::TagHelper
@@ -1,30 +1,5 @@
1
1
  require "#{File.dirname(__FILE__)}/spec_helper.rb"
2
2
 
3
- describe Adyen::SOAP::RecurringService do
4
-
5
- before(:each) do
6
-
7
- response_xml = <<-EOS
8
- <?xml version="1.0" encoding="UTF-8" ?>
9
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
10
- xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
11
-
12
- <soap:Body>
13
- </soap:Body>
14
- </soap:Envelope>
15
- EOS
3
+ describe Adyen::SOAP do
16
4
 
17
- @response = mock('Handsoap::HTTP::Response')
18
- @part = mock('Handsoap::HTTP::Part')
19
- @part.stub!(:body).and_return(response_xml)
20
-
21
- @response.stub!(:status).and_return(200)
22
- @response.stub!(:primary_part).and_return(@part)
23
- Adyen::SOAP::RecurringService.instance.stub!(:send_http_request).and_return(@response)
24
- end
25
-
26
- it "should send an HTTP request" do
27
- Adyen::SOAP::RecurringService.instance.should_receive(:send_http_request).and_return(@response)
28
- Adyen::SOAP::RecurringService.submit()
29
- end
30
5
  end
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: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willem van Bergen
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-09-29 00:00:00 +02:00
13
+ date: 2009-10-07 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -33,7 +33,7 @@ dependencies:
33
33
  - !ruby/object:Gem::Version
34
34
  version: 1.1.0
35
35
  version:
36
- description: Package to simplify including the Adyen payments services into a Ruby on Rails application.
36
+ description: " Package to simplify including the Adyen payments services into a Ruby on Rails application.\n The package provides functionality to create payment forms, handling and storing notifications \n sent by Adyen and consuming the SOAP services provided by Adyen. Moreover, it contains helper\n methods, mocks and matchers to simpify writing tests/specsfor your code.\n"
37
37
  email:
38
38
  - willem@vanbergen.org
39
39
  - cicaboo@gmail.com
@@ -64,7 +64,7 @@ files:
64
64
  - lib/adyen.rb
65
65
  - lib/adyen/encoding.rb
66
66
  has_rdoc: true
67
- homepage: http://www.adyen.com
67
+ homepage: http://wiki.github.com/wvanbergen/adyen
68
68
  licenses: []
69
69
 
70
70
  post_install_message:
@@ -89,13 +89,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  - !ruby/object:Gem::Version
90
90
  version: "0"
91
91
  version:
92
- requirements: []
93
-
92
+ requirements:
93
+ - Handsoap is required for accessing the SOAP services. See http://github.com/troelskn/handsoap.
94
+ - LibXML is required for using the RSpec matchers.
95
+ - ActiveRecord is required for storing the notifications in your database.
94
96
  rubyforge_project:
95
97
  rubygems_version: 1.3.5
96
98
  signing_key:
97
99
  specification_version: 3
98
- summary: Integrate Adyen payment services in you Ruby on Rails application
100
+ summary: Integrate Adyen payment services in you Ruby on Rails application.
99
101
  test_files:
100
102
  - spec/soap_spec.rb
101
103
  - spec/notification_spec.rb