suntech_rails 0.0.1 → 0.0.2
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 +4 -4
- data/lib/suntech_rails/core/version.rb +1 -1
- data/lib/suntech_rails/payment/buysafe.rb +17 -0
- data/test/dummy/log/test.log +60 -0
- data/test/lib/suntech_rails/payment/buysafe_test.rb +45 -0
- metadata +1 -2
- data/README.rdoc +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a767288ffbdc0bd6267fc30b51dee4ef68b369b1
|
4
|
+
data.tar.gz: 5a5c25f18ef4cb89e4789ba5d4ee6ea14045a890
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 828c994a579affe8b5ca54b05e9c1047f856c756c5c54f3e9793f6a6a728d9a589a3d1b6d91b0b5f2e3df88bae84887eaffcfcc86821cb3928304a40d680d44b
|
7
|
+
data.tar.gz: b21e837bc770078bedb3a035ee74a8b3a1cb237585b72f4d0c035366e3517097f4aafcd46a21b8ba911e3ec8e4b94891ad0fa1d88bed659bd8ee430877a0eec3
|
@@ -17,6 +17,10 @@ module SuntechRails
|
|
17
17
|
Digest::SHA1.hexdigest("#{@web}#{SuntechRails::Core::Config.config.transaction_code}#{@MN}").upcase
|
18
18
|
end
|
19
19
|
|
20
|
+
def self.check_chkvalue?(params)
|
21
|
+
Digest::SHA1.hexdigest("#{params["web"]}#{SuntechRails::Core::Config.config.transaction_code}#{params["buysafeno"]}#{params["MN"]}#{params["errcode"]}").upcase == params["ChkValue"]
|
22
|
+
end
|
23
|
+
|
20
24
|
def merge!(options, &block)
|
21
25
|
if options.is_a? Hash
|
22
26
|
options.each do |key, value|
|
@@ -41,6 +45,19 @@ module SuntechRails
|
|
41
45
|
raise TypeError, "#{error.message}(#{value.inspect}) for #{self.class.name}.#{key} member"
|
42
46
|
end
|
43
47
|
|
48
|
+
def self.success?(params)
|
49
|
+
params["errcode"] == "00"
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.check(params)
|
53
|
+
|
54
|
+
if SuntechRails::Core::Config.config.buy_safe_id == params["web"] && check_chkvalue?(params)
|
55
|
+
return params
|
56
|
+
else
|
57
|
+
return nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
44
61
|
end
|
45
62
|
end
|
46
63
|
end
|
data/test/dummy/log/test.log
CHANGED
@@ -238,3 +238,63 @@ SuntechRailsHelperTest::buysafe builder: test_0001_build form
|
|
238
238
|
SuntechRailsTest: test_0001_truth
|
239
239
|
---------------------------------
|
240
240
|
[1m[35m (0.1ms)[0m rollback transaction
|
241
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
242
|
+
-------------------------------------------------------------
|
243
|
+
SuntechRailsHelperTest::buysafe builder: test_0001_build form
|
244
|
+
-------------------------------------------------------------
|
245
|
+
[1m[35m (0.4ms)[0m rollback transaction
|
246
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
247
|
+
---------------------------------
|
248
|
+
SuntechRailsTest: test_0001_truth
|
249
|
+
---------------------------------
|
250
|
+
[1m[35m (0.4ms)[0m rollback transaction
|
251
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
252
|
+
----------------------------------------------------------------------------------------
|
253
|
+
SuntechRails::Payment::BuySafe::callback checking: test_0001_should get correct ChkValue
|
254
|
+
----------------------------------------------------------------------------------------
|
255
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
256
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
257
|
+
-------------------------------------------------------------------------------
|
258
|
+
SuntechRails::Payment::BuySafe::callback checking: test_0002_should reture true
|
259
|
+
-------------------------------------------------------------------------------
|
260
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
261
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
262
|
+
-----------------------------------------------------------------------------------
|
263
|
+
SuntechRails::Payment::BuySafe::callback checking: test_0003_should return all hash
|
264
|
+
-----------------------------------------------------------------------------------
|
265
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
266
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
267
|
+
------------------------------------------------------------------------------
|
268
|
+
SuntechRails::Payment::BuySafe::basic operation: test_0001_can new a instanace
|
269
|
+
------------------------------------------------------------------------------
|
270
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
271
|
+
[1m[36m (0.5ms)[0m [1mbegin transaction[0m
|
272
|
+
-------------------------------------------------------------
|
273
|
+
SuntechRailsHelperTest::buysafe builder: test_0001_build form
|
274
|
+
-------------------------------------------------------------
|
275
|
+
[1m[35m (0.4ms)[0m rollback transaction
|
276
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
277
|
+
----------------------------------------------------------------------------------------
|
278
|
+
SuntechRails::Payment::BuySafe::callback checking: test_0001_should get correct ChkValue
|
279
|
+
----------------------------------------------------------------------------------------
|
280
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
281
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
282
|
+
-------------------------------------------------------------------------------
|
283
|
+
SuntechRails::Payment::BuySafe::callback checking: test_0002_should reture true
|
284
|
+
-------------------------------------------------------------------------------
|
285
|
+
[1m[35m (0.2ms)[0m rollback transaction
|
286
|
+
[1m[36m (1.2ms)[0m [1mbegin transaction[0m
|
287
|
+
-----------------------------------------------------------------------------------
|
288
|
+
SuntechRails::Payment::BuySafe::callback checking: test_0003_should return all hash
|
289
|
+
-----------------------------------------------------------------------------------
|
290
|
+
[1m[35m (0.3ms)[0m rollback transaction
|
291
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
292
|
+
---------------------------------
|
293
|
+
SuntechRailsTest: test_0001_truth
|
294
|
+
---------------------------------
|
295
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
296
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
297
|
+
------------------------------------------------------------------------------
|
298
|
+
SuntechRails::Payment::BuySafe::basic operation: test_0001_can new a instanace
|
299
|
+
------------------------------------------------------------------------------
|
300
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
@@ -22,4 +22,49 @@ describe SuntechRails::Payment::BuySafe do
|
|
22
22
|
buysafe_payment.email.must_equal BuySafePaymentAttributes["email"]
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
describe "callback checking" do
|
27
|
+
before do
|
28
|
+
Success = {
|
29
|
+
"buysafeno"=>"N090001601210000024",
|
30
|
+
"web"=>"S1512089010",
|
31
|
+
"MN"=>"100",
|
32
|
+
"Td"=>"1453305918",
|
33
|
+
"webname"=>"%e7%b6%a0%e9%bb%9e%e8%83%bd%e5%89%b5%e8%82%a1%e4%bb%bd%e6%9c%89%e9%99%90%e5%85%ac%e5%8f%b8",
|
34
|
+
"Name"=>"1%e2%97%8b%e2%97%8b%e2%97%8b%e2%97%8b1",
|
35
|
+
"note1"=>"none",
|
36
|
+
"note2"=>"none",
|
37
|
+
"ApproveCode"=>"T0NCCC",
|
38
|
+
"Card_NO"=>"1234",
|
39
|
+
"UserNo"=>"",
|
40
|
+
"BarcodeA"=>"",
|
41
|
+
"BarcodeB"=>"",
|
42
|
+
"BarcodeC"=>"",
|
43
|
+
"PostBarcodeA"=>"",
|
44
|
+
"PostBarcodeB"=>"",
|
45
|
+
"PostBarcodeC"=>"",
|
46
|
+
"EntityATM"=>"",
|
47
|
+
"paycode"=>"",
|
48
|
+
"PayType"=>"",
|
49
|
+
"SendType"=>"2",
|
50
|
+
"errcode"=>"00",
|
51
|
+
"errmsg"=>"%e6%88%90%e5%8a%9f%e4%ba%a4%e6%98%93",
|
52
|
+
"Card_Type"=>"0",
|
53
|
+
"CargoNo"=>"",
|
54
|
+
"ChkValue"=>"014B5457A2864B5A03A65E79430EBFF12855B17A"
|
55
|
+
}
|
56
|
+
end
|
57
|
+
it "should get correct ChkValue" do
|
58
|
+
SuntechRails::Payment::BuySafe.check_chkvalue?(Success).must_equal true
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should reture true" do
|
62
|
+
SuntechRails::Payment::BuySafe.success?(Success).must_equal true
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should return all hash" do
|
66
|
+
SuntechRails::Payment::BuySafe.check(Success).must_equal Success
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
25
70
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: suntech_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aloha
|
@@ -46,7 +46,6 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- MIT-LICENSE
|
49
|
-
- README.rdoc
|
50
49
|
- Rakefile
|
51
50
|
- app/assets/javascripts/suntech_rails/application.js
|
52
51
|
- app/assets/stylesheets/suntech_rails/application.css
|
data/README.rdoc
DELETED