Class: UmfStringUtil
- Inherits:
-
Object
- Object
- UmfStringUtil
- Defined in:
- lib/UmfStringUtil.rb
Instance Method Summary collapse
- #getPlainSortByAnd(params) ⇒ Object
-
#getPlainSortByAndWithoutSignType(params) ⇒ Object
使用&符号组织签名明文串排序a-z 去除sign_type字段 不做urlencode.
-
#getPlainSortByAndWithSignType(params) ⇒ Object
使用&符号组织签名明文串排序a-z 包含sign_type字段 做了urlencode.
- #rasEncryptedStrEscape(params) ⇒ Object
Instance Method Details
#getPlainSortByAnd(params) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/UmfStringUtil.rb', line 12 def getPlainSortByAnd(params) arg = "" paramter = {} if params.size>0 keys = params.keys keys.each { |elem| if elem=="ret_url" || elem=="notify_url" params[elem] = CGI.escape(params[elem]) end paramter = paramter.merge({elem+"="+params[elem].to_s => elem+"="+params[elem].to_s}) } # 字母a到z排序后的数组 # [["amount=1", "amount=1"], ["amt_type=RMB", "amt_type=RMB"]...] paramter = sorted_hash(paramter) # print paramter paramter.each{ |elem| arg = arg + elem[0] + "&" } # 去掉最后一个&字符 arg = arg.chop return arg end end |
#getPlainSortByAndWithoutSignType(params) ⇒ Object
使用&符号组织签名明文串排序a-z 去除sign_type字段 不做urlencode
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/UmfStringUtil.rb', line 39 def getPlainSortByAndWithoutSignType(params) arg = "" paramter = {} if params.size>0 keys = params.keys keys.each { |elem| # sign_type 不需要参与RAS签名 if "sign_type" != elem paramter = paramter.merge({elem+"="+params[elem].to_s => elem+"="+params[elem].to_s}) end } # 字母a到z排序后的数组 # [["amount=1", "amount=1"], ["amt_type=RMB", "amt_type=RMB"]...] paramter = sorted_hash(paramter) paramter.each{ |elem| arg = arg + elem[0].to_s + "&" } # 去掉最后一个&字符 arg = arg.chop return arg else UmfLogger.logInfoMsg("[UMF SDK]获取请求参数明文字符串失败:传入参数为空!") exit end end |
#getPlainSortByAndWithSignType(params) ⇒ Object
使用&符号组织签名明文串排序a-z 包含sign_type字段 做了urlencode
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/UmfStringUtil.rb', line 67 def getPlainSortByAndWithSignType(params) arg = "" paramter = {} if params.size>0 keys = params.keys keys.each { |elem| paramter = paramter.merge({elem+"="+URI::encode(params[elem].to_s) => elem+"="+URI::encode(params[elem].to_s)}) } # 字母a到z排序后的数组 paramter = sorted_hash(paramter) paramter.each{ |elem| arg = arg + elem[0].to_s + "&" } arg = arg.chop puts arg return arg else UmfLogger.logInfoMsg("[UMF SDK]获取请求参数明文字符串失败:传入参数为空!") exit end end |
#rasEncryptedStrEscape(params) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/UmfStringUtil.rb', line 90 def rasEncryptedStrEscape(params) chkKeys = [ "card_id", "valid_date", "cvv2", "pass_wd", "identity_code", "card_holder", "recv_account", "recv_user_name", "identity_holder", "identityCode", "cardHolder", "mer_cust_name", "account_name", "bank_account", "endDate", ] chkKeys.each{ |elem| value = params[elem] if value=="" || value==nil next end params[elem] = CGI.escape(value) } return params end |