ogone-rails 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -38,6 +38,7 @@ Define:
38
38
  Generate an **ogone_form**:
39
39
 
40
40
  ogone_form({
41
+ #transaction information
41
42
  :order_id => 12345,
42
43
  :amount => 299.99,
43
44
  :customer_name => "Jan Janssen",
@@ -46,8 +47,25 @@ Generate an **ogone_form**:
46
47
  :customer_zip => "1000",
47
48
  :customer_city => "Brussel",
48
49
  :customer_country => "Belgium",
49
- :customer_phone => "0412345678"
50
- })
50
+ :customer_phone => "0412345678",
51
+
52
+ # feedback url's
53
+ :accept_url => "www.example.com/ogone/accept",
54
+ :decline_url => "www.example.com/ogone/decline",
55
+ :exception_url => "www.example.com/ogone/exception",
56
+ :cancel_url => "www.example.com/ogone/cancel",
57
+
58
+ # look and feel
59
+ :title => "lorem ipsum",
60
+ :bg_color => "FFFFFF",
61
+ :text_color => "000000"
62
+ :table_bg_color => "000000"
63
+ :table_text_color => "000000"
64
+ :button_bg_color => "CCCCCC"
65
+ :button_text_color => "000000"
66
+ :font_family => "Helvetica"
67
+ :logo => "www.example.com/images/logo.png"
68
+ })
51
69
 
52
70
  ### Check Ogone feedback
53
71
 
@@ -61,19 +79,19 @@ Check valid authorization:
61
79
  @check.valid?
62
80
  #return true or false
63
81
 
64
- Get parameters, returned in a hash format. The keys are renamed to be much more readable:
82
+ Get parameters:
65
83
 
66
84
  @check.get_parameters
67
85
 
68
- will return
86
+ returns the Ogone feedback in a hash format. The keys are made more readable then Ogone provides them:
69
87
 
70
88
  {
71
- "order_id" => "46185",
72
- "amount" => "299.38",
89
+ "order_id" => 46185,
90
+ "amount" => 299.38,
73
91
  "currency" => "EUR",
74
92
  "payment_method" => "CreditCard",
75
93
  "acceptance" => "test123",
76
- "status" => "5",
94
+ "status" => "Authorized",
77
95
  "card_number" => "XXXXXXXXXXXX1111",
78
96
  "pay_id" => "14838904",
79
97
  "error" => nil,
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -1,25 +1,26 @@
1
1
  module OgoneRails
2
+
2
3
  module Helpers
3
4
  extend self
4
5
 
5
6
  def ogone_form options={}
6
- form = ""
7
7
 
8
8
  OgoneRails::mode == "live" ? action = OgoneRails::LIVE_SERVICE_URL : action = OgoneRails::TEST_SERVICE_URL
9
9
 
10
- form << "<form method='post' action='#{action}'>\n"
10
+ form = Form.new(action)
11
+ hash = StringToHash.new
11
12
 
12
13
  # REQUIRED VALUES
13
- StringToHash::reset
14
+ # hash.reset
14
15
  # pspid
15
- form << "\t<input type='hidden' name='PSPID' value='#{OgoneRails::pspid}'>\n"
16
- StringToHash::add_parameter 'PSPID', OgoneRails::pspid
16
+ form.add_input('PSPID', OgoneRails::pspid)
17
+ hash.add_parameter 'PSPID', OgoneRails::pspid
17
18
  # currency
18
- form << "\t<input type='hidden' name='currency' value='#{OgoneRails::currency}'>\n"
19
- StringToHash::add_parameter 'currency', OgoneRails::currency
19
+ form.add_input('currency', OgoneRails::currency)
20
+ hash.add_parameter 'currency', OgoneRails::currency
20
21
  # language
21
- form << "\t<input type='hidden' name='language' value='#{OgoneRails::language}'>\n"
22
- StringToHash::add_parameter 'language', OgoneRails::language
22
+ form.add_input('language', OgoneRails::language)
23
+ hash.add_parameter 'language', OgoneRails::language
23
24
 
24
25
 
25
26
 
@@ -27,58 +28,145 @@ module OgoneRails
27
28
  options.each do |option, value|
28
29
  case option
29
30
 
31
+
32
+ # ------------------
33
+ # General parameters
34
+
30
35
  when :order_id
31
- form << "\t<input type='hidden' name='orderID' value='#{value}'>\n"
32
- StringToHash::add_parameter 'orderID', value
36
+ form.add_input('orderID', value)
37
+ hash.add_parameter 'orderID', value
33
38
 
34
39
  when :amount
35
40
  #amount 15.00 -> 1500
36
41
  value = (value.to_f * 100).to_i
37
- form << "\t<input type='hidden' name='amount' value='#{value}'>\n"
38
- StringToHash::add_parameter 'amount', value
42
+ form.add_input('amount', value)
43
+ hash.add_parameter 'amount', value
39
44
 
40
45
  when :customer_name
41
- form << "\t<input type='hidden' name='CN' value='#{value}'>\n"
42
- StringToHash::add_parameter 'CN', value
46
+ form.add_input('CN', value)
47
+ hash.add_parameter 'CN', value
43
48
 
44
49
  when :customer_email
45
- form << "\t<input type='hidden' name='EMAIL' value='#{value}'>\n"
46
- StringToHash::add_parameter 'EMAIL', value
50
+ form.add_input('EMAIL', value)
51
+ hash.add_parameter 'EMAIL', value
47
52
 
48
53
  when :customer_address
49
- form << "\t<input type='hidden' name='owneraddress' value='#{value}'>\n"
50
- StringToHash::add_parameter 'owneraddress', value
54
+ form.add_input('owneraddress', value)
55
+ hash.add_parameter 'owneraddress', value
51
56
 
52
57
  when :customer_zip
53
- form << "\t<input type='hidden' name='ownerZIP' value='#{value}'>\n"
54
- StringToHash::add_parameter 'ownerZIP', value
58
+ form.add_input('ownerZIP', value)
59
+ hash.add_parameter 'ownerZIP', value
55
60
 
56
61
  when :customer_city
57
- form << "\t<input type='hidden' name='ownertown' value='#{value}'>\n"
58
- StringToHash::add_parameter 'ownertown', value
62
+ form.add_input('ownertown', value)
63
+ hash.add_parameter 'ownertown', value
59
64
 
60
65
  when :customer_country
61
- form << "\t<input type='hidden' name='ownercty' value='#{value}'>\n"
62
- StringToHash::add_parameter 'ownercty', value
66
+ form.add_input('ownercty', value)
67
+ hash.add_parameter 'ownercty', value
63
68
 
64
69
  when :customer_phone
65
- form << "\t<input type='hidden' name='ownertelno' value='#{value}'>\n"
66
- StringToHash::add_parameter 'ownertelno', value
70
+ form.add_input('ownertelno', value)
71
+ hash.add_parameter 'ownertelno', value
72
+
73
+
74
+ # --------------
75
+ # Feedback url's
76
+
77
+ when :accept_url
78
+ form.add_input('accepturl', value)
79
+ hash.add_parameter 'accepturl', value
80
+
81
+ when :decline_url
82
+ form.add_input('declineurl', value)
83
+ hash.add_parameter 'declineurl', value
84
+
85
+ when :exception_url
86
+ form.add_input('exceptionurl', value)
87
+ hash.add_parameter 'exceptionurl', value
67
88
 
89
+ when :cancel_url
90
+ form.add_input('cancelurl', value)
91
+ hash.add_parameter 'cancelurl', value
92
+
93
+
94
+ # --------------
95
+ # Look and feel
96
+
97
+ when :title
98
+ form.add_input('TITLE', value)
99
+ hash.add_parameter 'TITLE', value
100
+
101
+ when :bg_color
102
+ form.add_input('BGCOLOR', value)
103
+ hash.add_parameter 'BGCOLOR', value
104
+
105
+
106
+ when :text_color
107
+ form.add_input('TXTCOLOR', value)
108
+ hash.add_parameter 'TXTCOLOR', value
109
+
110
+
111
+ when :table_bg_color
112
+ form.add_input('TBLBGCOLOR', value)
113
+ hash.add_parameter 'TBLBGCOLOR', value
114
+
115
+ when :table_text_color
116
+ form.add_input('TBLTXTCOLOR', value)
117
+ hash.add_parameter 'TBLTXTCOLOR', value
118
+
119
+
120
+ when :button_bg_color
121
+ form.add_input('BUTTONBGCOLOR', value)
122
+ hash.add_parameter 'BUTTONBGCOLOR', value
123
+
124
+
125
+ when :button_text_color
126
+ form.add_input('BUTTONTXTCOLOR', value)
127
+ hash.add_parameter 'BUTTONTXTCOLOR', value
128
+
129
+
130
+ when :font_family
131
+ form.add_input('FONTTYPE', value)
132
+ hash.add_parameter 'FONTTYPE', value
133
+
134
+ when :logo
135
+ form.add_input('LOGO', value)
136
+ hash.add_parameter 'LOGO', value
137
+
138
+
68
139
  else
69
- form << "\t<input type='hidden' name='#{option}' value='#{value}'>\n"
140
+ form.add_input(option, value)
70
141
  end
71
142
  end
72
143
 
73
144
  # shasign
74
- sha_in = StringToHash.generate_sha_in
75
- form << "\t<input type='hidden' name='SHASign' value='#{sha_in}'>\n"
145
+ sha_in = hash.generate_sha_in
146
+ form.add_input('SHASign', sha_in)
76
147
 
77
- #submit
78
- form << "\t<input type='submit' value='ga verder naar ogone' id='submit2' name='submit2'>\n"
79
-
80
- form << "</form>"
81
- form.html_safe
148
+ form.get_form
82
149
  end
83
150
  end
151
+
152
+
153
+ private
154
+
155
+ class Form
156
+ def initialize action
157
+ @form = ""
158
+ @form << "<form method='post' action='#{action}'>\n"
159
+ end
160
+
161
+ def add_input name, value
162
+ @form << "\t<input type='hidden' name='#{name}' value='#{value}'>\n"
163
+ end
164
+
165
+
166
+ def get_form
167
+ @form << "\t<input type='submit' value='ga verder naar ogone' id='submit2' name='submit2'>\n"
168
+ @form << "</form>"
169
+ @form.html_safe
170
+ end
171
+ end
84
172
  end
@@ -1,8 +1,10 @@
1
1
  module OgoneRails
2
- module StringToHash
3
- extend self
4
- @params = {}
5
- @sha_in_phrase = ""
2
+ class StringToHash
3
+
4
+ def initialize
5
+ @params = {}
6
+ @sha_in_phrase = ""
7
+ end
6
8
 
7
9
  def add_parameter key, value
8
10
  @params[key.upcase] = value
@@ -20,14 +22,7 @@ module OgoneRails
20
22
 
21
23
  end
22
24
 
23
- def self.params
24
- @params
25
- end
26
-
27
- def self.sha_in_phrase
28
- @sha_in_phrase
29
- end
30
-
25
+ # unused since Module transformed to Class
31
26
  def reset
32
27
  @sha_in_phrase = ""
33
28
  @params = {}
data/ogone-rails.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ogone-rails"
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Robin Houdmeyers"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ogone-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-05-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
16
- requirement: &70331864054080 !ruby/object:Gem::Requirement
16
+ requirement: &70258295961920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70331864054080
24
+ version_requirements: *70258295961920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &70331864052940 !ruby/object:Gem::Requirement
27
+ requirement: &70258295960780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.12'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70331864052940
35
+ version_requirements: *70258295960780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &70331864007560 !ruby/object:Gem::Requirement
38
+ requirement: &70258295915400 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.1.3
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70331864007560
46
+ version_requirements: *70258295915400
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &70331864006060 !ruby/object:Gem::Requirement
49
+ requirement: &70258295913900 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.8.3
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70331864006060
57
+ version_requirements: *70258295913900
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rcov
60
- requirement: &70331864004080 !ruby/object:Gem::Requirement
60
+ requirement: &70258295911920 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70331864004080
68
+ version_requirements: *70258295911920
69
69
  description: Add Ogone payments functionality to your Rails application
70
70
  email: houdmeyers@gmail.com
71
71
  executables: []
@@ -105,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  segments:
107
107
  - 0
108
- hash: 3204021684087159827
108
+ hash: 2104379818654802254
109
109
  required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  none: false
111
111
  requirements: