eloan 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/example.rb +3 -3
- data/lib/eloan/api.rb +4 -2
- data/lib/eloan/client.rb +7 -5
- data/lib/eloan/configuration.rb +4 -0
- data/lib/eloan/helper/payment.rb +3 -3
- data/lib/eloan/helper/request.rb +7 -6
- data/lib/eloan/helper/service.rb +10 -7
- data/lib/eloan/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96f9a439006d13b140af13970bc1278d878b1e40f54139f3c52b2f4a5a8dd31a
|
4
|
+
data.tar.gz: e86d3f4b882a188b59ff00ce342cfd1e1fac1a7c85985af64cf792004be8ef9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71252e034e803d58fb55f3acb9570d3060c8695ca766ee9d44ee53259613cc672482301cefd009b4eb04239671569a96c7a0006e580c08796d71f54a14f71d29
|
7
|
+
data.tar.gz: 80830baa752c6223cd84eb29b457800570d2dd2bf47e5daf5f7a5995472180d49a809d80ffbdc0906d87dc19d7d400d90fa19bbe8891c0687ea24b53d6272d63
|
data/examples/example.rb
CHANGED
@@ -20,7 +20,7 @@ data = {
|
|
20
20
|
Eloan.api.pay(101, data)
|
21
21
|
|
22
22
|
# 个人开户代扣签约绑卡(102)
|
23
|
-
# code =
|
23
|
+
# code = 102
|
24
24
|
# cert_id String 是 最长20 身份证号码
|
25
25
|
# user_name String 是 最长80 用户姓名
|
26
26
|
# card_no String 是 最长20 银行卡号
|
@@ -66,12 +66,12 @@ Eloan.api.pay(103, data)
|
|
66
66
|
# user_name String 是 最长80 借款人姓名
|
67
67
|
# user_card_no String 是 最长20 借款人银行卡号
|
68
68
|
# user_amount String 是 最长14 借款人金额,小数点后两位数字 #.##
|
69
|
-
# user_cash_method String 是 定长2 取现方式:T0:即时到账,手续费较高;T1:第二日到账,手续费较低, default:
|
69
|
+
# user_cash_method String 是 定长2 取现方式:T0:即时到账,手续费较高;T1:第二日到账,手续费较低, default: T0
|
70
70
|
# merchant_cert_type String 否 定长2 受托商户证件类型,受托支付时必填:00-普通营业执照企业; 01-三证合一企业
|
71
71
|
# merchant_cert_id String 否 最长30 受托商户证件号码,受托支付时必填
|
72
72
|
# merchant_amount String 否 最长14 受托商户金额,小数点后两位数字#.##,受托支付时必填
|
73
73
|
# installment_number String 是 最长3 分期期数
|
74
|
-
# installment_rate String 是 最长5 分期利率,年化<=36.00%,小数点后两位数字#.##, 如22.22%,传参为:22.22
|
74
|
+
# installment_rate String 是 最长5 分期利率,年化<=36.00%,小数点后两位数字#.##, 如22.22%,传参为:22.22, default: 0.00
|
75
75
|
# payment_method String 是 定长2 还款方式:00-等额本息;01-等额本金;02-一次性还本付息; 03-先息后本(即按频率付息、一次还本)
|
76
76
|
# loan_comment String 否 最长256 备注
|
77
77
|
# auditor String 否 最长64 审核人
|
data/lib/eloan/api.rb
CHANGED
@@ -10,7 +10,6 @@ module Eloan
|
|
10
10
|
include Helper::Payment
|
11
11
|
include Helper::Request
|
12
12
|
|
13
|
-
|
14
13
|
def pay code, data = {}
|
15
14
|
request = request_params(code.to_s)
|
16
15
|
url = generate_request_url(request[:url])
|
@@ -19,7 +18,10 @@ module Eloan
|
|
19
18
|
options = handle_params(generate_default_params.merge(data))
|
20
19
|
default_params = request[:default]
|
21
20
|
default_params.keys.each{|k| options[k] = default_params[k] if options[k].blank? }
|
22
|
-
|
21
|
+
|
22
|
+
eloan_message = handle_request_data(request_method, url, options)
|
23
|
+
instance_variable_set(:@eloan_message, eloan_message)
|
24
|
+
options["signature"] = hexdigest(eloan_message)
|
23
25
|
|
24
26
|
response = execute(request_method, url, options)
|
25
27
|
end
|
data/lib/eloan/client.rb
CHANGED
@@ -10,11 +10,13 @@ module Eloan
|
|
10
10
|
@configurate = config
|
11
11
|
end
|
12
12
|
|
13
|
-
def execute(
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
def execute(method, url, options)
|
14
|
+
if method == 'get'
|
15
|
+
response = RestClient.get(URI.escape(url), options)
|
16
|
+
else
|
17
|
+
response = RestClient.post(URI.escape(url), options)
|
18
|
+
end
|
19
|
+
raw_response response
|
18
20
|
end
|
19
21
|
|
20
22
|
end
|
data/lib/eloan/configuration.rb
CHANGED
data/lib/eloan/helper/payment.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Eloan
|
2
2
|
module Helper
|
3
3
|
module Payment
|
4
|
+
|
4
5
|
# 生成默认参数
|
5
6
|
def generate_default_params
|
6
7
|
{
|
@@ -13,10 +14,9 @@ module Eloan
|
|
13
14
|
end
|
14
15
|
|
15
16
|
private
|
16
|
-
#
|
17
|
+
# 生成长度为28的流水
|
17
18
|
def generate_request_seq
|
18
|
-
|
19
|
-
_ljust = 8 + length
|
19
|
+
_ljust = 14 - configurate.platform.length
|
20
20
|
configurate.platform + Time.now.strftime("%Y%m%d%H%M%S") + rand(1000 * 1000).to_s.rjust(_ljust, '0')
|
21
21
|
end
|
22
22
|
|
data/lib/eloan/helper/request.rb
CHANGED
@@ -8,7 +8,7 @@ module Eloan
|
|
8
8
|
{
|
9
9
|
url: '/v1/users/add-cash-card',
|
10
10
|
method: 'POST',
|
11
|
-
|
11
|
+
notify: true,
|
12
12
|
default: {
|
13
13
|
'cert_type' => '00',
|
14
14
|
'card_type' => 'D',
|
@@ -19,7 +19,7 @@ module Eloan
|
|
19
19
|
{
|
20
20
|
url: '/v1/users/add-withhold-card',
|
21
21
|
method: 'POST',
|
22
|
-
|
22
|
+
notify: true,
|
23
23
|
default: {
|
24
24
|
'cert_type' => '00',
|
25
25
|
'card_type' => 'D',
|
@@ -38,7 +38,7 @@ module Eloan
|
|
38
38
|
{
|
39
39
|
url: '/v1/trade/loan',
|
40
40
|
method: 'POST',
|
41
|
-
|
41
|
+
notify: true,
|
42
42
|
default: {
|
43
43
|
'business_type' => '00',
|
44
44
|
'product_type' => '00',
|
@@ -47,9 +47,10 @@ module Eloan
|
|
47
47
|
'loan_period_type' => '01',
|
48
48
|
'entrusted_flag' => 'N',
|
49
49
|
'user_cert_type' => '00',
|
50
|
-
'user_cash_method' => '
|
50
|
+
'user_cash_method' => 'T0',
|
51
51
|
'installment_number' => '1',
|
52
52
|
'payment_method' => '02',
|
53
|
+
'installment_rate' => '0.00',
|
53
54
|
'bg_return_url' => configurate.bg_return_url
|
54
55
|
}
|
55
56
|
}
|
@@ -57,7 +58,7 @@ module Eloan
|
|
57
58
|
{
|
58
59
|
url: '/v1/trade/repay',
|
59
60
|
method: 'POST',
|
60
|
-
|
61
|
+
notify: true,
|
61
62
|
default: {
|
62
63
|
'business_type' => '00',
|
63
64
|
'product_type' => '00',
|
@@ -72,7 +73,7 @@ module Eloan
|
|
72
73
|
{
|
73
74
|
url: '/v1/trade/loan/cash',
|
74
75
|
method: 'POST',
|
75
|
-
|
76
|
+
notify: true,
|
76
77
|
default: {
|
77
78
|
'bg_return_url' => configurate.bg_return_url
|
78
79
|
}
|
data/lib/eloan/helper/service.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Eloan
|
2
2
|
module Helper
|
3
3
|
module Service
|
4
|
+
attr_accessor :chaxue
|
4
5
|
def generate_request_url(url='')
|
5
6
|
[default_url, url] * ''
|
6
7
|
end
|
@@ -18,28 +19,30 @@ module Eloan
|
|
18
19
|
if response_code.last(2).to_s == '00'
|
19
20
|
status, code, message = 'success', 200, 'success'
|
20
21
|
else
|
21
|
-
if request_params(response_code.first(3))[:notify] && response_code.last(2).to_s == '
|
22
|
+
if request_params(response_code.first(3))[:notify] && response_code.last(2).to_s == '01'
|
22
23
|
status, code, message = 'success', 201, '处理中'
|
23
24
|
else
|
24
25
|
message = response['bind_error_message'].present? ? response['bind_error_message'] : response['response_message']
|
25
26
|
status, code = 'fail', 202
|
26
27
|
end
|
27
28
|
end
|
28
|
-
|
29
|
+
|
30
|
+
response = {status: status, code: code, message: message, data: response}
|
31
|
+
unless configurate.production?
|
32
|
+
eloan_message = instance_variable_get(:@eloan_message)
|
33
|
+
response = response.merge(eloan_message: eloan_message)
|
34
|
+
end
|
29
35
|
end
|
30
36
|
|
31
37
|
private
|
32
38
|
|
33
39
|
def default_url
|
34
|
-
if production?
|
40
|
+
if configurate.production?
|
41
|
+
p chaxue
|
35
42
|
else
|
36
43
|
'https://mertest.cloudpnr.com/api/eloan'
|
37
44
|
end
|
38
45
|
end
|
39
|
-
|
40
|
-
def production?
|
41
|
-
configurate.env == 'production'
|
42
|
-
end
|
43
46
|
end
|
44
47
|
end
|
45
48
|
end
|
data/lib/eloan/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eloan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rqiang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|