ll_pay 0.4.0 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27e236f7da1a930ed85d277e0f1f362692dc160b
4
- data.tar.gz: 99a6988e4104fcf65f24b5d123930dbc630a2b48
3
+ metadata.gz: ac2772f8f1ecafe1006c0452dea64efd64c67f2f
4
+ data.tar.gz: b6eb1d00781e7773c8036ec885177b2707bc0751
5
5
  SHA512:
6
- metadata.gz: 4d75e35f538e46466facb3c17fe666b9565298f11e58c3fd91696042e377b15b3b079d6911b3a2f97984958d5812e547b1174a9098d6e82004878fdd1f26a457
7
- data.tar.gz: 59dd9313404b78cc79136958422cb14a728b84aa6a93fde30adea77347759ec268b67bbc19c62494c4efcc18875146ec05becb29962eb601f37cafba6fb7bfd1
6
+ metadata.gz: ab32fa457432eb129c845aa3d06a09ce51482f836410a4399302002e65ca8fbc3f882f8d61d9d5a37be997bf24f8929e6472a601a20571f8a7224967d93804ca
7
+ data.tar.gz: 1b07b23cf8a733cf637dca50ae66d0b2dc60833015a80bf39aee56e86355085cb2050c09bcce380a8768f036b5950a1c90b0f0b18275a9b90d6c3d0e8e86d5e8
data/lib/ll_pay/notify.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module LlPay
2
2
  module Notify
3
- def self.verify?(params, options = {})
3
+ def notify_verify?(params, options = {})
4
4
  params = LlPay::Utils.stringify_keys(params)
5
5
  options = LlPay::Utils.stringify_keys(options)
6
6
 
@@ -4,31 +4,11 @@ require 'http' # https://github.com/httprb/http
4
4
 
5
5
  module LlPay
6
6
  module QueryOrder
7
- def self.query_single_order(sign_type, no_order, dt_order)
8
- query_order_hash = { oid_partner: LlPay.oid_partner, dt_order: dt_order, no_order: no_order }
7
+ def query_single_order(sign_type, no_order, dt_order)
8
+ query_order_hash = { oid_partner: LlPay.oid_partner, dt_order: dt_order, no_order: no_order, sign_type: sign_type }
9
+ query_order_hash[:sign] = LlPay::Sign.generate(query_order_hash)
9
10
 
10
- if sign_type == 'RSA'
11
- query_order_hash[:sign_type] = 'RSA'
12
- query_order_hash[:sign] = LlPay::Sign::RSA.sign(LlPay.rsa_pri_key, LlPay::Sign.params_to_string(query_order_hash))
13
- else
14
- query_order_hash[:sign_type] = 'MD5'
15
- query_order_hash[:sign] = LlPay::Sign::MD5.sign(LlPay.md5_key, LlPay::Sign.params_to_string(query_order_hash))
16
- end
17
-
18
- http_response = HTTP.post('https://yintong.com.cn/queryapi/orderquery.htm',
19
- json: query_order_hash)
20
-
21
- response_hash = JSON.parse(http_response.body.to_s)
22
-
23
- if http_response.code == 200
24
- if response_hash['ret_code'] == 0000 && LlPay::Sign.verify?(LlPay::Sign.params_to_string(response_hash))
25
- return response_hash
26
- else
27
- return response_hash
28
- end
29
- else
30
- return
31
- end
11
+ request(:post, 'https://yintong.com.cn/queryapi/orderquery.htm', query_order_hash)
32
12
  end
33
13
  end
34
14
  end
@@ -0,0 +1,43 @@
1
+ module LlPay
2
+ module RefundOrder
3
+ def refund_order(params)
4
+ params = LlPay::Utils.stringify_keys(params)
5
+
6
+ params[:sign_type] = params[:sign_type] || LlPay.sign_type
7
+ params[:oid_partner] = LlPay.oid_partner
8
+
9
+ sign_params = { 'oid_partner' => params[:oid_partner],
10
+ 'sign_type' => params[:sign_type],
11
+ 'no_refund' => params[:no_refund],
12
+ 'dt_refund' => params[:dt_refund],
13
+ 'money_refund' => params[:money_refund],
14
+ 'no_order' => params[:no_order],
15
+ 'dt_order' => params[:dt_order],
16
+ 'oid_paybill' => params[:oid_paybill],
17
+ 'notify_url' => params[:notify_url]
18
+ }
19
+
20
+ params[:sign] = LlPay::Sign.generate(sign_params)
21
+
22
+ request(:post, 'https://yintong.com.cn/traderapi/refund.htm', params)
23
+ end
24
+
25
+ def refund_order_query(params)
26
+ params = LlPay::Utils.stringify_keys(params)
27
+
28
+ params[:sign_type] = params[:sign_type] || LlPay.sign_type
29
+ params[:oid_partner] = LlPay.oid_partner
30
+
31
+ sign_params = { 'oid_partner' => params[:oid_partner],
32
+ 'sign_type' => params[:sign_type],
33
+ 'no_refund' => params[:no_refund],
34
+ 'dt_refund' => params[:dt_refund],
35
+ 'oid_refundno' => params[:oid_refundno]
36
+ }
37
+
38
+ params[:sign] = LlPay::Sign.generate(sign_params)
39
+
40
+ request(:post, 'https://queryapi.lianlianpay.com/refundquery.htm', params)
41
+ end
42
+ end
43
+ end
@@ -4,13 +4,13 @@ module LlPay
4
4
  module Service
5
5
 
6
6
  SECURITY_PAY_REQUIRED_PARAMS = %w(busi_partner dt_order info_order money_order name_goods no_order notify_url oid_partner risk_item sign_type valid_order)
7
- def self.securitypay_pay_json(params, options = {})
7
+ def securitypay_pay_json(params, options = {})
8
8
  # params = LlPay::Utils.stringify_keys(params)
9
9
  # options = LlPay::Utils.stringify_keys(options)
10
10
 
11
11
  check_required_params(params, SECURITY_PAY_REQUIRED_PARAMS)
12
12
 
13
- params['sign_type'] = options['sign_type'] || LlPay.sign_type
13
+ params['sign_type'] = params['sign_type'] || LlPay.sign_type
14
14
 
15
15
  params = { 'oid_partner' => LlPay.oid_partner }.merge(params)
16
16
 
@@ -30,7 +30,7 @@ module LlPay
30
30
  params.to_json
31
31
  end
32
32
 
33
- def self.check_required_params(params, names)
33
+ def check_required_params(params, names)
34
34
  names.each do |name|
35
35
  warn("ll_pay Warn: missing required option: #{name}") unless params.has_key?(name)
36
36
  end
@@ -1,3 +1,3 @@
1
1
  module LlPay
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
data/lib/ll_pay.rb CHANGED
@@ -4,6 +4,7 @@ require 'll_pay/sign/md5'
4
4
  require 'll_pay/sign/rsa'
5
5
  require 'll_pay/notify'
6
6
  require 'll_pay/query_order'
7
+ require 'll_pay/refund_order'
7
8
  require 'll_pay/service'
8
9
  require 'll_pay/utils'
9
10
 
@@ -24,5 +25,32 @@ kPE0FtaoMP3gYfh+OwI+fIRrpW3ySn3mScnc6Z700nU/VYrRkfcSCbSnRwIDAQAB
24
25
  attr_accessor :rsa_pri_key # 私钥
25
26
  attr_accessor :md5_key # md5
26
27
  attr_accessor :sign_type
28
+
29
+ include QueryOrder
30
+ include RefundOrder
31
+ include Service
32
+ include Notify
33
+ end
34
+
35
+ def self.request(verb, url, params = {})
36
+ case verb.to_sym
37
+ when :post
38
+ @http_response = HTTP.post(url, json: params)
39
+ when :get
40
+ @http_response = HTTP.get(url)
41
+ end
42
+ response_hash = JSON.parse(@http_response.body.to_s)
43
+
44
+ if @http_response.code == 200
45
+ if response_hash['ret_code'] == 0000
46
+ if LlPay::Sign.verify?(response_hash)
47
+ return response_hash
48
+ else
49
+ return { ret_msg: '签名验证错误' }
50
+ end
51
+ else
52
+ return response_hash
53
+ end
54
+ end
27
55
  end
28
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ll_pay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - houdelin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-18 00:00:00.000000000 Z
11
+ date: 2016-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -72,7 +72,7 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '3.5'
75
- description: Helping rubyist integration with lianlian pay easier.
75
+ description: Helping rubyist integration with lianlian pay(lianlianpay llpay) easier.
76
76
  email:
77
77
  - houdelin@bayekeji.com
78
78
  executables: []
@@ -88,6 +88,7 @@ files:
88
88
  - lib/ll_pay.rb
89
89
  - lib/ll_pay/notify.rb
90
90
  - lib/ll_pay/query_order.rb
91
+ - lib/ll_pay/refund_order.rb
91
92
  - lib/ll_pay/service.rb
92
93
  - lib/ll_pay/sign.rb
93
94
  - lib/ll_pay/sign/md5.rb