chan_pay 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/chan_pay.gemspec +33 -0
- data/lib/chan_pay/api/query_order.rb +23 -0
- data/lib/chan_pay/api/quick_pay.rb +94 -0
- data/lib/chan_pay/client.rb +22 -0
- data/lib/chan_pay/encrypt/rsa.rb +15 -0
- data/lib/chan_pay/http/communicate.rb +73 -0
- data/lib/chan_pay/http/ret_code.rb +20 -0
- data/lib/chan_pay/sign/rsa.rb +34 -0
- data/lib/chan_pay/utils.rb +21 -0
- data/lib/chan_pay/version.rb +3 -0
- data/lib/chan_pay.rb +18 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8d7c70b34dbd0487cd8238f9399de59df96fb316
|
4
|
+
data.tar.gz: f81dd32e452c871df1d20f581871f547434cf3a3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e49ecda7d3418f8539d51b30a0f743bb405b856d5f7a0b291c8cc500ebf244a7f3537f412fb9f8f00a130eb1efecc40c581c2ee15ec05cb80ba13b2cba66fad
|
7
|
+
data.tar.gz: d245c4b2650720f459cc110efbba8ce9c1490d645bfccee9656a57c8133d0227cd50fb29555f56b2f2d2aabb51102fcc85d557cb459cc752fea9d6bef17caed8
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at tony@omniaccount.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 tony
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# ChanPay
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/chan_pay`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'chan_pay'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install chan_pay
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/chan_pay. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "chan_pay"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/chan_pay.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'chan_pay/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "chan_pay"
|
8
|
+
spec.version = ChanPay::VERSION
|
9
|
+
spec.authors = ["tony"]
|
10
|
+
spec.email = ["tony@omniaccount.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{"畅捷支付"}
|
13
|
+
spec.description = %q{"畅捷支付"}
|
14
|
+
spec.homepage = "https://github.com/omniaccountcorp/chan_pay"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
# 4.4.2.14 确认收货接口
|
4
|
+
|
5
|
+
module ChanPay
|
6
|
+
module Api
|
7
|
+
module QueryOrder
|
8
|
+
|
9
|
+
SERVICE_NAME = 'nmg_api_query_trade'
|
10
|
+
|
11
|
+
def query_order(flow_id, vendor_order_id)
|
12
|
+
params = {
|
13
|
+
:TrxId => flow_id,
|
14
|
+
:OrderTrxId => vendor_order_id,
|
15
|
+
:TradeType => 'pay_order',
|
16
|
+
}
|
17
|
+
|
18
|
+
response = Http.post(@partner_id, @private_key, @public_key, @server_uri, SERVICE_NAME, params)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
# 4.4.2.18 快捷代扣请求接口(API)
|
4
|
+
|
5
|
+
module ChanPay
|
6
|
+
module Api
|
7
|
+
module QuickPay
|
8
|
+
|
9
|
+
SERVICE_NAME = 'nmg_api_quickpay_withhold'
|
10
|
+
|
11
|
+
# 快捷代扣
|
12
|
+
#
|
13
|
+
# @param flow_id [String] 订单号(需要保证唯一)
|
14
|
+
# @param card_id [String] 支付银行卡号
|
15
|
+
# @param identity_id [String] 身份证号
|
16
|
+
# @param true_name [String] 真实姓名
|
17
|
+
# @param phone [String] 银行卡预留手机号
|
18
|
+
# @param money [String] 支付金额(单位:元,精确到 2 位小数点)
|
19
|
+
#
|
20
|
+
# @return [Hash] 返回结果集
|
21
|
+
#
|
22
|
+
def quick_pay(flow_id, card_id, identity_id, true_name, phone, money)
|
23
|
+
|
24
|
+
params = {
|
25
|
+
:TrxId => flow_id.to_s, # 最长 32 位唯一订单号
|
26
|
+
:OrdrName => '快捷充值', # 商品名称
|
27
|
+
:SellerId => @seller_id, # 畅捷提供的商户编号
|
28
|
+
:ExpiredTime => '90m', # 订单有效期
|
29
|
+
:BkAcctNo => card_id, # 卡号,需要 rsa 加密
|
30
|
+
:IDTp => '01', # 证件类型,01 身份证
|
31
|
+
:IDNo => identity_id, # 证件号,rsa 加密
|
32
|
+
:CstmrNm => true_name, # 持卡人姓名,rsa 加密
|
33
|
+
:MobNo => phone, # 银行预留手机号,rsa 加密
|
34
|
+
:TradeType => '11', # 交易类型(即时 11 担保 12)
|
35
|
+
:TrxAmt => money.to_s, # 交易金额
|
36
|
+
# 'NotifyUrl' => '', # 异步通知地址,可空
|
37
|
+
# 'Extension' => '', # 扩展字段,可空
|
38
|
+
}
|
39
|
+
|
40
|
+
# 这里是明文参数输出
|
41
|
+
puts "\n[#{SERVICE_NAME}] 请求参数为:\n#{params.inspect}"
|
42
|
+
|
43
|
+
# 敏感字段加密
|
44
|
+
params[:BkAcctNo] = Encrypt::RSA.encrypt(@public_key, card_id)
|
45
|
+
params[:IDNo] = Encrypt::RSA.encrypt(@public_key, identity_id)
|
46
|
+
params[:CstmrNm] = Encrypt::RSA.encrypt(@public_key, true_name)
|
47
|
+
params[:MobNo] = Encrypt::RSA.encrypt(@public_key, phone)
|
48
|
+
|
49
|
+
# api 返回
|
50
|
+
# TrxId, 商户网站唯一订单号, String(32)
|
51
|
+
# OrderTrxId, 畅捷流水号, String(32)
|
52
|
+
# Status, 订单状态, String(2), S:成功,F:失败;P:处理中
|
53
|
+
# RetCode, 业务返回码, String(64)
|
54
|
+
# RetMsg, 返回描述, String (200)
|
55
|
+
# Extension, 扩展字段, String(4000), json格式
|
56
|
+
# 例子:
|
57
|
+
# {:AcceptStatus=>"S",
|
58
|
+
# :InputCharset=>"UTF-8",
|
59
|
+
# :OrderTrxid=>"101150831263182558262",
|
60
|
+
# :PartnerId=>"200001280051",
|
61
|
+
# :RetCode=>"S0001",
|
62
|
+
# :RetMsg=>"受理成功",
|
63
|
+
# :Status=>"S",
|
64
|
+
# :TradeDate=>"20171018",
|
65
|
+
# :TradeTime=>"154354",
|
66
|
+
# :TrxId=>"1508312631562"}
|
67
|
+
response = Http.post(@partner_id, @private_key, @public_key, @server_uri, SERVICE_NAME, params)
|
68
|
+
|
69
|
+
res = {
|
70
|
+
result: 'P', # 默认 pending
|
71
|
+
msg: response[:RetMsg],
|
72
|
+
ret_code: response[:RetCode],
|
73
|
+
flow_id: response[:TrxId],
|
74
|
+
vendor_order_id: response[:OrderTrxid],
|
75
|
+
extension: response[:Extension],
|
76
|
+
log: [params.to_json, response.to_json],
|
77
|
+
}
|
78
|
+
|
79
|
+
# 受理失败 || 受理成功但是结果失败
|
80
|
+
if response[:AcceptStatus] == 'F' || (response[:AcceptStatus] == 'S' && response[:Status] == 'F')
|
81
|
+
res[:result] = 'F'
|
82
|
+
end
|
83
|
+
|
84
|
+
# 受理成功并且结果成功,才是成功
|
85
|
+
if response[:AcceptStatus] == 'S' && response[:Status] == 'S'
|
86
|
+
res[:result] = 'S'
|
87
|
+
end
|
88
|
+
|
89
|
+
res
|
90
|
+
end
|
91
|
+
|
92
|
+
end # module QuickPay
|
93
|
+
end # module Api
|
94
|
+
end # module Chanpay
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
# 客户端
|
4
|
+
|
5
|
+
module ChanPay
|
6
|
+
class Client
|
7
|
+
|
8
|
+
include ChanPay::Api::QuickPay
|
9
|
+
include ChanPay::Api::QueryOrder
|
10
|
+
|
11
|
+
def initialize(options_arg)
|
12
|
+
options = Utils.symbolize_keys(options_arg)
|
13
|
+
|
14
|
+
@partner_id = options[:partner_id]
|
15
|
+
@seller_id = options[:seller_id]
|
16
|
+
@server_uri = URI options[:server_url]
|
17
|
+
@private_key = options[:private_key]
|
18
|
+
@public_key = options[:public_key]
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module ChanPay
|
4
|
+
module Encrypt
|
5
|
+
module RSA
|
6
|
+
|
7
|
+
def self.encrypt(key, content)
|
8
|
+
rsa_pkey = OpenSSL::PKey::RSA.new(key)
|
9
|
+
content_str = rsa_pkey.public_encrypt(content)
|
10
|
+
Base64.strict_encode64(content_str)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
module ChanPay
|
3
|
+
module Http
|
4
|
+
|
5
|
+
VERSION = '1.0'
|
6
|
+
SIGN_TYPE = 'rsa'
|
7
|
+
|
8
|
+
def self.post(partner_id, private_key, public_key, server_uri,
|
9
|
+
service_name, params, time=Time.now)
|
10
|
+
|
11
|
+
body = pack_body(partner_id, private_key, service_name, params, time)
|
12
|
+
|
13
|
+
url_encoded_body = url_encode(body)
|
14
|
+
|
15
|
+
puts "\n[#{service_name}] 发送报文为: \n#{url_encoded_body}\n"
|
16
|
+
|
17
|
+
result = {}
|
18
|
+
|
19
|
+
begin
|
20
|
+
response = Net::HTTP.post_form(server_uri, url_encoded_body)
|
21
|
+
|
22
|
+
if response.is_a?(Net::HTTPSuccess) # 返回 200 才处理
|
23
|
+
result = Utils.symbolize_keys(JSON.parse(response.body))
|
24
|
+
|
25
|
+
unless Sign::RSA.verify?(public_key, result, result[:Sign])
|
26
|
+
# 验签失败, status 状态处于 pending,这样之后再去询问确保
|
27
|
+
result[:AcceptStatus] = 'S'
|
28
|
+
result[:Status] = 'P'
|
29
|
+
end
|
30
|
+
else
|
31
|
+
# 非 200 请求
|
32
|
+
result = RetCode.general_error_response(response.code,
|
33
|
+
RetCode::UNKNOWN_ERROR)
|
34
|
+
end
|
35
|
+
rescue Net::ReadTimeout # 请求超时
|
36
|
+
result = RetCode.general_error_response(0, RetCode::NET_TIMEOUT)
|
37
|
+
end
|
38
|
+
|
39
|
+
puts "\n[#{service_name}] 返回结果为:\n#{result}"
|
40
|
+
|
41
|
+
result
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def self.pack_body(partner_id, private_key, service_name, params, time)
|
47
|
+
header = {
|
48
|
+
:Service => service_name,
|
49
|
+
:Version => VERSION,
|
50
|
+
:PartnerId => partner_id,
|
51
|
+
:InputCharset => 'UTF-8',
|
52
|
+
:TradeDate => time.strftime('%Y%m%d'),
|
53
|
+
:TradeTime => time.strftime('%H%M%S'),
|
54
|
+
}
|
55
|
+
|
56
|
+
body = params.merge(header)
|
57
|
+
sign = Sign::RSA.sign(private_key, body)
|
58
|
+
|
59
|
+
body.merge({:Sign => sign, :SignType => SIGN_TYPE})
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.url_encode(body)
|
63
|
+
arr = {}
|
64
|
+
body.each{ |k, v|
|
65
|
+
str = URI.encode_www_form({"test": v})
|
66
|
+
arr[k] = str[5, str.size]
|
67
|
+
}
|
68
|
+
puts {}
|
69
|
+
arr
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
module ChanPay
|
3
|
+
module Http
|
4
|
+
module RetCode
|
5
|
+
|
6
|
+
UNKNOWN_ERROR = 'UNKNOWN_ERROR'
|
7
|
+
NET_TIMEOUT = 'NET_TIMEOUT'
|
8
|
+
|
9
|
+
def self.general_error_response(http_status, code)
|
10
|
+
{
|
11
|
+
:AcceptStatus => "F", # 业务受理失败
|
12
|
+
:RetCode => code,
|
13
|
+
:RetMsg => "网络异常(#{http_status})",
|
14
|
+
:Status => "F", # 业务失败
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
module ChanPay
|
3
|
+
module Sign
|
4
|
+
module RSA
|
5
|
+
|
6
|
+
def self.sign(key, hash)
|
7
|
+
content = link_hash(hash)
|
8
|
+
rsa = OpenSSL::PKey::RSA.new(key)
|
9
|
+
Base64.strict_encode64(rsa.sign('sha1', content))
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.verify?(key, hash, sign)
|
13
|
+
content = link_hash(hash)
|
14
|
+
rsa = OpenSSL::PKey::RSA.new(key)
|
15
|
+
rsa.verify('sha1', Base64.strict_decode64(sign), content)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def self.link_hash(hash)
|
21
|
+
hash.delete_if do |key, value|
|
22
|
+
key == :Sign || key == :SignType || value.nil? || value == ''
|
23
|
+
end
|
24
|
+
values = []
|
25
|
+
hash.sort.to_h.each{|k,v|
|
26
|
+
values << "#{k}=#{v}"
|
27
|
+
}
|
28
|
+
|
29
|
+
values.join("&")
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
# 通用工具类方法
|
4
|
+
|
5
|
+
module ChanPay
|
6
|
+
module Utils
|
7
|
+
|
8
|
+
# 把 hash 中的 key,都转化为 symbol 类型
|
9
|
+
#
|
10
|
+
# @param hash [Hash] 需要更改的 hash
|
11
|
+
# @return [Hash] 更改后的 hash
|
12
|
+
def self.symbolize_keys(hash)
|
13
|
+
new_hash = {}
|
14
|
+
hash.each do |key, value|
|
15
|
+
new_hash[(key.to_sym rescue key) || key] = value
|
16
|
+
end
|
17
|
+
new_hash
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/chan_pay.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "uri"
|
2
|
+
require "net/http"
|
3
|
+
require "json"
|
4
|
+
require "openssl"
|
5
|
+
require "base64"
|
6
|
+
|
7
|
+
require "chan_pay/version"
|
8
|
+
require "chan_pay/utils"
|
9
|
+
require "chan_pay/sign/rsa"
|
10
|
+
require "chan_pay/encrypt/rsa"
|
11
|
+
require "chan_pay/http/ret_code"
|
12
|
+
require "chan_pay/http/communicate"
|
13
|
+
require "chan_pay/api/quick_pay"
|
14
|
+
require "chan_pay/api/query_order"
|
15
|
+
require "chan_pay/client"
|
16
|
+
|
17
|
+
module ChanPay
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chan_pay
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tony
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: '"畅捷支付"'
|
56
|
+
email:
|
57
|
+
- tony@omniaccount.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- CODE_OF_CONDUCT.md
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- chan_pay.gemspec
|
73
|
+
- lib/chan_pay.rb
|
74
|
+
- lib/chan_pay/api/query_order.rb
|
75
|
+
- lib/chan_pay/api/quick_pay.rb
|
76
|
+
- lib/chan_pay/client.rb
|
77
|
+
- lib/chan_pay/encrypt/rsa.rb
|
78
|
+
- lib/chan_pay/http/communicate.rb
|
79
|
+
- lib/chan_pay/http/ret_code.rb
|
80
|
+
- lib/chan_pay/sign/rsa.rb
|
81
|
+
- lib/chan_pay/utils.rb
|
82
|
+
- lib/chan_pay/version.rb
|
83
|
+
homepage: https://github.com/omniaccountcorp/chan_pay
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata:
|
87
|
+
allowed_push_host: https://rubygems.org
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.4.8
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: '"畅捷支付"'
|
108
|
+
test_files: []
|