buckaroo-ideal 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -6,7 +6,7 @@
6
6
  # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
7
  # Only full ruby name is supported here, for short names use:
8
8
  # echo "rvm use 1.9.3" > .rvmrc
9
- environment_id="ruby-1.9.3-p125@buckaroo"
9
+ environment_id="ruby-1.9.3@buckaroo"
10
10
 
11
11
  # Uncomment the following lines if you want to verify rvm version per project
12
12
  # rvmrc_rvm_version="1.10.3" # 1.10.1 seams as a safe start
@@ -16,5 +16,10 @@ Gem::Specification.new do |gem|
16
16
  gem.version = Buckaroo::Ideal::VERSION
17
17
 
18
18
  gem.add_dependency 'activesupport'
19
- gem.add_dependency 'transliterator'
19
+
20
+ if RUBY_VERSION < "1.9"
21
+ gem.add_dependency 'fastercsv'
22
+ else
23
+ gem.add_dependency 'transliterator'
24
+ end
20
25
  end
@@ -65,16 +65,16 @@ module Buckaroo
65
65
  # Default settings
66
66
  def defaults
67
67
  {
68
- gateway_url: 'https://payment.buckaroo.nl/gateway/payment.asp',
69
- merchant_key: nil,
70
- secret_key: nil,
71
- test_mode: false,
72
- success_url: nil,
73
- reject_url: nil,
74
- error_url: nil,
75
- return_method: 'POST',
76
- style: 'PAGE',
77
- autoclose_popup: false
68
+ :gateway_url => 'https://payment.buckaroo.nl/gateway/ideal_payment.asp',
69
+ :merchant_key => nil,
70
+ :secret_key => nil,
71
+ :test_mode => false,
72
+ :success_url => nil,
73
+ :reject_url => nil,
74
+ :error_url => nil,
75
+ :return_method => 'POST',
76
+ :style => 'PAGE',
77
+ :autoclose_popup => false
78
78
  }
79
79
  end
80
80
 
@@ -4,7 +4,7 @@ module Buckaroo
4
4
  module Ideal
5
5
  class Order
6
6
  def self.defaults
7
- { currency: 'EUR' }
7
+ { :currency => 'EUR' }
8
8
  end
9
9
 
10
10
  # @return [Float] The total amount that this order is for
@@ -45,24 +45,24 @@ module Buckaroo
45
45
  class Request
46
46
  def self.defaults
47
47
  {
48
- language: 'NL',
49
- success_url: Config.success_url,
50
- reject_url: Config.reject_url,
51
- error_url: Config.error_url,
52
- return_method: Config.return_method,
53
- style: Config.style,
54
- autoclose_popup: Config.autoclose_popup
48
+ :language => 'NL',
49
+ :success_url => Config.success_url,
50
+ :reject_url => Config.reject_url,
51
+ :error_url => Config.error_url,
52
+ :return_method => Config.return_method,
53
+ :style => Config.style,
54
+ :autoclose_popup => Config.autoclose_popup
55
55
  }
56
56
  end
57
57
 
58
58
  # @return [String] The configured gateway_url in +Buckaroo::Ideal::Config+
59
- delegate :gateway_url, to: Config
59
+ delegate :gateway_url, :to => Config
60
60
 
61
61
  # @return [Boolean] The configured test_mode in +Buckaroo::Ideal::Config+
62
- delegate :test_mode, to: Config
62
+ delegate :test_mode, :to => Config
63
63
 
64
64
  # @return [String] The configured merchant_key in +Buckaroo::Ideal::Config+
65
- delegate :merchant_key, to: Config
65
+ delegate :merchant_key, :to => Config
66
66
 
67
67
  # @return [Buckaroo::Ideal::Order] The order for which the payment request
68
68
  # is being made
@@ -32,13 +32,13 @@ module Buckaroo
32
32
  attr_reader :order
33
33
 
34
34
  # @return [Boolean] The configured test_mode in +Buckaroo::Ideal::Config+
35
- delegate :test_mode, to: Config
35
+ delegate :test_mode, :to => Config
36
36
 
37
37
  # @return [String] The configured merchant_key in +Buckaroo::Ideal::Config+
38
- delegate :merchant_key, to: Config
38
+ delegate :merchant_key, :to => Config
39
39
 
40
40
  # @return [String] The configured secret_key in +Buckaroo::Ideal::Config+
41
- delegate :secret_key, to: Config
41
+ delegate :secret_key, :to => Config
42
42
 
43
43
  # Initialize a new +Buckaroo::Ideal::Signature+ instance for the given
44
44
  # order.
@@ -6,10 +6,10 @@ module Buckaroo
6
6
  class ResponseSignature
7
7
 
8
8
  # @return [String] The configured merchant_key in +Buckaroo::Ideal::Config+
9
- delegate :merchant_key, to: Config
9
+ delegate :merchant_key, :to => Config
10
10
 
11
11
  # @return [String] The configured secret_key in +Buckaroo::Ideal::Config+
12
- delegate :secret_key, to: Config
12
+ delegate :secret_key, :to => Config
13
13
 
14
14
  # @return [String] The signature that was given in the response
15
15
  attr_reader :signature
@@ -1,37 +1,44 @@
1
- require 'csv'
2
-
3
1
  module Buckaroo
4
2
  module Ideal
5
3
  class Status
6
4
  class UnknownStatusCode < StandardError; end
7
5
 
8
6
  STATES = {
9
- completed: %w(071 121 151 171 190 242 243 244 245 246 247 254 255 301
10
- 401 461 462 463 464 551 601 701 801),
11
- pending: %w(000 001 070 090 091 100 105 120 126 135 136 150 156 157
12
- 170 176 177 253 300 400 460 500 550 600 700 710 790 791
13
- 792 793 800 811 814 815 831 834),
14
- failed: %w(072 073 074 075 076 101 102 103 104 106 122 123 124 125
15
- 137 138 139 152 153 155 158 159 172 173 175 178 179 201
16
- 203 204 205 206 207 251 252 260 261 262 302 303 304 305
17
- 306 309 402 409 410 411 414 421 422 425 466 468 490 491
18
- 492 501 552 553 554 555 556 560 581 590 602 605 609 610
19
- 612 690 702 703 704 705 706 707 708 711 712 720 721 802
20
- 803 804 810 812 813 816 820 821 822 823 824 830 833 835
21
- 836 890 891 900 901 910 931 932 933 934 935 940 941 942
22
- 943 944 945 946 947 948 949 950 951 952 953 954 955 956
23
- 960 961 962 963 964 971 972 973 974 975 976 977 978 980
24
- 981 982 983 990 991 992 993 999)
7
+ :completed => %w(071 121 151 171 190 242 243 244 245 246 247 254 255
8
+ 301 401 461 462 463 464 551 601 701 801),
9
+ :pending => %w(000 001 070 090 091 100 105 120 126 135 136 150 156
10
+ 157 170 176 177 253 300 400 460 500 550 600 700 710
11
+ 790 791 792 793 800 811 814 815 831 834),
12
+ :failed => %w(072 073 074 075 076 101 102 103 104 106 122 123 124
13
+ 125 137 138 139 152 153 155 158 159 172 173 175 178
14
+ 179 201 203 204 205 206 207 251 252 260 261 262 302
15
+ 303 304 305 306 309 402 409 410 411 414 421 422 425
16
+ 466 468 490 491 492 501 552 553 554 555 556 560 581
17
+ 590 602 605 609 610 612 690 702 703 704 705 706 707
18
+ 708 711 712 720 721 802 803 804 810 812 813 816 820
19
+ 821 822 823 824 830 833 835 836 890 891 900 901 910
20
+ 931 932 933 934 935 940 941 942 943 944 945 946 947
21
+ 948 949 950 951 952 953 954 955 956 960 961 962 963
22
+ 964 971 972 973 974 975 976 977 978 980 981 982 983
23
+ 990 991 992 993 999)
25
24
  }
26
25
 
27
26
  CSV_FILE = File.expand_path('../../../files/statuscodes.csv', __FILE__)
28
27
 
28
+ if RUBY_VERSION < "1.9"
29
+ require 'fastercsv'
30
+ CSV = ::FasterCSV
31
+ else
32
+ require 'csv'
33
+ CSV = ::CSV
34
+ end
35
+
29
36
  attr_reader :code, :message
30
37
 
31
38
  def self.status_codes(csv_file = CSV_FILE)
32
39
  codes = {}
33
40
 
34
- CSV.foreach(csv_file, col_sep: ';') do |row|
41
+ CSV.foreach(csv_file, :col_sep => ';') do |row|
35
42
  codes[row[0]] = row[1]
36
43
  end
37
44
 
@@ -1,12 +1,26 @@
1
- require 'transliterator'
2
-
3
1
  module Buckaroo
4
2
  module Ideal
5
3
  module Util
6
4
  extend self
7
5
 
8
- def to_normalized_string(string)
9
- Transliterator.asciify(string.to_s)
6
+ if RUBY_VERSION < "1.9"
7
+
8
+ require 'iconv'
9
+
10
+ STRIP_ACCENTS_RE = /[\^~"`']/
11
+
12
+ def to_normalized_string(string)
13
+ Iconv.iconv('US-ASCII//IGNORE//TRANSLIT', 'UTF-8', string).to_s.gsub(STRIP_ACCENTS_RE, '')
14
+ end
15
+
16
+ else
17
+
18
+ require 'transliterator'
19
+
20
+ def to_normalized_string(string)
21
+ Transliterator.asciify(string.to_s)
22
+ end
23
+
10
24
  end
11
25
 
12
26
  def to_cents(amount)
@@ -1,5 +1,5 @@
1
1
  module Buckaroo
2
2
  module Ideal
3
- VERSION = "0.0.1"
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
@@ -3,22 +3,22 @@ require 'spec_helper'
3
3
  describe Buckaroo::Ideal::Config do
4
4
  before do
5
5
  Buckaroo::Ideal::Config.configure(
6
- merchant_key: 'merchant_key',
7
- secret_key: 'secret_key',
8
- test_mode: true,
9
- success_url: 'http://example.com/transaction/success',
10
- reject_url: 'http://example.com/transaction/reject',
11
- error_url: 'http://example.com/transaction/error',
12
- return_method: 'GET',
13
- style: 'POPUP',
14
- autoclose_popup: true
6
+ :merchant_key => 'merchant_key',
7
+ :secret_key => 'secret_key',
8
+ :test_mode => true,
9
+ :success_url => 'http://example.com/transaction/success',
10
+ :reject_url => 'http://example.com/transaction/reject',
11
+ :error_url => 'http://example.com/transaction/error',
12
+ :return_method => 'GET',
13
+ :style => 'POPUP',
14
+ :autoclose_popup => true
15
15
  )
16
16
  end
17
17
 
18
18
  subject { Buckaroo::Ideal::Config }
19
19
 
20
20
  it 'has a gateway_url' do
21
- subject.gateway_url.should == 'https://payment.buckaroo.nl/gateway/payment.asp'
21
+ subject.gateway_url.should == 'https://payment.buckaroo.nl/gateway/ideal_payment.asp'
22
22
  end
23
23
 
24
24
  it 'has a merchant_key' do
@@ -5,15 +5,15 @@ describe Buckaroo::Ideal::Order do
5
5
 
6
6
  before do
7
7
  Buckaroo::Ideal::Config.configure(
8
- merchant_key: 'merchant_key',
9
- secret_key: 'secret_key',
10
- test_mode: true,
11
- success_url: 'http://example.com/transaction/success',
12
- reject_url: 'http://example.com/transaction/reject',
13
- error_url: 'http://example.com/transaction/error',
14
- return_method: 'GET',
15
- style: 'POPUP',
16
- autoclose_popup: true
8
+ :merchant_key => 'merchant_key',
9
+ :secret_key => 'secret_key',
10
+ :test_mode => true,
11
+ :success_url => 'http://example.com/transaction/success',
12
+ :reject_url => 'http://example.com/transaction/reject',
13
+ :error_url => 'http://example.com/transaction/error',
14
+ :return_method => 'GET',
15
+ :style => 'POPUP',
16
+ :autoclose_popup => true
17
17
  )
18
18
  end
19
19
 
@@ -2,18 +2,18 @@ require 'spec_helper'
2
2
 
3
3
  describe Buckaroo::Ideal::RequestSignature do
4
4
  it 'generates a signature for the given order' do
5
- order = mock invoice_number: 'EETNU-12345',
6
- amount: 12.50,
7
- currency: 'EUR'
5
+ order = mock :invoice_number => 'EETNU-12345',
6
+ :amount => 12.50,
7
+ :currency => 'EUR'
8
8
 
9
- Buckaroo::Ideal::Config.stub(:test_mode)
10
- .and_return(true)
9
+ Buckaroo::Ideal::Config.stub(:test_mode).
10
+ and_return(true)
11
11
 
12
- Buckaroo::Ideal::Config.stub(:merchant_key)
13
- .and_return('merchant_key')
12
+ Buckaroo::Ideal::Config.stub(:merchant_key).
13
+ and_return('merchant_key')
14
14
 
15
- Buckaroo::Ideal::Config.stub(:secret_key)
16
- .and_return('secret_key')
15
+ Buckaroo::Ideal::Config.stub(:secret_key).
16
+ and_return('secret_key')
17
17
 
18
18
  signature = Buckaroo::Ideal::RequestSignature.new(order)
19
19
 
@@ -26,8 +26,8 @@ describe Buckaroo::Ideal::RequestSignature do
26
26
  'secret_key' # config.secret_key
27
27
  ].join
28
28
 
29
- Digest::MD5.should_receive(:hexdigest)
30
- .with(expected_salt)
29
+ Digest::MD5.should_receive(:hexdigest).
30
+ with(expected_salt)
31
31
 
32
32
  signature.to_s
33
33
  end
@@ -6,15 +6,15 @@ describe Buckaroo::Ideal::Request do
6
6
 
7
7
  before do
8
8
  Buckaroo::Ideal::Config.configure(
9
- merchant_key: 'merchant_key',
10
- secret_key: 'secret_key',
11
- test_mode: true,
12
- success_url: 'http://example.com/transaction/success',
13
- reject_url: 'http://example.com/transaction/reject',
14
- error_url: 'http://example.com/transaction/error',
15
- return_method: 'GET',
16
- style: 'POPUP',
17
- autoclose_popup: true
9
+ :merchant_key => 'merchant_key',
10
+ :secret_key => 'secret_key',
11
+ :test_mode => true,
12
+ :success_url => 'http://example.com/transaction/success',
13
+ :reject_url => 'http://example.com/transaction/reject',
14
+ :error_url => 'http://example.com/transaction/error',
15
+ :return_method => 'GET',
16
+ :style => 'POPUP',
17
+ :autoclose_popup => true
18
18
  )
19
19
  end
20
20
 
@@ -2,14 +2,14 @@ require 'spec_helper'
2
2
 
3
3
  describe Buckaroo::Ideal::ResponseSignature do
4
4
  let(:response) {
5
- mock transaction_id: 'transaction_id',
6
- timestamp: 'timestamp',
7
- invoice_number: 'invoice_number',
8
- reference: 'reference',
9
- currency: 'EUR',
10
- amount: 12.50,
11
- status: mock(code: '101'),
12
- test_mode: true
5
+ mock :transaction_id => 'transaction_id',
6
+ :timestamp => 'timestamp',
7
+ :invoice_number => 'invoice_number',
8
+ :reference => 'reference',
9
+ :currency => 'EUR',
10
+ :amount => 12.50,
11
+ :status => mock(:code => '101'),
12
+ :test_mode => true
13
13
  }
14
14
 
15
15
  let(:signature) {
@@ -17,11 +17,11 @@ describe Buckaroo::Ideal::ResponseSignature do
17
17
  }
18
18
 
19
19
  before do
20
- Buckaroo::Ideal::Config.stub(:merchant_key)
21
- .and_return('merchant_key')
20
+ Buckaroo::Ideal::Config.stub(:merchant_key).
21
+ and_return('merchant_key')
22
22
 
23
- Buckaroo::Ideal::Config.stub(:secret_key)
24
- .and_return('secret_key')
23
+ Buckaroo::Ideal::Config.stub(:secret_key).
24
+ and_return('secret_key')
25
25
  end
26
26
 
27
27
  describe '#valid?' do
@@ -50,8 +50,7 @@ describe Buckaroo::Ideal::ResponseSignature do
50
50
  'secret_key' # config.secret_key
51
51
  ].join
52
52
 
53
- Digest::MD5.should_receive(:hexdigest)
54
- .with(expected_salt)
53
+ Digest::MD5.should_receive(:hexdigest).with(expected_salt)
55
54
 
56
55
  signature.generate_signature
57
56
  end
@@ -52,7 +52,7 @@ describe Buckaroo::Ideal::Response do
52
52
  end
53
53
 
54
54
  it 'has a time' do
55
- response.time.should == Time.new(2012, 05, 22, 12, 58, 13)
55
+ response.time.should == Time.local(2012, 05, 22, 12, 58, 13)
56
56
  end
57
57
 
58
58
  it 'has a timestamp' do
@@ -61,15 +61,13 @@ describe Buckaroo::Ideal::Response do
61
61
 
62
62
  describe '#valid?' do
63
63
  it 'returns true if the signature is valid' do
64
- response.signature.stub(:valid?)
65
- .and_return(true)
64
+ response.signature.stub(:valid?).and_return(true)
66
65
 
67
66
  response.should be_valid
68
67
  end
69
68
 
70
69
  it 'returns false if the signature if not valid' do
71
- response.signature.stub(:valid?)
72
- .and_return(false)
70
+ response.signature.stub(:valid?).and_return(false)
73
71
 
74
72
  response.should_not be_valid
75
73
  end
@@ -7,6 +7,11 @@ describe Buckaroo::Ideal::Util do
7
7
  result = Buckaroo::Ideal::Util.to_normalized_string('îñtërnâtiônàlizâtiôn')
8
8
  result.should == 'internationalization'
9
9
  end
10
+
11
+ it 'keeps dashes' do
12
+ result = Buckaroo::Ideal::Util.to_normalized_string('order-123')
13
+ result.should == 'order-123'
14
+ end
10
15
  end
11
16
 
12
17
  describe '#to_cents' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buckaroo-ideal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-24 00:00:00.000000000 Z
12
+ date: 2012-10-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &70309503982320 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70309503982320
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: transliterator
27
- requirement: &70309503981860 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,7 +37,12 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70309503981860
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  description: A simple Ruby library that aids you in handling iDEAL transactions via
37
47
  the Buckaroo iDEAL gateway.
38
48
  email:
@@ -94,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
104
  version: '0'
95
105
  requirements: []
96
106
  rubyforge_project:
97
- rubygems_version: 1.8.17
107
+ rubygems_version: 1.8.24
98
108
  signing_key:
99
109
  specification_version: 3
100
110
  summary: Integrate with the Buckaroo iDEAL API.