suntech_rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c98ca534f2c7745f05e2a4febd5b6127beaea250
4
- data.tar.gz: d15a69645a6b458a4eec968193cfed7ce958cffc
3
+ metadata.gz: a767288ffbdc0bd6267fc30b51dee4ef68b369b1
4
+ data.tar.gz: 5a5c25f18ef4cb89e4789ba5d4ee6ea14045a890
5
5
  SHA512:
6
- metadata.gz: 965286017002182e4058231134305bb55159df5a7d599ecaae85f9c6a03359a8a49ce7f3aa19f128a327f64fb4f5fbee1ac95bc694ffbd706d63a12bd06e4aa3
7
- data.tar.gz: ff66de88f16726d92f0d55832eb0ffb103f3ab590f6b3e3091b259d91c85e8456ae25bcd3823c05cd9ff64efee784b36f004db04206251eac2e275d126dfae10
6
+ metadata.gz: 828c994a579affe8b5ca54b05e9c1047f856c756c5c54f3e9793f6a6a728d9a589a3d1b6d91b0b5f2e3df88bae84887eaffcfcc86821cb3928304a40d680d44b
7
+ data.tar.gz: b21e837bc770078bedb3a035ee74a8b3a1cb237585b72f4d0c035366e3517097f4aafcd46a21b8ba911e3ec8e4b94891ad0fa1d88bed659bd8ee430877a0eec3
@@ -1,5 +1,5 @@
1
1
  module SuntechRails
2
2
  module Core
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -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
@@ -238,3 +238,63 @@ SuntechRailsHelperTest::buysafe builder: test_0001_build form
238
238
  SuntechRailsTest: test_0001_truth
239
239
  ---------------------------------
240
240
   (0.1ms) rollback transaction
241
+  (0.2ms) begin transaction
242
+ -------------------------------------------------------------
243
+ SuntechRailsHelperTest::buysafe builder: test_0001_build form
244
+ -------------------------------------------------------------
245
+  (0.4ms) rollback transaction
246
+  (0.3ms) begin transaction
247
+ ---------------------------------
248
+ SuntechRailsTest: test_0001_truth
249
+ ---------------------------------
250
+  (0.4ms) rollback transaction
251
+  (0.1ms) begin transaction
252
+ ----------------------------------------------------------------------------------------
253
+ SuntechRails::Payment::BuySafe::callback checking: test_0001_should get correct ChkValue
254
+ ----------------------------------------------------------------------------------------
255
+  (0.1ms) rollback transaction
256
+  (0.2ms) begin transaction
257
+ -------------------------------------------------------------------------------
258
+ SuntechRails::Payment::BuySafe::callback checking: test_0002_should reture true
259
+ -------------------------------------------------------------------------------
260
+  (0.1ms) rollback transaction
261
+  (0.1ms) begin transaction
262
+ -----------------------------------------------------------------------------------
263
+ SuntechRails::Payment::BuySafe::callback checking: test_0003_should return all hash
264
+ -----------------------------------------------------------------------------------
265
+  (0.1ms) rollback transaction
266
+  (0.1ms) begin transaction
267
+ ------------------------------------------------------------------------------
268
+ SuntechRails::Payment::BuySafe::basic operation: test_0001_can new a instanace
269
+ ------------------------------------------------------------------------------
270
+  (0.1ms) rollback transaction
271
+  (0.5ms) begin transaction
272
+ -------------------------------------------------------------
273
+ SuntechRailsHelperTest::buysafe builder: test_0001_build form
274
+ -------------------------------------------------------------
275
+  (0.4ms) rollback transaction
276
+  (0.1ms) begin transaction
277
+ ----------------------------------------------------------------------------------------
278
+ SuntechRails::Payment::BuySafe::callback checking: test_0001_should get correct ChkValue
279
+ ----------------------------------------------------------------------------------------
280
+  (0.1ms) rollback transaction
281
+  (0.1ms) begin transaction
282
+ -------------------------------------------------------------------------------
283
+ SuntechRails::Payment::BuySafe::callback checking: test_0002_should reture true
284
+ -------------------------------------------------------------------------------
285
+  (0.2ms) rollback transaction
286
+  (1.2ms) begin transaction
287
+ -----------------------------------------------------------------------------------
288
+ SuntechRails::Payment::BuySafe::callback checking: test_0003_should return all hash
289
+ -----------------------------------------------------------------------------------
290
+  (0.3ms) rollback transaction
291
+  (0.1ms) begin transaction
292
+ ---------------------------------
293
+ SuntechRailsTest: test_0001_truth
294
+ ---------------------------------
295
+  (0.0ms) rollback transaction
296
+  (0.1ms) begin transaction
297
+ ------------------------------------------------------------------------------
298
+ SuntechRails::Payment::BuySafe::basic operation: test_0001_can new a instanace
299
+ ------------------------------------------------------------------------------
300
+  (0.1ms) 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.1
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
@@ -1,3 +0,0 @@
1
- = SuntechRails
2
-
3
- This project rocks and uses MIT-LICENSE.