pingpp 1.0.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pingpp/certificate_blacklist.rb +2 -2
- data/lib/pingpp/channel.rb +10 -4
- data/lib/pingpp/version.rb +1 -1
- data/lib/pingpp/wx_pub_oauth.rb +41 -0
- data/lib/pingpp.rb +17 -14
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e400717b5fb25538403e1276d4938a01b061956
|
4
|
+
data.tar.gz: b177462b2b6949988f9207a0f9b0f7032d052b13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b86aca054bc33863c67b950131b7cc844f3abbbe5e2ada5e5de3242e5c047f6b8d08d6ea79f8eb8cf5e94aa3a7d56d9998263ae3f5ebcb0dcd865d4fce1e8b0
|
7
|
+
data.tar.gz: eb04bd61d5c1a8f8cf4a0fe0ebf624351864329155422a650d6e0dbb06bb91b2649504affc15c432b6ebb7e45b53ab6edc0973151241aae2e9b8efe268d6c5be
|
@@ -5,7 +5,7 @@ module Pingpp
|
|
5
5
|
module CertificateBlacklist
|
6
6
|
|
7
7
|
BLACKLIST = {
|
8
|
-
"api.
|
8
|
+
"api.pingxx.com" => [
|
9
9
|
'05c0b3643694470a888c6e7feb5c9e24e823dc53',
|
10
10
|
'5b7dc7fbc98d78bf76d4d4fa6f597a0c901fad5c',
|
11
11
|
]
|
@@ -39,7 +39,7 @@ module Pingpp
|
|
39
39
|
raise APIConnectionError.new(
|
40
40
|
"Invalid server certificate. You tried to connect to a server that" +
|
41
41
|
"has a revoked SSL certificate, which means we cannot securely send" +
|
42
|
-
"data to that server. Please email support@
|
42
|
+
"data to that server. Please email support@pingxx.com if you need" +
|
43
43
|
"help connecting to the correct API server."
|
44
44
|
)
|
45
45
|
end
|
data/lib/pingpp/channel.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
module Pingpp
|
2
2
|
class Channel
|
3
|
-
ALIPAY
|
4
|
-
WECHAT
|
5
|
-
|
3
|
+
ALIPAY = "alipay"
|
4
|
+
WECHAT = "wx"
|
5
|
+
WX = "wx" # Alias of WECHAT
|
6
|
+
UPMP = "upmp"
|
6
7
|
ALIPAY_WAP = "alipay_wap"
|
7
|
-
UPMP_WAP
|
8
|
+
UPMP_WAP = "upmp_wap"
|
9
|
+
WX_PUB = "wx_pub"
|
10
|
+
BFB = "bfb"
|
11
|
+
BFB_WAP = "bfb_wap"
|
12
|
+
UPACP = "upacp"
|
13
|
+
UPACP_WAP = "upacp_wap"
|
8
14
|
end
|
9
15
|
end
|
data/lib/pingpp/version.rb
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
module Pingpp
|
2
|
+
module WxPubOauth
|
3
|
+
def self.create_oauth_url_for_code(app_id, redirect_url, more_info = false)
|
4
|
+
query_parts = {
|
5
|
+
'appid' => app_id,
|
6
|
+
'redirect_uri' => redirect_url,
|
7
|
+
'response_type' => 'code',
|
8
|
+
'scope' => more_info ? 'snsapi_userinfo' : 'snsapi_base'
|
9
|
+
}
|
10
|
+
query_str = Pingpp.uri_encode(query_parts)
|
11
|
+
'https://open.weixin.qq.com/connect/oauth2/authorize?' + query_str + '#wechat_redirect'
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.get_openid(app_id, app_secret, code)
|
15
|
+
url = create_oauth_url_for_openid(app_id, app_secret, code)
|
16
|
+
request_opts = {
|
17
|
+
:url => url,
|
18
|
+
:verify_ssl => false,
|
19
|
+
:ssl_version => 'TLSv1',
|
20
|
+
:method => 'GET',
|
21
|
+
:headers => false,
|
22
|
+
:open_timeout => 30,
|
23
|
+
:timeout => 30
|
24
|
+
}
|
25
|
+
response = RestClient::Request.execute(request_opts)
|
26
|
+
response = JSON.parse(response.body)
|
27
|
+
response['openid']
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.create_oauth_url_for_openid(app_id, app_secret, code)
|
31
|
+
query_parts = {
|
32
|
+
'appid' => app_id,
|
33
|
+
'secret' => app_secret,
|
34
|
+
'code' => code,
|
35
|
+
'grant_type' => 'authorization_code'
|
36
|
+
}
|
37
|
+
query_str = Pingpp.uri_encode(query_parts)
|
38
|
+
'https://api.weixin.qq.com/sns/oauth2/access_token?' + query_str
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/pingpp.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Pingpp Ruby bindings
|
2
|
-
# API spec at https://
|
2
|
+
# API spec at https://pingxx.com/document/api
|
3
3
|
require 'cgi'
|
4
4
|
require 'set'
|
5
5
|
require 'openssl'
|
@@ -35,11 +35,14 @@ require 'pingpp/errors/api_connection_error'
|
|
35
35
|
require 'pingpp/errors/invalid_request_error'
|
36
36
|
require 'pingpp/errors/authentication_error'
|
37
37
|
|
38
|
+
# WxPubOauth
|
39
|
+
require 'pingpp/wx_pub_oauth'
|
40
|
+
|
38
41
|
module Pingpp
|
39
42
|
DEFAULT_CA_BUNDLE_PATH = File.dirname(__FILE__) + '/data/ca-certificates.crt'
|
40
|
-
@api_base = 'https://api.
|
43
|
+
@api_base = 'https://api.pingxx.com'
|
41
44
|
|
42
|
-
@api_version = '
|
45
|
+
@api_version = '2015-01-01'
|
43
46
|
|
44
47
|
@ssl_bundle_path = DEFAULT_CA_BUNDLE_PATH
|
45
48
|
@verify_ssl_certs = true
|
@@ -59,15 +62,15 @@ module Pingpp
|
|
59
62
|
raise AuthenticationError.new('No API key provided. ' +
|
60
63
|
'Set your API key using "Pingpp.api_key = <API-KEY>". ' +
|
61
64
|
'You can generate API keys from the Pingpp web interface. ' +
|
62
|
-
'See https://
|
65
|
+
'See https://pingxx.com/document/api for details, or email support@pingxx.com ' +
|
63
66
|
'if you have any questions.')
|
64
67
|
end
|
65
68
|
|
66
69
|
if api_key =~ /\s/
|
67
70
|
raise AuthenticationError.new('Your API key is invalid, as it contains ' +
|
68
71
|
'whitespace. (HINT: You can double-check your API key from the ' +
|
69
|
-
'Pingpp web interface. See https://
|
70
|
-
'email support@
|
72
|
+
'Pingpp web interface. See https://pingxx.com/document/api for details, or ' +
|
73
|
+
'email support@pingxx.com if you have any questions.)')
|
71
74
|
end
|
72
75
|
|
73
76
|
request_opts = { :verify_ssl => false, :ssl_version => 'TLSv1' }
|
@@ -90,10 +93,10 @@ module Pingpp
|
|
90
93
|
url += "#{URI.parse(url).query ? '&' : '?'}#{uri_encode(params)}" if params && params.any?
|
91
94
|
payload = nil
|
92
95
|
else
|
93
|
-
payload =
|
96
|
+
payload = JSON.generate(params)
|
94
97
|
end
|
95
98
|
|
96
|
-
request_opts.update(:headers => request_headers(api_key).update(headers),
|
99
|
+
request_opts.update(:headers => request_headers(api_key, method.to_s.downcase.to_sym == :post).update(headers),
|
97
100
|
:method => method, :open_timeout => 30,
|
98
101
|
:payload => payload, :url => url, :timeout => 80)
|
99
102
|
|
@@ -167,11 +170,11 @@ module Pingpp
|
|
167
170
|
map { |k,v| "#{k}=#{Util.url_encode(v)}" }.join('&')
|
168
171
|
end
|
169
172
|
|
170
|
-
def self.request_headers(api_key)
|
173
|
+
def self.request_headers(api_key, is_post=false)
|
171
174
|
headers = {
|
172
175
|
:user_agent => "Pingpp/v1 RubyBindings/#{Pingpp::VERSION}",
|
173
176
|
:authorization => "Bearer #{api_key}",
|
174
|
-
:content_type => 'application/x-www-form-urlencoded'
|
177
|
+
:content_type => is_post ? 'application/json' : 'application/x-www-form-urlencoded'
|
175
178
|
}
|
176
179
|
|
177
180
|
headers[:pingplusplus_version] = api_version if api_version
|
@@ -242,7 +245,7 @@ module Pingpp
|
|
242
245
|
def self.handle_restclient_error(e)
|
243
246
|
connection_message = "Please check your internet connection and try again. " \
|
244
247
|
"If this problem persists, you should check Pingpp's service status at " \
|
245
|
-
"https://
|
248
|
+
"https://pingxx.com, or let us know at support@pingxx.com."
|
246
249
|
|
247
250
|
case e
|
248
251
|
when RestClient::RequestTimeout
|
@@ -256,16 +259,16 @@ module Pingpp
|
|
256
259
|
message = "Could not verify Pingpp's SSL certificate. " \
|
257
260
|
"Please make sure that your network is not intercepting certificates. " \
|
258
261
|
"(Try going to (#{@api_base}) in your browser.) " \
|
259
|
-
"If this problem persists, let us know at support@
|
262
|
+
"If this problem persists, let us know at support@pingxx.com."
|
260
263
|
|
261
264
|
when SocketError
|
262
265
|
message = "Unexpected error communicating when trying to connect to Pingpp. " \
|
263
266
|
"You may be seeing this message because your DNS is not working. " \
|
264
|
-
"To check, try running 'host
|
267
|
+
"To check, try running 'host pingxx.com' from the command line."
|
265
268
|
|
266
269
|
else
|
267
270
|
message = "Unexpected error communicating with Pingpp. " \
|
268
|
-
"If this problem persists, let us know at support@
|
271
|
+
"If this problem persists, let us know at support@pingxx.com."
|
269
272
|
|
270
273
|
end
|
271
274
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pingpp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xufeng Weng
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -126,10 +126,10 @@ dependencies:
|
|
126
126
|
- - ">="
|
127
127
|
- !ruby/object:Gem::Version
|
128
128
|
version: '0'
|
129
|
-
description: PingPlusPlus is the easiest way to accept payments online. See https://
|
129
|
+
description: PingPlusPlus is the easiest way to accept payments online. See https://pingxx.com
|
130
130
|
for details.
|
131
131
|
email:
|
132
|
-
- xufeng.weng@
|
132
|
+
- xufeng.weng@pingxx.com
|
133
133
|
executables: []
|
134
134
|
extensions: []
|
135
135
|
extra_rdoc_files: []
|
@@ -155,7 +155,8 @@ files:
|
|
155
155
|
- lib/pingpp/singleton_api_resource.rb
|
156
156
|
- lib/pingpp/util.rb
|
157
157
|
- lib/pingpp/version.rb
|
158
|
-
|
158
|
+
- lib/pingpp/wx_pub_oauth.rb
|
159
|
+
homepage: https://pingxx.com/document/api
|
159
160
|
licenses:
|
160
161
|
- MIT
|
161
162
|
metadata: {}
|
@@ -175,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
176
|
version: '0'
|
176
177
|
requirements: []
|
177
178
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.4.
|
179
|
+
rubygems_version: 2.4.5
|
179
180
|
signing_key:
|
180
181
|
specification_version: 4
|
181
182
|
summary: Ruby bindings for the PingPlusPlus API
|