da_funk 2.7.1 → 3.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6fddf16bc4de572c488ed6a63ee95be2cc7a6c2c
4
- data.tar.gz: 4af041d42ac40533c44842a69713a905715f361c
3
+ metadata.gz: 14a0759211adad87f8e8ef78f3acbe61201e8d68
4
+ data.tar.gz: 3f421864672af60122049e7e194303faa57d86ab
5
5
  SHA512:
6
- metadata.gz: e6cd002c845d3b056d0fa132dd031ee5f68aac6f5f57e8b90c9b35540b168221b783de4bd367725352b38d00e3d48e0fd00b789ea4c770316f63ad08732ebc11
7
- data.tar.gz: 90747a7835876b2abde831d3c81592f97ddcb2b8be89b18ef78311fd1fb220f228b2fed22ad3abdcd3965dd550fd7cfcefd9f525fcc0511830326619a4717e14
6
+ metadata.gz: bbd0ea30478678f50460cde1ded710d66e2bbd3a1216a155268659534a6907493828319a0d435ca16e9937f1f76d52c3716ecdb6cb42d660009406297c661d20
7
+ data.tar.gz: f15f8b1226a9ce6c2445fb564c4ef3ad2e16e3f26c5711d9c734c55ea8c76f57c2df86c772d776fb08ce22d1af3618f31b16a72c7e1f13fb0977db25c90f42ab
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- da_funk (2.7.1)
4
+ da_funk (3.0.0)
5
5
  archive-zip (~> 0.5)
6
6
  bundler
7
7
  cloudwalk_handshake
data/RELEASE_NOTES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # DaFunk
2
2
 
3
+ ### 3.0.0 - 2019-02-28
4
+
5
+ - Replace payment channel interface from WebSocket to HTTP;
6
+ - Support config.dat parameters `transaction_http_enabled`, `transaction_http_host`, `transaction_http_port`.
7
+
3
8
  ### 2.7.1 - 2019-02-16
4
9
 
5
10
  - Bug fix set payment channel limit disable as default.
@@ -64,7 +64,12 @@ module DaFunk
64
64
  end
65
65
  end
66
66
 
67
+ def self.transaction_http?
68
+ DaFunk::ParamsDat.exists? && DaFunk::ParamsDat.file["transaction_http_enabled"] != "0"
69
+ end
70
+
67
71
  def self.channel_limit_exceed?
72
+ return true if transaction_http?
68
73
  if payment_channel_limit?
69
74
  payment_channel_limit <= Device::Setting.payment_channel_attempts.to_i
70
75
  else
@@ -73,7 +78,7 @@ module DaFunk
73
78
  end
74
79
 
75
80
  def self.check(display_message = true)
76
- if self.dead?
81
+ if self.dead?
77
82
  unless self.channel_limit_exceed?
78
83
  PaymentChannel.connect(display_message)
79
84
  if @client
@@ -144,7 +149,8 @@ module DaFunk
144
149
  def initialize(client = nil)
145
150
  @host = Device::Setting.host
146
151
  @port = (Device::Setting.apn == "gprsnac.com.br") ? 32304 : 443
147
- @client = client || CwWebSocket::Client.new(@host, @port)
152
+ @client = client || CwHttpSocket.new(Device::Setting.transaction_http_host,
153
+ Device::Setting.transaction_http_port)
148
154
  rescue SocketError, PolarSSL::SSL::Error => e
149
155
  self.error(e)
150
156
  end
@@ -172,14 +178,18 @@ module DaFunk
172
178
  end
173
179
 
174
180
  def handshake?
175
- if self.connected? && ! @handshake_response
176
- timeout = Time.now + Device::Setting.tcp_recv_timeout.to_i
177
- loop do
178
- break if @handshake_response = self.client.read
179
- break if Time.now > timeout || getc(200) == Device::IO::CANCEL
181
+ if self.client.respond_to?(:handshake?)
182
+ self.client.handshake?
183
+ else
184
+ if self.connected? && ! @handshake_response
185
+ timeout = Time.now + Device::Setting.tcp_recv_timeout.to_i
186
+ loop do
187
+ break if @handshake_response = self.client.read
188
+ break if Time.now > timeout || getc(200) == Device::IO::CANCEL
189
+ end
180
190
  end
191
+ !! @handshake_response
181
192
  end
182
- !! @handshake_response
183
193
  end
184
194
 
185
195
  def check
@@ -203,7 +213,11 @@ module DaFunk
203
213
 
204
214
  def handshake
205
215
  if self.connected?
206
- @client.write(PaymentChannel.handshake_message)
216
+ if self.handshake?
217
+ true
218
+ else
219
+ @client.write(PaymentChannel.handshake_message)
220
+ end
207
221
  end
208
222
  end
209
223
  end
@@ -1,4 +1,4 @@
1
1
  module DaFunk
2
- VERSION="2.7.1"
2
+ VERSION="3.0.0"
3
3
  end
4
4
 
@@ -2,10 +2,13 @@
2
2
  class Device
3
3
  class Setting
4
4
  FILE_PATH = "./main/config.dat"
5
- HOST_PRODUCTION = "switch.cloudwalk.io"
6
- HOST_STAGING = "switch-staging.cloudwalk.io"
7
- PORT_TCP = "31415"
8
- PORT_TCP_SSL = "31416"
5
+ HOST_PRODUCTION = "switch.cloudwalk.io"
6
+ HOST_STAGING = "switch-staging.cloudwalk.io"
7
+ HTTP_HOST_PRODUCTION = "switch-http.cloudwalk.io"
8
+ HTTP_HOST_STAGING = "switch-http-staging.cloudwalk.io"
9
+ HTTP_PORT = "443"
10
+ PORT_TCP = "31415"
11
+ PORT_TCP_SSL = "31416"
9
12
 
10
13
  DEFAULT = {
11
14
  "host" => HOST_PRODUCTION,
@@ -56,7 +59,10 @@ class Device
56
59
  "company_name" => "", #SYS
57
60
  "metadata_timestamp" => "",
58
61
  "payment_channel_attempts" => "0",
59
- "payment_channel_date" => ""
62
+ "payment_channel_date" => "",
63
+ "transaction_http_enabled" => "1",
64
+ "transaction_http_host" => HTTP_HOST_PRODUCTION,
65
+ "transaction_http_port" => HTTP_PORT
60
66
  }
61
67
 
62
68
  class << self
@@ -92,7 +98,7 @@ class Device
92
98
 
93
99
  def self.to_production!
94
100
  if self.environment != "production"
95
- @file.update_attributes("company_name" => "", "environment" => "production", "host" => HOST_PRODUCTION)
101
+ @file.update_attributes("company_name" => "", "environment" => "production", "host" => HOST_PRODUCTION, "transaction_http_host" => HTTP_HOST_PRODUCTION)
96
102
  return true
97
103
  end
98
104
  false
@@ -100,7 +106,7 @@ class Device
100
106
 
101
107
  def self.to_staging!
102
108
  if self.environment != "staging"
103
- @file.update_attributes("company_name" => "", "environment" => "staging", "host" => HOST_STAGING)
109
+ @file.update_attributes("company_name" => "", "environment" => "staging", "host" => HOST_STAGING, "transaction_http_host" => HTTP_HOST_STAGING)
104
110
  return true
105
111
  end
106
112
  false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: da_funk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thiago Scalone
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-16 00:00:00.000000000 Z
11
+ date: 2019-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake