omnikassa 0.0.1.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +2 -0
- data/LICENSE +22 -0
- data/README.md +97 -0
- data/Rakefile +7 -0
- data/lib/omnikassa/codes.rb +33 -0
- data/lib/omnikassa/configuration.rb +13 -0
- data/lib/omnikassa/data.rb +15 -0
- data/lib/omnikassa/mock_response.rb +90 -0
- data/lib/omnikassa/request.rb +91 -0
- data/lib/omnikassa/response.rb +65 -0
- data/lib/omnikassa/seal.rb +10 -0
- data/lib/omnikassa/version.rb +3 -0
- data/lib/omnikassa.rb +26 -0
- data/omnikassa.gemspec +19 -0
- data/spec/lib/data_spec.rb +33 -0
- data/spec/lib/mock_response_spec.rb +16 -0
- data/spec/lib/request_spec.rb +44 -0
- data/spec/lib/response_spec.rb +49 -0
- data/spec/spec_helper.rb +11 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 135111f5de9d47873b1b7eae29615c444c98134e
|
4
|
+
data.tar.gz: 91168eee7807e0ac1c159923e417fa8750926d49
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 551c9c23e02dfbf5e5221044ae0ec4c60f3fbfefb9eb0522b008d577fbfbf3ca87e44da92d552d40fba38c246eb950b626b8d67e2b66bb4343b282570e54c521
|
7
|
+
data.tar.gz: 8938a3fe60b7b7b84924d5e1f0d9aa4ac5fc4b241cd3499c69e150958aa74191c72e165954f475547e22d31477f4cd88640b7664408ccf10c036fe71914c8f23
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Tijmen Brommet
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/tijmenb/omnikassa.png?branch=master)](https://travis-ci.org/tijmenb/omnikassa)
|
2
|
+
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/tijmenb/omnikassa)
|
3
|
+
|
4
|
+
# Omnikassa
|
5
|
+
|
6
|
+
De Omnikassa Gem is een wrapper voor [Rabobank's Omnikassa](http://www.rabobank.nl/bedrijven/producten/betalen_en_ontvangen/geld_ontvangen/rabo_omnikassa/).
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
Configureer de app met je gegevens:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
# config/initializers/omnikassa.rb
|
14
|
+
Omnikassa.configure do |config|
|
15
|
+
config.merchant_id = '002020000000001'
|
16
|
+
config.secret_key = '002020000000001_KEY1'
|
17
|
+
config.environment = :test
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
Maak een request aan in de controller:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
# controllers/payment_controller.rb
|
25
|
+
def payment
|
26
|
+
@omnikassa_request = Omnikassa::Request.new(
|
27
|
+
amount: 1234, # bedrag in centen
|
28
|
+
return_url: payment_return_url, # de URL waar de user naartoe gaat na betaling
|
29
|
+
response_url: payment_response_url, # URL waar Rabo naar POST na een betaling
|
30
|
+
reference: '1223123123' # Een unieke identifier voor je transactie
|
31
|
+
)
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
Een form voor de redirect:
|
36
|
+
|
37
|
+
```erb
|
38
|
+
<%= form_tag @omnikassa_request.url do |f| %>
|
39
|
+
<%= hidden_field_tag 'Data', @omnikassa_request.data_string %>
|
40
|
+
<%= hidden_field_tag 'InterfaceVersion', @omnikassa_request.interface_version %>
|
41
|
+
<%= hidden_field_tag 'Seal', @omnikassa_request.seal %>
|
42
|
+
<%= submit_tag 'Naar betaling' %>
|
43
|
+
<% end %>
|
44
|
+
```
|
45
|
+
|
46
|
+
Als de user heeft betaald, dan wordt hij geredirect naar `payment_return_url`.
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
# controllers/payment_controller.rb
|
50
|
+
def payment_return
|
51
|
+
@response = Omnikassa::Response.new(params)
|
52
|
+
if response.success?
|
53
|
+
render :success
|
54
|
+
else
|
55
|
+
render :error
|
56
|
+
end
|
57
|
+
end
|
58
|
+
```
|
59
|
+
|
60
|
+
Maar die redirect is niet gegarandeerd, dus je doet de afhandeling van de betaling in de callback.
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
# controllers/payment_controller.rb
|
64
|
+
def payment_response
|
65
|
+
response = Omnikassa::Response.new(params)
|
66
|
+
if response.success?
|
67
|
+
# sla de betaling op in de database
|
68
|
+
else
|
69
|
+
# doe iets anders
|
70
|
+
end
|
71
|
+
end
|
72
|
+
```
|
73
|
+
|
74
|
+
## Specs
|
75
|
+
|
76
|
+
Om je eigen applicatie te testen is er `Omnikassa::Mocks`. Hier vind je POST-data zoals die door Rabo worden gestuurd bij een transactie. Dit zorgt ervoor dat je niet handmatig alle responses van Rabobank hoeft te testen.
|
77
|
+
|
78
|
+
**iDEAL betaling**
|
79
|
+
|
80
|
+
- `ideal_ok`: Betaling gelukt
|
81
|
+
- `ideal_cancelled`: Betaling is afgebroken door de gebruiker
|
82
|
+
- `ideal_verlopen`: Betaling is verlopen
|
83
|
+
- `ideal_geopend`: Geen idee.
|
84
|
+
- `ideal_error`: technische fout bij Rabo.
|
85
|
+
|
86
|
+
Todo: Minitix, Card, etc.
|
87
|
+
|
88
|
+
Je kan zoiets doen in rspec:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
describe CheckoutController do
|
92
|
+
it 'can handle a response from rabo' do
|
93
|
+
post :return_payment, Omnikassa::Mock.ideal_ok
|
94
|
+
assigns(:payment).status.should equal 'paid'
|
95
|
+
end
|
96
|
+
end
|
97
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module Omnikassa
|
2
|
+
|
3
|
+
CURRENCY_CODES = {
|
4
|
+
'978' => 'euro'
|
5
|
+
}
|
6
|
+
|
7
|
+
PAYMENT_MEAN_BRANDS = %W{IDEAL VISA MASTERCARD MAESTRO MINITIX INCASSO ACCEPTGIRO REMBOURS}
|
8
|
+
|
9
|
+
PAYMENT_MEAN_TYPES = %W{CREDIT_TRANSFER CARD OTHER}
|
10
|
+
|
11
|
+
# Response code van pagina 25-27.
|
12
|
+
RESPONSE_CODES = {
|
13
|
+
'00' => 'Transaction success, authorization accepted.',
|
14
|
+
'02' => 'Please call the bank because the authorization limit on the card has been exceeded.',
|
15
|
+
'03' => 'Invalid merchant contract',
|
16
|
+
'05' => 'Do not honor, authorization refused',
|
17
|
+
'12' => 'Invalid transaction, check the parameters sent in the request',
|
18
|
+
'14' => 'Invalid card number or invalid Card Security Code or Card (for MasterCard) or invalid Card Verification Value (for Visa/Maestro)',
|
19
|
+
'17' => 'Cancellation of payment by the end user',
|
20
|
+
'24' => 'Invalid status',
|
21
|
+
'25' => 'Transaction not found in database',
|
22
|
+
'30' => 'Invalid format',
|
23
|
+
'34' => 'Fraud suspicion',
|
24
|
+
'40' => 'Operation not allowed to this Merchant',
|
25
|
+
'60' => 'Pending transaction',
|
26
|
+
'63' => 'Security breach detected, transaction stopped',
|
27
|
+
'75' => 'The number of attempts to enter the card number has been exceeded (three tries exhausted)',
|
28
|
+
'90' => 'Acquirer server temporarily unavailable',
|
29
|
+
'94' => 'Duplicate transaction',
|
30
|
+
'97' => 'Request time-out; transaction refused',
|
31
|
+
'99' => 'Payment page temporarily unavailable'
|
32
|
+
}
|
33
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Omnikassa
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :merchant_id, :secret_key, :key_version,
|
4
|
+
:currency_code, :rabobank_url, :language, :payment_methods,
|
5
|
+
:environment
|
6
|
+
|
7
|
+
def initialize(args)
|
8
|
+
args.each do |k,v|
|
9
|
+
self.send("#{k}=", v)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Omnikassa
|
2
|
+
class Data
|
3
|
+
def self.serialize(hash)
|
4
|
+
hash.map { |k,v| "#{k}=#{v}"}.join('|')
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.unserialize(string)
|
8
|
+
string.split("|").reduce({}) do |hash, key_value|
|
9
|
+
k, v = key_value.split "="
|
10
|
+
hash[k.to_sym] = v
|
11
|
+
hash
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Omnikassa
|
2
|
+
|
3
|
+
# MockResponse.success(:ideal, { amount: 120 })
|
4
|
+
# MockResponse.success(:ideal, { amount: 120 })
|
5
|
+
|
6
|
+
class MockResponse
|
7
|
+
|
8
|
+
DEFAULTS = { amount: '1234',
|
9
|
+
captureDay: '0',
|
10
|
+
captureMode: 'AUTHOR_CAPTURE',
|
11
|
+
currencyCode: '978',
|
12
|
+
merchantId: '002020000000001',
|
13
|
+
orderId: "null",
|
14
|
+
transactionDateTime: "2012-05-05T15:20:25+02:00",
|
15
|
+
transactionReference: "12312322",
|
16
|
+
keyVersion: "1"
|
17
|
+
}
|
18
|
+
|
19
|
+
SUCCESS = { ideal: {
|
20
|
+
authorisationId: "0020000006791167",
|
21
|
+
paymentMeanBrand: "IDEAL",
|
22
|
+
paymentMeanType: "CREDIT_TRANSFER",
|
23
|
+
responseCode: '00'
|
24
|
+
},
|
25
|
+
mastercard: {
|
26
|
+
authorisationId: '020704',
|
27
|
+
complementaryCode: '99',
|
28
|
+
maskedPan: '5209##########69',
|
29
|
+
paymentMeanBrand: 'MASTERCARD',
|
30
|
+
paymentMeanType: 'CARD',
|
31
|
+
responseCode: '00'
|
32
|
+
},
|
33
|
+
visa: {
|
34
|
+
authorisationId: '930730',
|
35
|
+
complementaryCode: '00',
|
36
|
+
maskedPan: '4563##########99',
|
37
|
+
paymentMeanBrand: 'VISA',
|
38
|
+
paymentMeanType: 'CARD',
|
39
|
+
responseCode: '00'
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
FAILURE = {
|
45
|
+
ideal: {
|
46
|
+
},
|
47
|
+
cancelled: {
|
48
|
+
authorisationId: '0020000529634199',
|
49
|
+
complementaryCode: '',
|
50
|
+
maskedPan: '',
|
51
|
+
paymentMeanBrand: 'IDEAL',
|
52
|
+
paymentMeanType: 'CREDIT_TRANSFER',
|
53
|
+
responseCode: '17',
|
54
|
+
},
|
55
|
+
mastercard: {
|
56
|
+
complementaryCode: '02',
|
57
|
+
maskedPan: '5475##########35',
|
58
|
+
paymentMeanBrand: 'MASTERCARD',
|
59
|
+
paymentMeanType: 'CARD',
|
60
|
+
},
|
61
|
+
|
62
|
+
do_not_honor: {
|
63
|
+
authorisationId: '',
|
64
|
+
responseCode: '05'
|
65
|
+
},
|
66
|
+
|
67
|
+
time_out: {
|
68
|
+
responseCode: '97'
|
69
|
+
}
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
# .success(:ideal | :mastercard)
|
74
|
+
def self.success(provider, args = {})
|
75
|
+
generate DEFAULTS.merge(SUCCESS[provider]).merge(args)
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.failure(provider, reason, args = {} )
|
79
|
+
generate DEFAULTS.merge(FAILURE[provider]).merge(FAILURE[reason]).merge(args)
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
def self.generate(args)
|
85
|
+
data = Data.serialize(args)
|
86
|
+
seal = Omnikassa::sign(data)
|
87
|
+
{ 'Data' => data, 'Seal' => seal, 'InterfaceVersion' => 'HP_1.0' }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module Omnikassa
|
2
|
+
class Request
|
3
|
+
|
4
|
+
attr_accessor :amount, :return_url, :response_url, :reference, :language
|
5
|
+
|
6
|
+
# request = Omnikassa::Request.new(
|
7
|
+
# amount: 1234, # bedrag in centen
|
8
|
+
# return_url: payment_return_url(), # de URL waar de user naartoe gaat na betaling
|
9
|
+
# response_url: payment_response_url(), # URL waar Rabo naar POST na een betaling
|
10
|
+
# reference: 1223123123 # Een unieke identifier voor je transactie
|
11
|
+
# )
|
12
|
+
def initialize(args)
|
13
|
+
args.each do |key, value|
|
14
|
+
self.send "#{key}=", value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def url
|
19
|
+
if Omnikassa.configuration.environment == :production
|
20
|
+
'https://payment-webinit.omnikassa.rabobank.nl/paymentServlet'
|
21
|
+
else
|
22
|
+
'https://payment-webinit.simu.omnikassa.rabobank.nl/paymentServlet'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Turn a has into a string like bla=bla|trala=trala
|
27
|
+
def data_string
|
28
|
+
Data.serialize(data)
|
29
|
+
end
|
30
|
+
|
31
|
+
def seal
|
32
|
+
Omnikassa::seal(seal_seed)
|
33
|
+
end
|
34
|
+
|
35
|
+
def interface_version
|
36
|
+
'HP_1.0'
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def seal_seed
|
42
|
+
data_string + Omnikassa.configuration.secret_key
|
43
|
+
end
|
44
|
+
|
45
|
+
# The Data component
|
46
|
+
def data
|
47
|
+
{
|
48
|
+
# Geef de valuta van de transactie aan.
|
49
|
+
# Betreft een numerieke code van 3 tekens. Zie bijlage § 9.3.
|
50
|
+
currencyCode: Omnikassa.configuration.currency_code,
|
51
|
+
|
52
|
+
# ID (Identificatie‐gegeven) van de webwinkel
|
53
|
+
merchantId: Omnikassa.configuration.merchant_id,
|
54
|
+
|
55
|
+
# URL waarnaar de klant teruggeleid moet worden nadat de transactie afgerond is (URL voor handmatige respons).
|
56
|
+
# Lengte is beperkt tot 512 tekens. LET OP! De URL mag geen parameters bevatten.
|
57
|
+
normalReturnUrl: return_url,
|
58
|
+
|
59
|
+
# URL waar Rabo naar toe POST na een betaling.
|
60
|
+
automaticResponseUrl: response_url,
|
61
|
+
|
62
|
+
# Bedrag van de transactie zonder decimaal scheidingsteken (bijv. 106,55 -> 10655).
|
63
|
+
# Zie bijlage §9.3. Numerieke reeks, beperkt tot 12 tekens (maximaal bedrag is 999999999999)
|
64
|
+
amount: amount,
|
65
|
+
|
66
|
+
# De lijst van betaalwijzes.
|
67
|
+
# Geldig: ideal, minitix, visa, mastercard, maestro, incasso, acceptgiro, rembours
|
68
|
+
paymentMeanBrandList: payment_methods,
|
69
|
+
|
70
|
+
# Referentie van de Rabo OmniKassa‐transactie die uniek moet zijn voor elke ondernemer.
|
71
|
+
# Alfanumerieke reeks, beperkt tot 35 tekens.
|
72
|
+
transactionReference: reference,
|
73
|
+
|
74
|
+
# Versie van de te gebruiken geheime sleutel (secretKey)
|
75
|
+
# die door aan de ondernemer geleverd/bekend gemaakt wordt.
|
76
|
+
keyVersion: Omnikassa.configuration.key_version,
|
77
|
+
|
78
|
+
# Taal van het betaalscherm (nl of en)
|
79
|
+
customerLanguage: language || Omnikassa.configuration.language
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
def payment_methods
|
84
|
+
(Omnikassa.configuration.payment_methods || default_payment_methods).join(',').upcase
|
85
|
+
end
|
86
|
+
|
87
|
+
def default_payment_methods
|
88
|
+
[:ideal, :minitix, :visa, :mastercard, :maestro]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Omnikassa
|
2
|
+
class Response
|
3
|
+
|
4
|
+
attr_accessor :data, :raw_data, :seal
|
5
|
+
|
6
|
+
def initialize(params)
|
7
|
+
self.data = Data.unserialize(params['Data'])
|
8
|
+
self.raw_data = params['Data']
|
9
|
+
self.seal = params['Seal']
|
10
|
+
end
|
11
|
+
|
12
|
+
# Check of de response een geldige seal heeft
|
13
|
+
def legit?
|
14
|
+
Omnikassa::seal(raw_data + Omnikassa.configuration.secret_key) === seal
|
15
|
+
end
|
16
|
+
|
17
|
+
def success?
|
18
|
+
response_code === '00' && legit?
|
19
|
+
end
|
20
|
+
|
21
|
+
# Valuta
|
22
|
+
def currency
|
23
|
+
Omnikassa::CURRENCY_CODES[data[:currencyCode]]
|
24
|
+
end
|
25
|
+
|
26
|
+
# De merchant ID.
|
27
|
+
def merchant_id
|
28
|
+
data[:merchantId]
|
29
|
+
end
|
30
|
+
|
31
|
+
# Bedrag van de transactie in centen
|
32
|
+
def amount
|
33
|
+
data[:amount]
|
34
|
+
end
|
35
|
+
|
36
|
+
def reference
|
37
|
+
data[:transactionReference]
|
38
|
+
end
|
39
|
+
|
40
|
+
def response_code
|
41
|
+
data[:responseCode]
|
42
|
+
end
|
43
|
+
|
44
|
+
def response
|
45
|
+
Omnikassa::RESPONSE_CODES[response_code]
|
46
|
+
end
|
47
|
+
|
48
|
+
# Niet duidelijk wat dit is.
|
49
|
+
def authorization_id
|
50
|
+
data[:authorisationId]
|
51
|
+
end
|
52
|
+
|
53
|
+
# CREDIT_TRANSFER, CARD, OTHER
|
54
|
+
def payment_type
|
55
|
+
data[:paymentMeanType]
|
56
|
+
end
|
57
|
+
|
58
|
+
# IDEAL, VISA, MASTERCARD, MAESTRO, MINITIX, INCASSO, ACCEPTGIRO, REMBOURS
|
59
|
+
def payment_service
|
60
|
+
data[:paymentMeanBrand]
|
61
|
+
end
|
62
|
+
|
63
|
+
# Nog niet beschikbaar: keyVersion, orderId, complementaryCode, maskedPan
|
64
|
+
end
|
65
|
+
end
|
data/lib/omnikassa.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'omnikassa/request'
|
2
|
+
require 'omnikassa/response'
|
3
|
+
require 'omnikassa/configuration'
|
4
|
+
require 'omnikassa/codes'
|
5
|
+
require 'omnikassa/mock_response'
|
6
|
+
require 'omnikassa/seal'
|
7
|
+
require 'omnikassa/data'
|
8
|
+
require 'digest'
|
9
|
+
|
10
|
+
module Omnikassa
|
11
|
+
attr_writer :configuration
|
12
|
+
|
13
|
+
def self.configure
|
14
|
+
yield(configuration)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.configuration
|
18
|
+
@configuration ||= Configuration.new(
|
19
|
+
key_version: 1,
|
20
|
+
currency_code: 978, # EURO
|
21
|
+
language: 'nl',
|
22
|
+
environment: :test,
|
23
|
+
payment_methods: [:ideal, :minitix, :visa, :mastercard, :maestro, :incasso, :acceptgiro, :rembours]
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
data/omnikassa.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omnikassa/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Tijmen"]
|
6
|
+
gem.email = ["tijmen@gmail.com"]
|
7
|
+
gem.description = %q{Gem for Omnikassa}
|
8
|
+
gem.summary = %q{Gem for Omnikassa}
|
9
|
+
gem.homepage = "https://github.com/tijmenb/omnikassa"
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "omnikassa"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Omnikassa::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency "rspec"
|
19
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Omnikassa::Data do
|
4
|
+
|
5
|
+
describe '.serialize' do
|
6
|
+
it 'turns a hash into a rabo string' do
|
7
|
+
serialized = Omnikassa::Data.serialize(a: 'b', c: 'd')
|
8
|
+
serialized.should eq 'a=b|c=d'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ".unserialize" do
|
13
|
+
let(:data_string) { 'amount=1234|captureDay=0|captureMode=AUTHOR_CAPTURE|' +
|
14
|
+
'currencyCode=978|merchantId=002020000000001|orderId=null|' +
|
15
|
+
'transactionDateTime=2012-05-04T15:52:56+02:00|' +
|
16
|
+
'transactionReference=23233|keyVersion=1|authorisationId=0020000006791167|' +
|
17
|
+
'paymentMeanBrand=IDEAL|paymentMeanType=CREDIT_TRANSFER|responseCode=00' }
|
18
|
+
|
19
|
+
let(:unserialized) { Omnikassa::Data.unserialize(data_string) }
|
20
|
+
|
21
|
+
it 'returns a hash' do
|
22
|
+
unserialized.should be_a(Hash)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns the correct values' do
|
26
|
+
unserialized[:amount].should eq '1234'
|
27
|
+
unserialized[:captureDay].should eq '0'
|
28
|
+
unserialized[:transactionReference].should eq '23233'
|
29
|
+
unserialized[:authorisationId].should eq '0020000006791167'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Omnikassa::MockResponse do
|
4
|
+
describe '.generate' do
|
5
|
+
|
6
|
+
it 'generates without error' do
|
7
|
+
Omnikassa::MockResponse.success(:ideal)
|
8
|
+
Omnikassa::MockResponse.success(:mastercard)
|
9
|
+
Omnikassa::MockResponse.success(:visa)
|
10
|
+
|
11
|
+
Omnikassa::MockResponse.failure(:mastercard, :time_out)
|
12
|
+
Omnikassa::MockResponse.failure(:mastercard, :do_not_honor)
|
13
|
+
Omnikassa::MockResponse.failure(:ideal, :cancelled)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Omnikassa::Request do
|
4
|
+
|
5
|
+
describe 'normal request' do
|
6
|
+
let(:request) {
|
7
|
+
Omnikassa::Request.new(
|
8
|
+
amount: 1234,
|
9
|
+
return_url: 'RETURN',
|
10
|
+
response_url: 'RESPONSE',
|
11
|
+
reference: 1223123123
|
12
|
+
)
|
13
|
+
}
|
14
|
+
|
15
|
+
it 'stringifies the data' do
|
16
|
+
request.data_string.should eq "currencyCode=978|merchantId=002020000000001|normalReturnUrl=RETURN|automaticResponseUrl=RESPONSE|amount=1234|paymentMeanBrandList=IDEAL,MINITIX,VISA,MASTERCARD,MAESTRO,INCASSO,ACCEPTGIRO,REMBOURS|transactionReference=1223123123|keyVersion=1|customerLanguage=nl"
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'seals' do
|
20
|
+
request.seal.should eq "ad830c9c402a22a63d07b92973b0e5cbd9abc28d3d5b4ea6798e58effd848818"
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'has interface' do
|
24
|
+
request.interface_version.should eq "HP_1.0"
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns the URL for prod if environment is production' do
|
28
|
+
Omnikassa.configuration.environment = :production
|
29
|
+
request.url.should eq "https://payment-webinit.omnikassa.rabobank.nl/paymentServlet"
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'returns the URL for test if environment is test' do
|
33
|
+
Omnikassa.configuration.environment = :test
|
34
|
+
request.url.should eq "https://payment-webinit.simu.omnikassa.rabobank.nl/paymentServlet"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'overriding language' do
|
39
|
+
it 'uses the provided language' do
|
40
|
+
request = Omnikassa::Request.new(amount: 1234, return_url: 'RETURN', response_url: 'RESPONSE', reference: 1223123123, language: 'en' )
|
41
|
+
request.data_string.should eq "currencyCode=978|merchantId=002020000000001|normalReturnUrl=RETURN|automaticResponseUrl=RESPONSE|amount=1234|paymentMeanBrandList=IDEAL,MINITIX,VISA,MASTERCARD,MAESTRO,INCASSO,ACCEPTGIRO,REMBOURS|transactionReference=1223123123|keyVersion=1|customerLanguage=en"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Omnikassa::Response do
|
4
|
+
|
5
|
+
let(:fake_response) { Omnikassa::MockResponse.success(:ideal, transactionReference: 1111) }
|
6
|
+
|
7
|
+
describe '.legit?' do
|
8
|
+
it 'can read a request object and validate it against the seal' do
|
9
|
+
resp = Omnikassa::Response.new(fake_response)
|
10
|
+
resp.legit?.should be true
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'can read a request object and know its not valid' do
|
14
|
+
invalid = fake_response
|
15
|
+
invalid['Seal'] = '2398462'
|
16
|
+
resp = Omnikassa::Response.new(invalid)
|
17
|
+
resp.legit?.should be false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'convenience methods' do
|
22
|
+
it 'has the right values' do
|
23
|
+
resp = Omnikassa::Response.new(fake_response)
|
24
|
+
|
25
|
+
resp.reference.should eq '1111'
|
26
|
+
resp.amount.should eq '1234'
|
27
|
+
resp.currency.should eq 'euro'
|
28
|
+
resp.merchant_id.should eq '002020000000001'
|
29
|
+
resp.response_code.should eq '00'
|
30
|
+
resp.response.should eq 'Transaction success, authorization accepted.'
|
31
|
+
|
32
|
+
# Normale iDeal betaling
|
33
|
+
resp.authorization_id.should eq '0020000006791167'
|
34
|
+
resp.payment_type.should eq 'CREDIT_TRANSFER'
|
35
|
+
resp.payment_service.should eq 'IDEAL'
|
36
|
+
|
37
|
+
# Gelukt?
|
38
|
+
resp.success?.should eq true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '.success' do
|
43
|
+
it 'technical error' do
|
44
|
+
resp = Omnikassa::Response.new(Omnikassa::MockResponse.failure(:ideal, :time_out))
|
45
|
+
resp.success?.should be false
|
46
|
+
resp.response.should eq 'Request time-out; transaction refused'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'omnikassa'
|
2
|
+
|
3
|
+
Omnikassa.configure do |config|
|
4
|
+
config.merchant_id = '002020000000001'
|
5
|
+
config.secret_key = '002020000000001_KEY1'
|
6
|
+
config.key_version = 1
|
7
|
+
config.currency_code = 978
|
8
|
+
config.rabobank_url = 'https://payment-webinit.simu.omnikassa.rabobank.nl/paymentServlet'
|
9
|
+
config.language = 'nl'
|
10
|
+
config.payment_methods = [:ideal, :minitix, :visa, :mastercard, :maestro, :incasso, :acceptgiro, :rembours]
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omnikassa
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.alpha
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tijmen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-05-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Gem for Omnikassa
|
28
|
+
email:
|
29
|
+
- tijmen@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- .rspec
|
36
|
+
- .travis.yml
|
37
|
+
- Gemfile
|
38
|
+
- LICENSE
|
39
|
+
- README.md
|
40
|
+
- Rakefile
|
41
|
+
- lib/omnikassa.rb
|
42
|
+
- lib/omnikassa/codes.rb
|
43
|
+
- lib/omnikassa/configuration.rb
|
44
|
+
- lib/omnikassa/data.rb
|
45
|
+
- lib/omnikassa/mock_response.rb
|
46
|
+
- lib/omnikassa/request.rb
|
47
|
+
- lib/omnikassa/response.rb
|
48
|
+
- lib/omnikassa/seal.rb
|
49
|
+
- lib/omnikassa/version.rb
|
50
|
+
- omnikassa.gemspec
|
51
|
+
- spec/lib/data_spec.rb
|
52
|
+
- spec/lib/mock_response_spec.rb
|
53
|
+
- spec/lib/request_spec.rb
|
54
|
+
- spec/lib/response_spec.rb
|
55
|
+
- spec/spec_helper.rb
|
56
|
+
homepage: https://github.com/tijmenb/omnikassa
|
57
|
+
licenses: []
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - '>'
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.3.1
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.0.0
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: Gem for Omnikassa
|
79
|
+
test_files:
|
80
|
+
- spec/lib/data_spec.rb
|
81
|
+
- spec/lib/mock_response_spec.rb
|
82
|
+
- spec/lib/request_spec.rb
|
83
|
+
- spec/lib/response_spec.rb
|
84
|
+
- spec/spec_helper.rb
|
85
|
+
has_rdoc:
|