atos 0.0.1
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.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/MIT-LICENSE +20 -0
- data/README.md +122 -0
- data/lib/atos.rb +84 -0
- data/lib/exception_handler.rb +40 -0
- data/test/atos_test.rb +13 -0
- data/test/test_helper.rb +6 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
data.tar.gz: 2ee92e798051fc53e257525398340bd3e94ca3aa
|
4
|
+
metadata.gz: d9b6bdce2ccf1af1427b329826b1c8727ce0a7c3
|
5
|
+
SHA512:
|
6
|
+
data.tar.gz: 429143a6fba31195c52804bfc99e74e3bc64c299c1073c69c13bc32ad3849e806316468bbcc08b8b4a4da1ecb7712a6de9301933ea63d3017d9aeddb4a8fab01
|
7
|
+
metadata.gz: 1a3319abe4849de8647e34172fdf78485702a25847984ef6d838c080c57e72eaf05989f04cf2eb13746a8939afe6072c7f6587cf98b00bc83e5dbdd41a26840b
|
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 [name of plugin creator]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
Atos, a Ruby on Rails gateway for SIPS/ATOS french online payments API
|
2
|
+
===
|
3
|
+
|
4
|
+
Usage
|
5
|
+
---
|
6
|
+
1. Drop the files given by your bank in your /lib dir, so it should look like this :
|
7
|
+
|
8
|
+
```
|
9
|
+
/lib
|
10
|
+
/atos
|
11
|
+
/bin
|
12
|
+
request
|
13
|
+
request_2.4.18_2.96
|
14
|
+
....
|
15
|
+
|
16
|
+
/param
|
17
|
+
certif.fr.014295303911111
|
18
|
+
parmcom.014295303911111
|
19
|
+
parmcom.*
|
20
|
+
pathfile
|
21
|
+
```
|
22
|
+
|
23
|
+
2. From your controller, call the API like this :
|
24
|
+
|
25
|
+
```
|
26
|
+
@request = Atos.new.request(
|
27
|
+
:merchant_id => '014295303911111',
|
28
|
+
:amount => '1500',
|
29
|
+
:customer_id => 'YOUR_CUSTOMER_ID',
|
30
|
+
:automatic_response_url => 'http://YOUR_SITE.com/ANY/LISTENING/URL/YOU/WANT',
|
31
|
+
:normal_return_url => 'http://YOUR_SITE.com/NORMAL/RETURN/URL',
|
32
|
+
:cancel_return_url => 'http://YOUR_SITE.com/CANCEL/URL'
|
33
|
+
)
|
34
|
+
```
|
35
|
+
|
36
|
+
3. And then show the @request in your view (it's an HTML form)
|
37
|
+
|
38
|
+
----- Let the customer pay on the bank platform, then listen to its response ----
|
39
|
+
|
40
|
+
4. Now, you can catch the DATA parameter in response by listening to the 'automatic\_response\_url' you gave above
|
41
|
+
```
|
42
|
+
response = Atos.new.response(params[:DATA])
|
43
|
+
```
|
44
|
+
|
45
|
+
5. Finally, you get a hash in 'response', that follows the API specs :
|
46
|
+
```
|
47
|
+
{
|
48
|
+
:code
|
49
|
+
:error
|
50
|
+
:merchant_id
|
51
|
+
:merchant_country
|
52
|
+
:amount
|
53
|
+
:transaction_id
|
54
|
+
:payment_means
|
55
|
+
:transmission_date
|
56
|
+
:payment_time
|
57
|
+
:payment_date
|
58
|
+
:response_code
|
59
|
+
:payment_certificate
|
60
|
+
:authorisation_id
|
61
|
+
:currency_code
|
62
|
+
:card_number
|
63
|
+
:cvv_flag
|
64
|
+
:cvv_response_code
|
65
|
+
:bank_response_code
|
66
|
+
:complementary_code
|
67
|
+
:complementary_info
|
68
|
+
:return_context
|
69
|
+
:caddie
|
70
|
+
:receipt_complement
|
71
|
+
:merchant_language
|
72
|
+
:language
|
73
|
+
:customer_id
|
74
|
+
:order_id
|
75
|
+
:customer_email
|
76
|
+
:customer_ip_address
|
77
|
+
:capture_day
|
78
|
+
:capture_mode
|
79
|
+
:data
|
80
|
+
}
|
81
|
+
```
|
82
|
+
|
83
|
+
Notes
|
84
|
+
---
|
85
|
+
- merchant_id, amount, customer_id, automatic_response_url, normal_return_url and cancel_return_url
|
86
|
+
are required to push a request, but you can freely add others (shopping cart, customer email...),
|
87
|
+
according to the API docs.
|
88
|
+
|
89
|
+
- Default language is set to 'fr' and currency to 'Euro', simply pass your own 'locale/currency' in
|
90
|
+
the request to override.
|
91
|
+
|
92
|
+
- I prefer conventions over configuration, but you can also override with your own path dirs while
|
93
|
+
instanciating the Atos class. You just add one step to the shortand way :
|
94
|
+
|
95
|
+
```
|
96
|
+
@request = Atos.new(
|
97
|
+
:root_path => '/where',
|
98
|
+
:request_path => '/where/ever',
|
99
|
+
:response_path => '/where/ever/you',
|
100
|
+
:pathfile_path => '/where/ever/you/want'
|
101
|
+
)
|
102
|
+
```
|
103
|
+
|
104
|
+
...And then...
|
105
|
+
|
106
|
+
```
|
107
|
+
@request.request(
|
108
|
+
:merchant_id => '014295303911111',
|
109
|
+
:amount => '1500',
|
110
|
+
:customer_id => YOUR_CUSTOMER_ID,:automatic_response_url=>'http://YOUR_SITE.com/ANY/LISTENING/URL/YOU/WANT',
|
111
|
+
:normal_return_url => 'http://YOUR_SITE.com/NORMAL/FALLBACK/URL',
|
112
|
+
:cancel_return_url => 'http://YOUR_SITE.com/CANCEL/URL'
|
113
|
+
)
|
114
|
+
```
|
115
|
+
|
116
|
+
* Don't forget to check at the 'pathfile' Atos file, and fill requested paths according to your app absolute location on the server
|
117
|
+
|
118
|
+
* Drop the credit card logos in a public dir, then fill this directory's absolute location on the server
|
119
|
+
in the '/lib/atos/param/pathfile' file
|
120
|
+
|
121
|
+
* The '014295303911111' merchant\_id I use all the way here is the test merchant\_id, obviously, use you own.
|
122
|
+
|
data/lib/atos.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'exception_handler'
|
2
|
+
|
3
|
+
class Atos
|
4
|
+
|
5
|
+
attr_accessor :root_path, :request_path, :response_path, :pathfile_path
|
6
|
+
|
7
|
+
def initialize(*args)
|
8
|
+
|
9
|
+
args.empty? ? paths = {} : paths = args.first
|
10
|
+
|
11
|
+
# You may override those default paths on Class instanciation
|
12
|
+
paths[:root_path] ? @root_path = paths[:root_path] : @root_path = "#{Rails.root}/lib/atos"
|
13
|
+
paths[:request_path] ? @request_path = paths[:request_path] : @request_path = "#{self.root_path}/bin/request"
|
14
|
+
paths[:response_path] ? @response_path = paths[:response_path] : @response_path = "#{self.root_path}/bin/response"
|
15
|
+
paths[:pathfile_path] ? @pathfile_path = paths[:pathfile_path] : @pathfile_path = "#{self.root_path}/param/pathfile"
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
# Call the request binary
|
20
|
+
def request(datas)
|
21
|
+
|
22
|
+
ExceptionHandler.before(datas)
|
23
|
+
|
24
|
+
# Default parameters if nothing given
|
25
|
+
datas[:merchant_country] ||= "fr" # => French shop
|
26
|
+
datas[:language] ||= "fr" # => French locale
|
27
|
+
datas[:currency_code] ||= "978" # => Euro
|
28
|
+
datas[:pathfile] ||= "#{@pathfile_path}" # => Path to the Atos "pathfile"
|
29
|
+
|
30
|
+
args = ''
|
31
|
+
datas.each do |key, value|
|
32
|
+
args << "#{key.to_s}=#{value} "
|
33
|
+
end
|
34
|
+
|
35
|
+
response_array = ExceptionHandler.on_launch(`#{self.request_path} #{args}`)
|
36
|
+
|
37
|
+
# If everything goes fine, should now respond an HTML form
|
38
|
+
response_array[3]
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
# Decrypt bank response, then return a hash
|
43
|
+
def response(datas)
|
44
|
+
|
45
|
+
response_array = ExceptionHandler.on_launch(`#{self.response_path} pathfile=#{self.pathfile_path} message=#{datas}`)
|
46
|
+
|
47
|
+
{
|
48
|
+
:code => response_array[1],
|
49
|
+
:error => response_array[2],
|
50
|
+
:merchant_id => response_array[3],
|
51
|
+
:merchant_country => response_array[4],
|
52
|
+
:amount => response_array[5],
|
53
|
+
:transaction_id => response_array[6],
|
54
|
+
:payment_means => response_array[7],
|
55
|
+
:transmission_date => response_array[8],
|
56
|
+
:payment_time => response_array[9],
|
57
|
+
:payment_date => response_array[10],
|
58
|
+
:response_code => response_array[11],
|
59
|
+
:payment_certificate => response_array[12],
|
60
|
+
:authorisation_id => response_array[13],
|
61
|
+
:currency_code => response_array[14],
|
62
|
+
:card_number => response_array[15],
|
63
|
+
:cvv_flag => response_array[16],
|
64
|
+
:cvv_response_code => response_array[17],
|
65
|
+
:bank_response_code => response_array[18],
|
66
|
+
:complementary_code => response_array[19],
|
67
|
+
:complementary_info => response_array[20],
|
68
|
+
:return_context => response_array[21],
|
69
|
+
:caddie => response_array[22],
|
70
|
+
:receipt_complement => response_array[23],
|
71
|
+
:merchant_language => response_array[24],
|
72
|
+
:language => response_array[25],
|
73
|
+
:customer_id => response_array[26],
|
74
|
+
:order_id => response_array[27],
|
75
|
+
:customer_email => response_array[28],
|
76
|
+
:customer_ip_address => response_array[29],
|
77
|
+
:capture_day => response_array[30],
|
78
|
+
:capture_mode => response_array[31],
|
79
|
+
:data => response_array[32]
|
80
|
+
}
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class ExceptionHandler < StandardError
|
2
|
+
|
3
|
+
# Minimum required parameters
|
4
|
+
def self.before(datas)
|
5
|
+
|
6
|
+
required_params = [
|
7
|
+
'merchant_id',
|
8
|
+
'amount',
|
9
|
+
'customer_id',
|
10
|
+
'cancel_return_url',
|
11
|
+
'normal_return_url',
|
12
|
+
'automatic_response_url'
|
13
|
+
]
|
14
|
+
|
15
|
+
required_params.each do |r|
|
16
|
+
raise "Atos plugin error : missing parameter '#{r}' in request" if !datas[r.to_sym]
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
# Check if the request is ok
|
22
|
+
def self.on_launch(datas)
|
23
|
+
|
24
|
+
response_array = datas.split("!")
|
25
|
+
|
26
|
+
case response_array[1]
|
27
|
+
when nil
|
28
|
+
# No response at all from API
|
29
|
+
raise "Atos plugin error : binary file does not respond ! Check your 'request' binary path, default is 'Rails.root/lib/atos/bin'"
|
30
|
+
when "0"
|
31
|
+
# API respond 'ok', return the content
|
32
|
+
response_array
|
33
|
+
else
|
34
|
+
# API binary respond an error, formated in an HTML table. Let's strip tags before showing the error message
|
35
|
+
raise "Atos API binary file outputs : #{response_array[2].gsub(/<\/?[^>]*>/, '')}"
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/test/atos_test.rb
ADDED
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: atos
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Guillaume Barillot
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2013-06-07 00:00:00 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
prerelease: false
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- &id002
|
20
|
+
- ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
type: :runtime
|
24
|
+
version_requirements: *id001
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
prerelease: false
|
28
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- *id002
|
31
|
+
type: :development
|
32
|
+
version_requirements: *id003
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: activesupport
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.2.13
|
41
|
+
type: :development
|
42
|
+
version_requirements: *id004
|
43
|
+
description: Ruby on Rails gateway for SIPS/ATOS french online payments API
|
44
|
+
email: gbarillot@gmail.com
|
45
|
+
executables: []
|
46
|
+
|
47
|
+
extensions: []
|
48
|
+
|
49
|
+
extra_rdoc_files:
|
50
|
+
- README.md
|
51
|
+
files:
|
52
|
+
- MIT-LICENSE
|
53
|
+
- README.md
|
54
|
+
- Gemfile
|
55
|
+
- lib/atos.rb
|
56
|
+
- lib/exception_handler.rb
|
57
|
+
- test/atos_test.rb
|
58
|
+
- test/test_helper.rb
|
59
|
+
homepage: http://github.com/gbarillot/atos
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- *id002
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- *id002
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.0.3
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Ruby on Rails gateway for SIPS/ATOS
|
82
|
+
test_files:
|
83
|
+
- test/atos_test.rb
|