ubox 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/ubox.rb +17 -17
- data/lib/ubox/version.rb +1 -1
- 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: 249f22e3cb2b990d51888c7deb9312410aa2b628
|
4
|
+
data.tar.gz: 294f9fb278bd81ac099bb97b57893239e00e29ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26071bd34a3dd9fb7a9681eb6c3da35ab846a66ae2a3cba9c5d4d77686366fcd3d1dfafc2a568c3cff943148d0c88ca5d378b747e2718b6fb5781ffabda3af06
|
7
|
+
data.tar.gz: e8efa21256ee819cbc4d9665ca78497d24170e7a516280a36e3c8cad6e6815c4e6af32da791c7f921dd948323fd616f090c85221326a6c52358bcd4c7f963e58
|
data/README.md
CHANGED
@@ -34,9 +34,9 @@ Or install it yourself as:
|
|
34
34
|
|
35
35
|
## Usage
|
36
36
|
|
37
|
-
|
37
|
+
###getProductDetail 获取商品信息(扫码)
|
38
38
|
```ruby
|
39
|
-
Ubox.product_detail('http://v.dev.uboxol.com/qr/c0081801_10000870_1')
|
39
|
+
Ubox.product_detail(qr_string:'http://v.dev.uboxol.com/qr/c0081801_10000870_1')
|
40
40
|
```
|
41
41
|
|
42
42
|
```json
|
@@ -71,9 +71,9 @@ Ubox.product_detail('http://v.dev.uboxol.com/qr/c0081801_10000870_1')
|
|
71
71
|
}
|
72
72
|
}
|
73
73
|
```
|
74
|
-
### 扫码下单请求
|
74
|
+
### notifyOrder 扫码下单请求
|
75
75
|
```ruby
|
76
|
-
detail = Ubox.product_detail('http://v.dev.uboxol.com/qr/c0081801_10000870_1')
|
76
|
+
detail = Ubox.product_detail(qr_string:'http://v.dev.uboxol.com/qr/c0081801_10000870_1')
|
77
77
|
notify = Ubox.notify_order(tran_id: detail['body']['tran_id'],
|
78
78
|
retain_period: 300,
|
79
79
|
app_tran_id: Random.rand_str(32),
|
data/lib/ubox.rb
CHANGED
@@ -31,15 +31,16 @@ module Ubox
|
|
31
31
|
params.inject([]) { |a, (k, v)| a<<"#{k}=#{v}"; a }.join("&")
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
def
|
34
|
+
|
35
|
+
def post_request(api_path, attributes)
|
36
|
+
puts attributes
|
36
37
|
params = {
|
37
38
|
app_id: self.config.app_id,
|
38
|
-
|
39
|
-
}
|
39
|
+
tran_id: attributes[:tran_id]
|
40
|
+
}.merge(attributes)
|
40
41
|
params = params.merge({sign: self.sign(params)})
|
41
42
|
|
42
|
-
url = "#{self.config.api_url}
|
43
|
+
url = "#{self.config.api_url}/#{api_path}"
|
43
44
|
uri = URI(url)
|
44
45
|
res = Net::HTTP.post_form(uri, params)
|
45
46
|
|
@@ -47,22 +48,21 @@ module Ubox
|
|
47
48
|
JSON.parse(body)
|
48
49
|
end
|
49
50
|
|
51
|
+
#商品详情
|
52
|
+
def product_detail(attributes)
|
53
|
+
post_request('/getProductDetail', attributes)
|
54
|
+
end
|
55
|
+
|
50
56
|
#扫码下单请求
|
51
57
|
#notify_order(tran_id:xxxx,retain_period:300,app_tran_id:xxxx,app_uid:uid)
|
52
58
|
def notify_order(attributes)
|
53
|
-
|
54
|
-
|
55
|
-
app_id: self.config.app_id,
|
56
|
-
tran_id: attributes[:tran_id]
|
57
|
-
}.merge(attributes)
|
58
|
-
params = params.merge({sign: self.sign(params)})
|
59
|
-
|
60
|
-
url = "#{self.config.api_url}/notifyOrder"
|
61
|
-
uri = URI(url)
|
62
|
-
res = Net::HTTP.post_form(uri, params)
|
59
|
+
post_request('/notifyOrder', attributes)
|
60
|
+
end
|
63
61
|
|
64
|
-
|
65
|
-
|
62
|
+
#m买取货吗(支付结果通知)
|
63
|
+
#notify_payment(tran_id:xxx,pay_time:13311111,app_current_time:true,deliver_now:true)
|
64
|
+
def notify_payment(attributes)
|
65
|
+
post_request('/notifyPayment', attributes)
|
66
66
|
end
|
67
67
|
|
68
68
|
end
|
data/lib/ubox/version.rb
CHANGED