unionpay_app 0.6.0 → 0.7.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 +4 -4
- data/README.md +43 -6
- data/lib/unionpay_app/service.rb +1 -1
- data/lib/unionpay_app/version.rb +1 -1
- data/lib/unionpay_app.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5a55cbcaae7b52d07dc33c0d124c2210c13516d
|
4
|
+
data.tar.gz: 168a8a8128e34a304671aae79bebd0b9c678fde5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df0d6e827780b8bb96b633d8602b0d76f9c44f47446a3b5daf7737147679bbc24c71295606e999a462af235173b406a20ccd8da1ec0c2c200b0b0b94a7b6ccc5
|
7
|
+
data.tar.gz: ac49e9a1385de89b9d36be14526ad2f4e9a0e13570f44d287d3867cc4871ee2d76dedd80040437f0af2ff48cdf58c95c07cec938f882cd41354ead0b5c3160b9
|
data/README.md
CHANGED
@@ -1,12 +1,49 @@
|
|
1
|
+
<<<<<<< HEAD
|
1
2
|
该gem是一个银联手机控件支付接口
|
3
|
+
|
4
|
+
Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
gem 'unionpay_app', '~> 0.6.0'
|
9
|
+
or development version
|
10
|
+
|
11
|
+
$ bundle
|
12
|
+
Usage
|
13
|
+
|
14
|
+
Config
|
15
|
+
|
16
|
+
UnionpayApp.front_url = Settings.union.frontUrl
|
17
|
+
UnionpayApp.back_url = Settings.union.backUrl
|
18
|
+
UnionpayApp.mer_id = Settings.union.merId
|
19
|
+
UnionpayApp.uri = Settings.union.uri
|
20
|
+
UnionpayApp.private_key = Settings.union.private_key
|
21
|
+
UnionpayApp.cer = Settings.union.cer
|
22
|
+
UnionpayApp.cert_id = Settings.union.certId
|
23
|
+
Generate payment url for web
|
24
|
+
|
2
25
|
1. #银联签名 返回hash {time: "交易时间", sign: "post给银联的hash"}
|
3
|
-
|
4
|
-
|
26
|
+
UnionpayApp::Service.sign txtAmt, orderId
|
27
|
+
params = UnionpayApp::Service.sign("100", "20150415122801272")
|
5
28
|
2. #发送给银联post请求 换取tn值
|
6
|
-
UnionpayApp::Service.post UnionpayApp::Service.sign(txtAmt, orderId)
|
29
|
+
UnionpayApp::Service.post UnionpayApp::Service.sign(txtAmt, orderId)
|
7
30
|
UnionpayApp::Service.post(params)
|
8
31
|
3. #银联验签:当请求银联获取tn后,或者请求银联查询交易后,或者当交易完成后,银联通过backUrl、frontUrl返回你结果时要进行验签
|
9
|
-
|
32
|
+
UnionpayApp::Service.verify params
|
10
33
|
4. #查询交易是否成功 传入参数order_id
|
11
|
-
|
12
|
-
|
34
|
+
UnionpayApp::Service.query order_id, UnionpayApp::Service.sign(txtAmt, orderId)[:time]
|
35
|
+
UnionpayApp::Service.query "20150415122801272", params[:time]
|
36
|
+
=======
|
37
|
+
该gem是一个银联手机控件支付接口
|
38
|
+
1. #银联签名 返回hash {time: "交易时间", sign: "post给银联的hash"}
|
39
|
+
UnionpayApp::Service.sign txtAmt, orderId
|
40
|
+
params = UnionpayApp::Service.sign("100", "20150415122801272")
|
41
|
+
2. #发送给银联post请求 换取tn值
|
42
|
+
UnionpayApp::Service.post UnionpayApp::Service.sign(txtAmt, orderId)[:sign]
|
43
|
+
UnionpayApp::Service.post(params)
|
44
|
+
3. #银联验签:当请求银联获取tn后,或者请求银联查询交易后,或者当交易完成后,银联通过backUrl、frontUrl返回你结果时要进行验签
|
45
|
+
UnionpayApp::Service.verify params
|
46
|
+
4. #查询交易是否成功 传入参数order_id
|
47
|
+
UnionpayApp::Service.query order_id, UnionpayApp::Service.sign(txtAmt, orderId)[:time]
|
48
|
+
UnionpayApp::Service.query "20150415122801272", params[:time]
|
49
|
+
>>>>>>> 760bcdda0389701cee33cbedba2d424b7ce36d7d
|
data/lib/unionpay_app/service.rb
CHANGED
@@ -80,7 +80,7 @@ module UnionpayApp
|
|
80
80
|
}
|
81
81
|
data = Digest::SHA1.hexdigest(union_params.sort.map{|key, value| "#{key}=#{value}" }.join('&'))
|
82
82
|
sign = Base64.encode64(OpenSSL::PKey::RSA.new(UnionpayApp.private_key).sign('sha1', data.force_encoding("utf-8"))).gsub("\n", "")
|
83
|
-
request = Typhoeus::Request.new(UnionpayApp.
|
83
|
+
request = Typhoeus::Request.new(UnionpayApp.query_uri, method: :post, params: union_params.merge(signature: sign), ssl_verifypeer: false, headers: {'Content-Type' =>'application/x-www-form-urlencoded'} )
|
84
84
|
request.run
|
85
85
|
if request.response.success?
|
86
86
|
code = Hash[*request.response.body.split("&").map{|a| a.gsub("==", "@@").split("=")}.flatten]['origRespCode']
|
data/lib/unionpay_app/version.rb
CHANGED
data/lib/unionpay_app.rb
CHANGED