smartkiosk-server 0.10.3 → 0.10.4
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.
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/app/acquirers/cards_mkb_acquirer.rb +67 -44
- data/app/acquirers/cash_acquirer.rb +19 -7
- data/app/models/.terminal_ping.rb.kate-swp +0 -0
- data/app/models/.terminal_profile.rb.kate-swp +0 -0
- data/app/models/payment.rb +26 -16
- data/db/migrate/20120825083305_create_payments.rb +1 -0
- data/db/schema.rb +2 -0
- data/lib/smartkiosk/server/version.rb +1 -1
- data/smartkiosk-server.gemspec +2 -2
- metadata +22 -8
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -169,7 +169,7 @@ GEM
|
|
169
169
|
has_scope (~> 0.5.0)
|
170
170
|
responders (~> 0.6)
|
171
171
|
iso8583 (0.1.4)
|
172
|
-
iso8583-mkb (0.0.
|
172
|
+
iso8583-mkb (0.0.2)
|
173
173
|
eventmachine
|
174
174
|
iso8583
|
175
175
|
jdbc-postgres (9.2.1002)
|
@@ -397,7 +397,7 @@ DEPENDENCIES
|
|
397
397
|
guard-spork!
|
398
398
|
haml
|
399
399
|
i18n_yaml_sorter
|
400
|
-
iso8583-mkb (= 0.0.
|
400
|
+
iso8583-mkb (= 0.0.2)
|
401
401
|
jquery-rails
|
402
402
|
jruby-openssl
|
403
403
|
liquid
|
@@ -19,29 +19,81 @@ class CardsMkbAcquirer
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
class
|
23
|
-
|
24
|
-
|
22
|
+
class Transaction
|
23
|
+
attr_reader :error
|
24
|
+
|
25
|
+
def initialize(payment, config)
|
26
|
+
@payment = payment
|
27
|
+
@auth = nil
|
28
|
+
@config = config
|
29
|
+
@transaction = nil
|
30
|
+
@error = nil
|
31
|
+
@auth = nil
|
25
32
|
end
|
26
33
|
|
27
|
-
def
|
28
|
-
@
|
34
|
+
def id
|
35
|
+
@transaction.id
|
29
36
|
end
|
30
37
|
|
31
|
-
def
|
32
|
-
|
38
|
+
def transact(&block)
|
39
|
+
CardsMkbAcquirer.gateway.transaction do |transaction|
|
40
|
+
@transaction = transaction
|
41
|
+
begin
|
42
|
+
yield self
|
43
|
+
ensure
|
44
|
+
@transaction = nil
|
45
|
+
end
|
46
|
+
end
|
33
47
|
end
|
34
48
|
|
35
|
-
def
|
49
|
+
def authorize
|
50
|
+
auth = ISO8583::MKB::Authorization.new(@transaction)
|
51
|
+
auth.processing_code = @config[:processing_code]
|
52
|
+
auth.merchant_type = @config[:merchant_type]
|
53
|
+
auth.acquirer_country = @config[:acquirer_country]
|
54
|
+
auth.entry_mode = @config[:entry_mode]
|
55
|
+
auth.condition_code = @config[:condition_code]
|
56
|
+
auth.acquirer = @config[:acquirer]
|
57
|
+
auth.terminal_id = @config[:terminal_id]
|
58
|
+
auth.acceptor_id = @config[:acceptor_id]
|
59
|
+
|
60
|
+
auth.track2 = @payment.card_track2
|
61
|
+
|
62
|
+
delimiter = auth.track2.index '='
|
63
|
+
auth.pan = auth.track2.slice(0, delimiter)
|
64
|
+
auth.expiry = auth.track2.slice(delimiter + 1, 4)
|
65
|
+
|
66
|
+
terminal = "OOOMKB TERM#{@payment.terminal.keyword}"
|
67
|
+
city = "Moscow"
|
68
|
+
country = "RU"
|
36
69
|
|
70
|
+
auth.acceptor_name = sprintf("%-25s%-13s%-2s", terminal, city, country)
|
71
|
+
|
72
|
+
# TODO: implement currency handling
|
73
|
+
auth.amount = (@payment.paid_amount * 100).to_i
|
74
|
+
auth.currency = 643
|
75
|
+
|
76
|
+
# TODO: build additional data
|
77
|
+
auth.additional = "USRDT, <cm>#{@payment.commission_amount}</cm>, <ses>#{@payment.session_id}</ses>backend data"
|
78
|
+
|
79
|
+
CardsMkbAcquirer.gateway.execute auth
|
80
|
+
|
81
|
+
@auth = auth
|
82
|
+
@error = auth.status_description
|
83
|
+
|
84
|
+
auth.success?
|
37
85
|
end
|
38
86
|
|
39
87
|
def reverse
|
40
88
|
reversal = @auth.reverse
|
41
|
-
# TODO: set reason code
|
42
|
-
|
43
89
|
CardsMkbAcquirer.gateway.execute reversal
|
44
|
-
|
90
|
+
|
91
|
+
@error = reversal.status_description
|
92
|
+
reversal.success?
|
93
|
+
end
|
94
|
+
|
95
|
+
def confirm
|
96
|
+
true
|
45
97
|
end
|
46
98
|
end
|
47
99
|
|
@@ -50,38 +102,9 @@ class CardsMkbAcquirer
|
|
50
102
|
CardsMkbAcquirer.ensure_running @config
|
51
103
|
end
|
52
104
|
|
53
|
-
def
|
54
|
-
|
55
|
-
|
56
|
-
auth.merchant_type = @config[:merchant_type]
|
57
|
-
auth.acquirer_country = @config[:acquirer_country]
|
58
|
-
auth.entry_mode = @config[:entry_mode]
|
59
|
-
auth.condition_code = @config[:condition_code]
|
60
|
-
auth.acquirer = @config[:acquirer]
|
61
|
-
auth.terminal_id = @config[:terminal_id]
|
62
|
-
auth.acceptor_id = @config[:acceptor_id]
|
63
|
-
|
64
|
-
auth.track2 = payment.card_track2
|
65
|
-
|
66
|
-
delimiter = auth.track2.index '='
|
67
|
-
auth.pan = auth.track2.slice(0, delimiter)
|
68
|
-
auth.expiry = auth.track2.slice(delimiter + 1, 4)
|
69
|
-
|
70
|
-
terminal = "OOOMKB TERM#{payment.terminal.keyword}"
|
71
|
-
city = "Moscow"
|
72
|
-
country = "RU"
|
73
|
-
|
74
|
-
auth.acceptor_name = sprintf("%-25s%-13s%-2s", terminal, city, country)
|
75
|
-
|
76
|
-
# TODO: implement currency handling
|
77
|
-
auth.amount = (payment.paid_amount * 100).to_i
|
78
|
-
auth.currency = 643
|
79
|
-
|
80
|
-
# TODO: build additional data
|
81
|
-
auth.additional = "USRDT, <cm>#{payment.commission_amount}</cm>, <ses>#{payment.session_id}</ses>backend data"
|
82
|
-
|
83
|
-
CardsMkbAcquirer.gateway.execute auth
|
84
|
-
|
85
|
-
Authorization.new auth
|
105
|
+
def transaction(payment, &block)
|
106
|
+
transaction = Transaction.new(payment, @config)
|
107
|
+
transaction.transact(&block)
|
86
108
|
end
|
87
109
|
end
|
110
|
+
|
@@ -1,22 +1,34 @@
|
|
1
1
|
class CashAcquirer
|
2
2
|
def initialize(*args)
|
3
3
|
end
|
4
|
-
|
5
|
-
class
|
6
|
-
def
|
7
|
-
|
4
|
+
|
5
|
+
class Transaction
|
6
|
+
def initialize(payment)
|
7
|
+
@payment = payment
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def id
|
11
|
+
"0"
|
12
|
+
end
|
11
13
|
|
14
|
+
def authorize
|
15
|
+
true
|
12
16
|
end
|
13
17
|
|
14
18
|
def reverse
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
def confirm
|
23
|
+
true
|
24
|
+
end
|
15
25
|
|
26
|
+
def error
|
27
|
+
nil
|
16
28
|
end
|
17
29
|
end
|
18
30
|
|
19
|
-
def
|
20
|
-
|
31
|
+
def transaction(payment, &block)
|
32
|
+
yield Transaction.new(payment)
|
21
33
|
end
|
22
34
|
end
|
Binary file
|
Binary file
|
data/app/models/payment.rb
CHANGED
@@ -291,28 +291,38 @@ class Payment < ActiveRecord::Base
|
|
291
291
|
|
292
292
|
def pay?
|
293
293
|
acquirer = Payment.acquirer(self.payment_type)
|
294
|
-
|
294
|
+
acquirer.transaction(self) do |transaction|
|
295
|
+
self.update_attribute(:acquirer_transaction, transaction.id)
|
295
296
|
|
296
|
-
|
297
|
-
|
297
|
+
if transaction.authorize
|
298
|
+
result = self.gateway.librarize.pay(self)
|
298
299
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
300
|
+
if result[:success]
|
301
|
+
self.gateway_error = nil
|
302
|
+
self.gateway_payment_id = result[:gateway_payment_id] unless result[:gateway_payment_id].blank?
|
303
|
+
self.paid_at = DateTime.now
|
304
|
+
self.meta[:gateway] = self.gateway.serialize_options
|
304
305
|
|
305
|
-
|
306
|
-
|
307
|
-
|
306
|
+
self.save!
|
307
|
+
if !transaction.confirm
|
308
|
+
self.plog :error, :acquirer, "unable to confirm transaction: #{transaction.error}"
|
309
|
+
|
310
|
+
# TODO: reverse on gateway if possible
|
311
|
+
end
|
312
|
+
|
313
|
+
return :paid
|
314
|
+
else
|
315
|
+
self.update_attribute(:gateway_error, result[:error])
|
316
|
+
if !transaction.reverse
|
317
|
+
self.plog :error, :acquirer, "unable to reverse transaction: #{transaction.error}"
|
318
|
+
end
|
319
|
+
|
320
|
+
return :error
|
321
|
+
end
|
308
322
|
else
|
309
|
-
self.update_attribute(:
|
310
|
-
authorization.reverse
|
323
|
+
self.update_attribute(:acquirer_error, transaction.error)
|
311
324
|
return :error
|
312
325
|
end
|
313
|
-
else
|
314
|
-
self.update_attribute(:acquirer_error, authorization.error)
|
315
|
-
return :error
|
316
326
|
end
|
317
327
|
end
|
318
328
|
|
@@ -25,6 +25,7 @@ class CreatePayments < ActiveRecord::Migration
|
|
25
25
|
t.string :state, :null => false, :default => 'new'
|
26
26
|
t.string :acquirer_error
|
27
27
|
t.integer :gateway_error
|
28
|
+
t.string :acquirer_transaction
|
28
29
|
t.string :gateway_provider_id
|
29
30
|
t.string :gateway_payment_id
|
30
31
|
t.datetime :hour
|
data/db/schema.rb
CHANGED
@@ -177,7 +177,9 @@ ActiveRecord::Schema.define(:version => 20130108091644) do
|
|
177
177
|
t.decimal "enrolled_amount", :precision => 38, :scale => 2
|
178
178
|
t.decimal "rebate_amount", :precision => 38, :scale => 2
|
179
179
|
t.string "state", :default => "new", :null => false
|
180
|
+
t.string "acquirer_error"
|
180
181
|
t.integer "gateway_error"
|
182
|
+
t.string "acquirer_transaction"
|
181
183
|
t.string "gateway_provider_id"
|
182
184
|
t.string "gateway_payment_id"
|
183
185
|
t.datetime "hour"
|
data/smartkiosk-server.gemspec
CHANGED
@@ -5,8 +5,8 @@ require 'smartkiosk/server/version'
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = 'smartkiosk-server'
|
7
7
|
gem.version = Smartkiosk::Server::VERSION
|
8
|
-
gem.authors = ['Boris Staal']
|
9
|
-
gem.email = ['boris@roundlake.ru']
|
8
|
+
gem.authors = ['Boris Staal', 'Sergey Gridasov']
|
9
|
+
gem.email = ['boris@roundlake.ru', 'grindars@gmail.com']
|
10
10
|
gem.description = %q{Smartkiosk server application}
|
11
11
|
gem.summary = gem.description
|
12
12
|
gem.homepage = 'https://github.com/smartkiosk/smartkiosk-server'
|
metadata
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smartkiosk-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Boris Staal
|
9
|
+
- Sergey Gridasov
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
@@ -13,18 +14,23 @@ date: 2013-02-06 00:00:00.000000000 Z
|
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: rails
|
16
|
-
requirement:
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
|
-
- - =
|
20
|
+
- - '='
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: 3.2.11
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - '='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 3.2.11
|
25
31
|
- !ruby/object:Gem::Dependency
|
26
32
|
name: matrioshka
|
27
|
-
requirement:
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
28
34
|
none: false
|
29
35
|
requirements:
|
30
36
|
- - ! '>='
|
@@ -32,10 +38,16 @@ dependencies:
|
|
32
38
|
version: 0.1.1
|
33
39
|
type: :runtime
|
34
40
|
prerelease: false
|
35
|
-
version_requirements:
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.1.1
|
36
47
|
description: Smartkiosk server application
|
37
48
|
email:
|
38
49
|
- boris@roundlake.ru
|
50
|
+
- grindars@gmail.com
|
39
51
|
executables: []
|
40
52
|
extensions: []
|
41
53
|
extra_rdoc_files: []
|
@@ -111,6 +123,8 @@ files:
|
|
111
123
|
- app/helpers/application_helper.rb
|
112
124
|
- app/mailers/.gitkeep
|
113
125
|
- app/models/.gitkeep
|
126
|
+
- app/models/.terminal_ping.rb.kate-swp
|
127
|
+
- app/models/.terminal_profile.rb.kate-swp
|
114
128
|
- app/models/ability.rb
|
115
129
|
- app/models/agent.rb
|
116
130
|
- app/models/collection.rb
|
@@ -307,7 +321,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
307
321
|
version: '0'
|
308
322
|
segments:
|
309
323
|
- 0
|
310
|
-
hash:
|
324
|
+
hash: 1639411805563885975
|
311
325
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
312
326
|
none: false
|
313
327
|
requirements:
|
@@ -316,7 +330,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
316
330
|
version: '0'
|
317
331
|
requirements: []
|
318
332
|
rubyforge_project:
|
319
|
-
rubygems_version: 1.8.
|
333
|
+
rubygems_version: 1.8.24
|
320
334
|
signing_key:
|
321
335
|
specification_version: 3
|
322
336
|
summary: Smartkiosk server application
|