umf_pay_service_ruby 1.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.
@@ -0,0 +1,126 @@
1
+ # UmfStringUtil
2
+ # author : zhaoyingxin
3
+ #
4
+
5
+ require 'uri'
6
+
7
+ require 'UmfLogger'
8
+
9
+
10
+ class UmfStringUtil
11
+
12
+ def getPlainSortByAnd(params)
13
+ arg = ""
14
+ paramter = {}
15
+ if params.size>0
16
+ keys = params.keys
17
+ keys.each { |elem|
18
+ if elem=="ret_url" || elem=="notify_url"
19
+ params[elem] = CGI.escape(params[elem])
20
+ end
21
+ paramter = paramter.merge({elem+"="+params[elem].to_s => elem+"="+params[elem].to_s})
22
+ }
23
+ # 字母a到z排序后的数组
24
+ # [["amount=1", "amount=1"], ["amt_type=RMB", "amt_type=RMB"]...]
25
+ paramter = sorted_hash(paramter)
26
+ # print paramter
27
+ paramter.each{ |elem|
28
+ arg = arg + elem[0] + "&"
29
+ }
30
+ # 去掉最后一个&字符
31
+ arg = arg.chop
32
+ return arg
33
+ end
34
+ end
35
+
36
+
37
+
38
+ # 使用&符号组织签名明文串排序a-z 去除sign_type字段 不做urlencode
39
+ def getPlainSortByAndWithoutSignType(params)
40
+ arg = ""
41
+ paramter = {}
42
+ if params.size>0
43
+ keys = params.keys
44
+ keys.each { |elem|
45
+ # sign_type 不需要参与RAS签名
46
+ if "sign_type" != elem
47
+ paramter = paramter.merge({elem+"="+params[elem].to_s => elem+"="+params[elem].to_s})
48
+ end
49
+ }
50
+ # 字母a到z排序后的数组
51
+ # [["amount=1", "amount=1"], ["amt_type=RMB", "amt_type=RMB"]...]
52
+ paramter = sorted_hash(paramter)
53
+ paramter.each{ |elem|
54
+ arg = arg + elem[0].to_s + "&"
55
+ }
56
+ # 去掉最后一个&字符
57
+ arg = arg.chop
58
+ return arg
59
+ else
60
+ UmfLogger.logInfoMsg("[UMF SDK]获取请求参数明文字符串失败:传入参数为空!")
61
+ exit
62
+ end
63
+ end
64
+
65
+
66
+ # 使用&符号组织签名明文串排序a-z 包含sign_type字段 做了urlencode
67
+ def getPlainSortByAndWithSignType(params)
68
+ arg = ""
69
+ paramter = {}
70
+ if params.size>0
71
+ keys = params.keys
72
+ keys.each { |elem|
73
+ paramter = paramter.merge({elem+"="+URI::encode(params[elem].to_s) => elem+"="+URI::encode(params[elem].to_s)})
74
+ }
75
+ # 字母a到z排序后的数组
76
+ paramter = sorted_hash(paramter)
77
+ paramter.each{ |elem|
78
+ arg = arg + elem[0].to_s + "&"
79
+ }
80
+ arg = arg.chop
81
+ puts arg
82
+ return arg
83
+ else
84
+ UmfLogger.logInfoMsg("[UMF SDK]获取请求参数明文字符串失败:传入参数为空!")
85
+ exit
86
+ end
87
+ end
88
+
89
+
90
+ def rasEncryptedStrEscape(params)
91
+ chkKeys = [
92
+ "card_id",
93
+ "valid_date",
94
+ "cvv2",
95
+ "pass_wd",
96
+ "identity_code",
97
+ "card_holder",
98
+ "recv_account",
99
+ "recv_user_name",
100
+ "identity_holder",
101
+ "identityCode",
102
+ "cardHolder",
103
+ "mer_cust_name",
104
+ "account_name",
105
+ "bank_account",
106
+ "endDate",
107
+ ]
108
+ chkKeys.each{ |elem|
109
+ value = params[elem]
110
+ if value=="" || value==nil
111
+ next
112
+ end
113
+ params[elem] = CGI.escape(value)
114
+ }
115
+ return params
116
+ end
117
+
118
+
119
+ private
120
+ # hash升序排列
121
+ def sorted_hash(aHash)
122
+ return aHash.sort{|a,b| a.to_s <=> b.to_s}
123
+ end
124
+
125
+ end
126
+
File without changes
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: umf_pay_service_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - zhaoyingxin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-18 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: umf pay service ruby
14
+ email: 18813141886@163.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/UmfCheckReqDataAndEncrypt.rb
20
+ - lib/UmfCommon.rb
21
+ - lib/UmfConfig.rb
22
+ - lib/UmfHttp.rb
23
+ - lib/UmfLogger.rb
24
+ - lib/UmfMerToPlat.rb
25
+ - lib/UmfRSACryptUtil.rb
26
+ - lib/UmfRegexUtil.rb
27
+ - lib/UmfReqDataUtil.rb
28
+ - lib/UmfService.rb
29
+ - lib/UmfStringUtil.rb
30
+ - lib/umf_pay_service_ruby.rb
31
+ homepage: https://xy.umfintech.com/api/
32
+ licenses:
33
+ - MIT
34
+ metadata: {}
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project:
51
+ rubygems_version: 2.6.13
52
+ signing_key:
53
+ specification_version: 4
54
+ summary: umf pay service ruby
55
+ test_files: []