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 +25 -7
- data/VERSION +1 -1
- data/lib/ogone-rails/helpers.rb +123 -35
- data/lib/ogone-rails/string-to-hash.rb +7 -12
- data/ogone-rails.gemspec +1 -1
- metadata +12 -12
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
|
82
|
+
Get parameters:
|
65
83
|
|
66
84
|
@check.get_parameters
|
67
85
|
|
68
|
-
…
|
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" =>
|
72
|
-
"amount" =>
|
89
|
+
"order_id" => 46185,
|
90
|
+
"amount" => 299.38,
|
73
91
|
"currency" => "EUR",
|
74
92
|
"payment_method" => "CreditCard",
|
75
93
|
"acceptance" => "test123",
|
76
|
-
"status" => "
|
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.
|
1
|
+
0.0.3
|
data/lib/ogone-rails/helpers.rb
CHANGED
@@ -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
|
10
|
+
form = Form.new(action)
|
11
|
+
hash = StringToHash.new
|
11
12
|
|
12
13
|
# REQUIRED VALUES
|
13
|
-
|
14
|
+
# hash.reset
|
14
15
|
# pspid
|
15
|
-
form
|
16
|
-
|
16
|
+
form.add_input('PSPID', OgoneRails::pspid)
|
17
|
+
hash.add_parameter 'PSPID', OgoneRails::pspid
|
17
18
|
# currency
|
18
|
-
form
|
19
|
-
|
19
|
+
form.add_input('currency', OgoneRails::currency)
|
20
|
+
hash.add_parameter 'currency', OgoneRails::currency
|
20
21
|
# language
|
21
|
-
form
|
22
|
-
|
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
|
32
|
-
|
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
|
38
|
-
|
42
|
+
form.add_input('amount', value)
|
43
|
+
hash.add_parameter 'amount', value
|
39
44
|
|
40
45
|
when :customer_name
|
41
|
-
form
|
42
|
-
|
46
|
+
form.add_input('CN', value)
|
47
|
+
hash.add_parameter 'CN', value
|
43
48
|
|
44
49
|
when :customer_email
|
45
|
-
form
|
46
|
-
|
50
|
+
form.add_input('EMAIL', value)
|
51
|
+
hash.add_parameter 'EMAIL', value
|
47
52
|
|
48
53
|
when :customer_address
|
49
|
-
form
|
50
|
-
|
54
|
+
form.add_input('owneraddress', value)
|
55
|
+
hash.add_parameter 'owneraddress', value
|
51
56
|
|
52
57
|
when :customer_zip
|
53
|
-
form
|
54
|
-
|
58
|
+
form.add_input('ownerZIP', value)
|
59
|
+
hash.add_parameter 'ownerZIP', value
|
55
60
|
|
56
61
|
when :customer_city
|
57
|
-
form
|
58
|
-
|
62
|
+
form.add_input('ownertown', value)
|
63
|
+
hash.add_parameter 'ownertown', value
|
59
64
|
|
60
65
|
when :customer_country
|
61
|
-
form
|
62
|
-
|
66
|
+
form.add_input('ownercty', value)
|
67
|
+
hash.add_parameter 'ownercty', value
|
63
68
|
|
64
69
|
when :customer_phone
|
65
|
-
form
|
66
|
-
|
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
|
140
|
+
form.add_input(option, value)
|
70
141
|
end
|
71
142
|
end
|
72
143
|
|
73
144
|
# shasign
|
74
|
-
sha_in =
|
75
|
-
form
|
145
|
+
sha_in = hash.generate_sha_in
|
146
|
+
form.add_input('SHASign', sha_in)
|
76
147
|
|
77
|
-
|
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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
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
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.
|
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: &
|
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: *
|
24
|
+
version_requirements: *70258295961920
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rdoc
|
27
|
-
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: *
|
35
|
+
version_requirements: *70258295960780
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
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: *
|
46
|
+
version_requirements: *70258295915400
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
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: *
|
57
|
+
version_requirements: *70258295913900
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rcov
|
60
|
-
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: *
|
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:
|
108
|
+
hash: 2104379818654802254
|
109
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
110
|
none: false
|
111
111
|
requirements:
|