cpay 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b537ad5b40e1c55da73bb111ae642c45fb3b15127ee15714f604e2d93ced95dc
4
+ data.tar.gz: 5e90738df6894a9c3247decf84b9a8a14ce98cc762b3971d7b9a05173ceef1f8
5
+ SHA512:
6
+ metadata.gz: 2176d5ac5e95f7dc0543cbb6e7953023974a088cf4c5c56b8470699de495993f2ccae1e7201f88e85d7dc5a2e81aaeda5ebad3c0ec834206f6dfa548e664c4f8
7
+ data.tar.gz: 61e0b016b44e1d31ada5bb1c894cfeece5918dccc09e908bd87c4c33e29adcba860af77d75624a929baa663bba00ea68e4b58726d235166a7441d06343379927
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$" />
8
+ <orderEntry type="inheritedJdk" />
9
+ <orderEntry type="sourceFolder" forTests="false" />
10
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.16.6, rbenv: 2.5.1) [gem]" level="application" />
11
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v5.11.3, rbenv: 2.5.1) [gem]" level="application" />
12
+ </component>
13
+ </module>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptSettings">
4
+ <option name="languageLevel" value="ES6" />
5
+ </component>
6
+ <component name="ProjectRootManager" version="2" project-jdk-name="rbenv: 2.5.1" project-jdk-type="RUBY_SDK" />
7
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/cpay.iml" filepath="$PROJECT_DIR$/.idea/cpay.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,248 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ChangeListManager">
4
+ <list default="true" id="2ea1b7bb-48ba-4e13-84af-7775b8a8e10f" name="Default Changelist" comment="">
5
+ <change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
6
+ <change afterPath="$PROJECT_DIR$/.idea/cpay.iml" afterDir="false" />
7
+ <change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
8
+ <change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
9
+ <change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
10
+ <change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
11
+ <change afterPath="$PROJECT_DIR$/.travis.yml" afterDir="false" />
12
+ <change afterPath="$PROJECT_DIR$/CODE_OF_CONDUCT.md" afterDir="false" />
13
+ <change afterPath="$PROJECT_DIR$/Gemfile" afterDir="false" />
14
+ <change afterPath="$PROJECT_DIR$/LICENSE.txt" afterDir="false" />
15
+ <change afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
16
+ <change afterPath="$PROJECT_DIR$/Rakefile" afterDir="false" />
17
+ <change afterPath="$PROJECT_DIR$/bin/console" afterDir="false" />
18
+ <change afterPath="$PROJECT_DIR$/bin/setup" afterDir="false" />
19
+ <change afterPath="$PROJECT_DIR$/cpay.gemspec" afterDir="false" />
20
+ <change afterPath="$PROJECT_DIR$/lib/cpay.rb" afterDir="false" />
21
+ <change afterPath="$PROJECT_DIR$/lib/cpay/version.rb" afterDir="false" />
22
+ <change afterPath="$PROJECT_DIR$/test/cpay_test.rb" afterDir="false" />
23
+ <change afterPath="$PROJECT_DIR$/test/test_helper.rb" afterDir="false" />
24
+ </list>
25
+ <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
26
+ <option name="SHOW_DIALOG" value="false" />
27
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
28
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
29
+ <option name="LAST_RESOLUTION" value="IGNORE" />
30
+ </component>
31
+ <component name="FUSProjectUsageTrigger">
32
+ <session id="1975939896">
33
+ <usages-collector id="statistics.lifecycle.project">
34
+ <counts>
35
+ <entry key="project.open.time.0" value="1" />
36
+ <entry key="project.opened" value="1" />
37
+ </counts>
38
+ </usages-collector>
39
+ <usages-collector id="statistics.file.extensions.open">
40
+ <counts>
41
+ <entry key="gemspec" value="1" />
42
+ <entry key="md" value="1" />
43
+ <entry key="rb" value="2" />
44
+ </counts>
45
+ </usages-collector>
46
+ <usages-collector id="statistics.file.types.open">
47
+ <counts>
48
+ <entry key="Markdown" value="1" />
49
+ <entry key="Ruby" value="3" />
50
+ </counts>
51
+ </usages-collector>
52
+ <usages-collector id="statistics.file.extensions.edit">
53
+ <counts>
54
+ <entry key="gemspec" value="75" />
55
+ </counts>
56
+ </usages-collector>
57
+ <usages-collector id="statistics.file.types.edit">
58
+ <counts>
59
+ <entry key="Ruby" value="75" />
60
+ </counts>
61
+ </usages-collector>
62
+ </session>
63
+ </component>
64
+ <component name="FileEditorManager">
65
+ <leaf>
66
+ <file pinned="false" current-in-tab="false">
67
+ <entry file="file://$PROJECT_DIR$/lib/cpay.rb">
68
+ <provider selected="true" editor-type-id="text-editor">
69
+ <state relative-caret-position="294">
70
+ <caret line="14" column="22" selection-start-line="14" selection-start-column="22" selection-end-line="14" selection-end-column="22" />
71
+ </state>
72
+ </provider>
73
+ </entry>
74
+ </file>
75
+ <file pinned="false" current-in-tab="false">
76
+ <entry file="file://$PROJECT_DIR$/CODE_OF_CONDUCT.md">
77
+ <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
78
+ <state split_layout="SPLIT">
79
+ <first_editor />
80
+ <second_editor />
81
+ </state>
82
+ </provider>
83
+ </entry>
84
+ </file>
85
+ <file pinned="false" current-in-tab="true">
86
+ <entry file="file://$PROJECT_DIR$/cpay.gemspec">
87
+ <provider selected="true" editor-type-id="text-editor">
88
+ <state relative-caret-position="368">
89
+ <caret line="19" column="63" selection-start-line="19" selection-start-column="63" selection-end-line="19" selection-end-column="63" />
90
+ </state>
91
+ </provider>
92
+ </entry>
93
+ </file>
94
+ </leaf>
95
+ </component>
96
+ <component name="FindInProjectRecents">
97
+ <findStrings>
98
+ <find>homepage_uri</find>
99
+ <find>FIXME</find>
100
+ <find>TODO</find>
101
+ </findStrings>
102
+ </component>
103
+ <component name="Git.Settings">
104
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
105
+ </component>
106
+ <component name="IdeDocumentHistory">
107
+ <option name="CHANGED_PATHS">
108
+ <list>
109
+ <option value="$PROJECT_DIR$/lib/cpay.rb" />
110
+ <option value="$PROJECT_DIR$/cpay.gemspec" />
111
+ </list>
112
+ </option>
113
+ </component>
114
+ <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
115
+ <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
116
+ <component name="JsGulpfileManager">
117
+ <detection-done>true</detection-done>
118
+ <sorting>DEFINITION_ORDER</sorting>
119
+ </component>
120
+ <component name="ProjectFrameBounds" fullScreen="true">
121
+ <option name="width" value="1680" />
122
+ <option name="height" value="1050" />
123
+ </component>
124
+ <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
125
+ <component name="ProjectView">
126
+ <navigator proportions="" version="1">
127
+ <foldersAlwaysOnTop value="true" />
128
+ </navigator>
129
+ <panes>
130
+ <pane id="ProjectPane">
131
+ <subPane>
132
+ <expand>
133
+ <path>
134
+ <item name="cpay" type="b2602c69:ProjectViewProjectNode" />
135
+ <item name="cpay" type="462c0819:PsiDirectoryNode" />
136
+ </path>
137
+ <path>
138
+ <item name="cpay" type="b2602c69:ProjectViewProjectNode" />
139
+ <item name="cpay" type="462c0819:PsiDirectoryNode" />
140
+ <item name="lib" type="462c0819:PsiDirectoryNode" />
141
+ </path>
142
+ <path>
143
+ <item name="cpay" type="b2602c69:ProjectViewProjectNode" />
144
+ <item name="cpay" type="462c0819:PsiDirectoryNode" />
145
+ <item name="lib" type="462c0819:PsiDirectoryNode" />
146
+ <item name="cpay" type="462c0819:PsiDirectoryNode" />
147
+ </path>
148
+ </expand>
149
+ <select />
150
+ </subPane>
151
+ </pane>
152
+ <pane id="Scope" />
153
+ </panes>
154
+ </component>
155
+ <component name="PropertiesComponent">
156
+ <property name="WebServerToolWindowFactoryState" value="false" />
157
+ <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
158
+ <property name="nodejs_npm_path_reset_for_default_project" value="true" />
159
+ </component>
160
+ <component name="RunDashboard">
161
+ <option name="ruleStates">
162
+ <list>
163
+ <RuleState>
164
+ <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
165
+ </RuleState>
166
+ <RuleState>
167
+ <option name="name" value="StatusDashboardGroupingRule" />
168
+ </RuleState>
169
+ </list>
170
+ </option>
171
+ </component>
172
+ <component name="SpringUtil" SPRING_PRE_LOADER_OPTION="true" />
173
+ <component name="SvnConfiguration">
174
+ <configuration />
175
+ </component>
176
+ <component name="TaskManager">
177
+ <task active="true" id="Default" summary="Default task">
178
+ <changelist id="2ea1b7bb-48ba-4e13-84af-7775b8a8e10f" name="Default Changelist" comment="" />
179
+ <created>1540542021525</created>
180
+ <option name="number" value="Default" />
181
+ <option name="presentableId" value="Default" />
182
+ <updated>1540542021525</updated>
183
+ <workItem from="1540542023212" duration="468000" />
184
+ </task>
185
+ <servers />
186
+ </component>
187
+ <component name="TimeTrackingManager">
188
+ <option name="totallyTimeSpent" value="468000" />
189
+ </component>
190
+ <component name="ToolWindowManager">
191
+ <frame x="0" y="0" width="1680" height="1050" extended-state="0" />
192
+ <editor active="true" />
193
+ <layout>
194
+ <window_info id="Favorites" side_tool="true" />
195
+ <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.24969475" />
196
+ <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
197
+ <window_info anchor="bottom" id="Docker" show_stripe_button="false" />
198
+ <window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
199
+ <window_info anchor="bottom" id="Version Control" show_stripe_button="false" />
200
+ <window_info active="true" anchor="bottom" id="Terminal" visible="true" weight="0.32917964" />
201
+ <window_info anchor="bottom" id="Event Log" side_tool="true" />
202
+ <window_info anchor="bottom" id="Message" order="0" />
203
+ <window_info anchor="bottom" id="Find" order="1" />
204
+ <window_info anchor="bottom" id="Run" order="2" weight="0.3219107" />
205
+ <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
206
+ <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
207
+ <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
208
+ <window_info anchor="bottom" id="TODO" order="6" />
209
+ <window_info anchor="right" id="Database" />
210
+ <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
211
+ <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
212
+ <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
213
+ </layout>
214
+ </component>
215
+ <component name="TypeScriptGeneratedFilesManager">
216
+ <option name="version" value="1" />
217
+ </component>
218
+ <component name="VcsContentAnnotationSettings">
219
+ <option name="myLimit" value="2678400000" />
220
+ </component>
221
+ <component name="editorHistoryManager">
222
+ <entry file="file://$PROJECT_DIR$/lib/cpay.rb">
223
+ <provider selected="true" editor-type-id="text-editor">
224
+ <state relative-caret-position="294">
225
+ <caret line="14" column="22" selection-start-line="14" selection-start-column="22" selection-end-line="14" selection-end-column="22" />
226
+ </state>
227
+ </provider>
228
+ </entry>
229
+ <entry file="file://$PROJECT_DIR$/CODE_OF_CONDUCT.md">
230
+ <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
231
+ <state split_layout="SPLIT">
232
+ <first_editor />
233
+ <second_editor />
234
+ </state>
235
+ </provider>
236
+ </entry>
237
+ <entry file="file://$PROJECT_DIR$/lib/cpay/version.rb">
238
+ <provider selected="true" editor-type-id="text-editor" />
239
+ </entry>
240
+ <entry file="file://$PROJECT_DIR$/cpay.gemspec">
241
+ <provider selected="true" editor-type-id="text-editor">
242
+ <state relative-caret-position="368">
243
+ <caret line="19" column="63" selection-start-line="19" selection-start-column="63" selection-end-line="19" selection-end-column="63" />
244
+ </state>
245
+ </provider>
246
+ </entry>
247
+ </component>
248
+ </project>
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 1.16.6
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at chuanci@vip.qq.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in cpay.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 chuanci
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.
@@ -0,0 +1,43 @@
1
+ # Cpay
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/cpay`. 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 'cpay'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install cpay
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 test` 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]/cpay. 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
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Cpay project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/cpay/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cpay"
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(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,42 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "cpay/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cpay"
8
+ spec.version = Cpay::VERSION
9
+ spec.authors = ["chuanci"]
10
+ spec.email = ["chuanci@vip.qq.com"]
11
+
12
+ spec.summary = %q{ Write a short summary, because RubyGems requires one.}
13
+ spec.description = %q{ Write a longer description or delete this line.}
14
+ spec.homepage = "http://gitee.com/chuanci/cpay"
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
+
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = "http://gitee.com/chuanci/cpay"
24
+ spec.metadata["changelog_uri"] = "http://gitee.com/chuanci/cpay"
25
+ else
26
+ raise "RubyGems 2.0 or newer is required to protect against " \
27
+ "public gem pushes."
28
+ end
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ end
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ["lib"]
38
+
39
+ spec.add_development_dependency "bundler", "~> 1.16"
40
+ spec.add_development_dependency "rake", "~> 10.0"
41
+ spec.add_development_dependency "minitest", "~> 5.0"
42
+ end
@@ -0,0 +1,234 @@
1
+ require "cpay/version"
2
+
3
+ module Cpay
4
+ require 'json'
5
+ require 'net/http'
6
+ require 'openssl'
7
+ require 'base64'
8
+
9
+
10
+ module Utils
11
+ extend self
12
+
13
+ def rsa_sign(data, private_key)
14
+ pri = OpenSSL::PKey::RSA.new private_key
15
+ sign = pri.sign('sha1', data.force_encoding('utf-8'))
16
+ Base64.encode64(sign).delete("\n").delete("\r")
17
+ end
18
+
19
+ def rsa_verify(data, sign, public_key)
20
+ pub = OpenSSL::PKey::RSA.new public_key
21
+ digester = OpenSSL::Digest::SHA1.new
22
+ sign = Base64.decode64(sign)
23
+ pub.verify(digester, sign, data)
24
+ end
25
+
26
+ def rsa_encrypt_by_pub(data, public_key)
27
+ pub = OpenSSL::PKey::RSA.new public_key
28
+ Base64.encode64(pub.public_encrypt(data)).delete("\n").delete("\r")
29
+ end
30
+
31
+ def rsa_decrypt_by_pri(data, private_key)
32
+ pri = OpenSSL::PKey::RSA.new private_key
33
+ pri.private_decrypt(Base64.decode64(data))
34
+ end
35
+
36
+ def aes_encrypt(data, key)
37
+ cipher = OpenSSL::Cipher.new 'AES-128-ECB'
38
+ cipher.encrypt
39
+ cipher.key = key
40
+ txt = cipher.update(data) << cipher.final
41
+ Base64.encode64(txt).delete("\n").delete("\r")
42
+ end
43
+
44
+ def aes_decrypt(data, key)
45
+ aes = OpenSSL::Cipher.new('AES-128-ECB')
46
+ aes.decrypt
47
+ aes.key = key
48
+ aes.update(Base64.decode64(data)) + aes.final
49
+ end
50
+
51
+ def url_decode(str)
52
+ str.gsub!(/%[a-fA-F0-9]{2}/) {|x| x = x[1..2].hex.chr}
53
+ end
54
+
55
+ end
56
+
57
+ module Sand
58
+ extend self
59
+
60
+ def quickpay(pay_params)
61
+ =begin
62
+ p = {
63
+ mid: mid,
64
+ privatekey: privatekey,
65
+ userid: userid,
66
+ orderid: orderid,
67
+ amount: amount,
68
+ subject: subject,
69
+ body: body,
70
+ notifyurl: notifyurl,
71
+ fronturl: fronturl,
72
+ }
73
+ =end
74
+ begin
75
+ time = Time.now.strftime('%Y%m%d%H%M%S')
76
+ data = {
77
+ head: {
78
+ version: '1.0',
79
+ method: 'sandPay.fastPay.quickPay.index',
80
+ productId: '00000016',
81
+ accessType: '1',
82
+ mid: pay_params[:mid].to_s,
83
+ channelType: '07',
84
+ reqTime: time
85
+ },
86
+ body: {
87
+ userId: pay_params[:userid].to_s, #用户ID
88
+ orderCode: pay_params[:orderid].to_s, #订单号
89
+ orderTime: time,
90
+ totalAmount: pay_params[:amount].to_s.rjust(12, '0'), #订单金额
91
+ subject: pay_params[:subject].to_s, #订单标题
92
+ body: pay_params[:body].to_s, #订单描述
93
+ currencyCode: 156,
94
+ notifyUrl: pay_params[:notifyurl].to_s, #异步通知地址
95
+ frontUrl: pay_params[:fronturl].to_s, #前端跳转地址
96
+ clearCycle: '0', #清算模式 0:t1 1:T0 2:D0
97
+ extend: ''
98
+ }
99
+ }
100
+ return %Q{
101
+ <form action="https://cashier.sandpay.com.cn/fastPay/quickPay/index" method="post" hidden="hidden">
102
+ <textarea name="charset">utf-8</textarea>
103
+ <textarea name="signType">01</textarea>
104
+ <textarea name="data">#{data.to_json}</textarea>
105
+ <textarea name="sign">#{Utils.rsa_sign(data.to_json, pay_params[:privatekey])}</textarea>
106
+ </form>
107
+ <script type="text/javascript">
108
+ document.forms[0].submit();
109
+ </script>
110
+ }
111
+ rescue Exception => ex
112
+ puts ex.to_s
113
+ return '生成订单出现异常'
114
+ end
115
+ end
116
+
117
+ def quickly_notify?(sign, data, publickey)
118
+ =begin
119
+ return {
120
+ orderid:'12311',
121
+ amount:'1222',
122
+ transid: '23',
123
+ successcode: 'success',
124
+ state: '1',
125
+ }
126
+ =end
127
+ m_res = {
128
+ orderid: '0',
129
+ amount: '0',
130
+ transid: '0',
131
+ successcode: 'success',
132
+ state: -1,
133
+ msg: '',
134
+ }
135
+ begin
136
+ if Utils.rsa_verify(data, sign, publickey)
137
+ data = JSON data
138
+ head = data['head']
139
+ body = data['body']
140
+ if head['respCode'] != '000000' || head['orderStatus'] != '1'
141
+ m_res[:state] = 1
142
+ else
143
+ m_res[:orderid] = body["orderCode"]
144
+ m_res[:transid] = body["tradeNo"]
145
+ m_res[:amount] = body["totalAmount"]
146
+ m_res[:state] = 0
147
+ end
148
+ end
149
+ rescue Exception => ex
150
+ m_res[:msg] = ex.to_s
151
+ end
152
+ m_res
153
+ end
154
+
155
+ def draw(draw_params)
156
+ =begin
157
+ draw_params = {
158
+ orderid: '123', #订单号
159
+ amount: '123', #金额
160
+ accno: '123', #银行卡账号
161
+ accname: '123', #姓名
162
+ remark: '123', #备注
163
+ mid: '123', #杉徳id
164
+ publickey: '123', #杉徳公钥
165
+ privatekey: '123', #杉徳私钥
166
+ }
167
+
168
+ return {
169
+ orderid: '0',
170
+ amount: '0',
171
+ transid: '0',
172
+ successcode: 'success',
173
+ state: -1,
174
+ msg: '',
175
+ }
176
+ =end
177
+ m_res = {
178
+ state: -1,
179
+ msg: '',
180
+ }
181
+
182
+ begin
183
+ uri = URI('https://caspay.sandpay.com.cn/agent-main/openapi/agentpay')
184
+ aes_key = rand(36 ** 16).to_s(36)
185
+
186
+ pt = {
187
+ orderCode: draw_params[:orderid].to_s,
188
+ version: '01',
189
+ productId: '00000004',
190
+ tranTime: Time.now.strftime('%Y%m%d%H%M%S'),
191
+ tranAmt: draw_params[:amount].to_s.rjust(12, '0'),
192
+ currencyCode: '156',
193
+ accAttr: '0',
194
+ accType: '4',
195
+ accNo: draw_params[:accno],
196
+ accName: draw_params[:accname],
197
+ remark: draw_params[:remark],
198
+ # noticeUrl:"#{@@draw_callback_addr}sandpay/draw_notify"
199
+ }
200
+ data = {
201
+ transCode: 'RTPM',
202
+ accessType: '0',
203
+ merId: draw_params[:mid],
204
+ encryptKey: Utils.rsa_encrypt_by_pub(aes_key, draw_params[:publickey]),
205
+ encryptData: Utils.aes_encrypt(pt.to_json, aes_key),
206
+ sign: Utils.rsa_sign(pt.to_json, draw_params[:privatekey]),
207
+ }
208
+ res = Net::HTTP.post_form uri, data
209
+ res_param = {}
210
+ Utils.url_decode(res.body).split('&').each do |str|
211
+ str_split = str.split('=')
212
+ res_param[str_split[0]] = str_split[1]
213
+ end
214
+
215
+ res_data = Utils.aes_decrypt(res_param['encryptData'], Utils.rsa_decrypt_by_pri(res_param['encryptKey'], draw_params[:privatekey]))
216
+
217
+ if Utils.rsa_verify(res_data, res_param['sign'], draw_params[:publickey])
218
+ res_data_json = JSON(res_data)
219
+ m_res[:state] = res_data_json['resultFlag'] # 0出金成功 1出金失败 2处理中,需通过查单确定状态
220
+ m_res[:msg] = res_data_json['respDesc']
221
+ else #验证签名失败,需通过查单确定状态
222
+ m_res[:state] = 2
223
+ end
224
+ rescue Exception => ex
225
+ m_res[:msg] = ex.to_s
226
+ end
227
+ m_res
228
+ end
229
+
230
+ end
231
+
232
+
233
+ end
234
+
@@ -0,0 +1,3 @@
1
+ module Cpay
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cpay
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - chuanci
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-10-26 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
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: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ description: " Write a longer description or delete this line."
56
+ email:
57
+ - chuanci@vip.qq.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".idea/cpay.iml"
64
+ - ".idea/misc.xml"
65
+ - ".idea/modules.xml"
66
+ - ".idea/vcs.xml"
67
+ - ".idea/workspace.xml"
68
+ - ".travis.yml"
69
+ - CODE_OF_CONDUCT.md
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - bin/console
75
+ - bin/setup
76
+ - cpay.gemspec
77
+ - lib/cpay.rb
78
+ - lib/cpay/version.rb
79
+ homepage: http://gitee.com/chuanci/cpay
80
+ licenses:
81
+ - MIT
82
+ metadata:
83
+ allowed_push_host: https://rubygems.org
84
+ homepage_uri: http://gitee.com/chuanci/cpay
85
+ source_code_uri: http://gitee.com/chuanci/cpay
86
+ changelog_uri: http://gitee.com/chuanci/cpay
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.7.6
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Write a short summary, because RubyGems requires one.
107
+ test_files: []