cpay 0.2.0 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 443e256c8b4a184c9e1703034012556f6c90ce304efb5086a7f41b455b600732
4
- data.tar.gz: 839baed22a08fc7dfc64527fcc714b588fe4f8f50cdfd0ff11815c185d4ae515
3
+ metadata.gz: eedd3a154131ea36b5379162c5f61757f24d1813406bb2e61c1b9d16c689edca
4
+ data.tar.gz: d01b9ff5cbf33cf25ec9e919976231f86852cb1f0b9cbb50a2699773e78bc588
5
5
  SHA512:
6
- metadata.gz: eeb29f7e93b34dcbf393f14f9bdec3dbf8fe99f4562f0ee4f5f2298c8af62a2a3a552df415592b85d2c5138ba067643e03445e02e054388f7c55b81bf7bfcfb1
7
- data.tar.gz: 5aafd9f161d9d78ec0c4284f9f5f80a19bbf795fbae1813dca163150a97df9e1d84cecee83ab9bf05b32ba3f8fee19b078f3452f81b93ad8f7577ba81784f754
6
+ metadata.gz: bd8a9930d6c41f4b712e76b90971b82010ad68fe39f13518aec873a7386e119bdef7aafc9a1c070384e6f77d6b993da41ad962bc51f343abd922d4569d5623f6
7
+ data.tar.gz: '084f38fb2f1d1ef0e3efe423ccc263e5721ede87de2ba95d68821e23240e3b6706f3699d8de545ba1139eb1894fe3d3e770cbf7ec62f8935c665eabdaa6227e8'
@@ -29,7 +29,21 @@
29
29
  <option name="LAST_RESOLUTION" value="IGNORE" />
30
30
  </component>
31
31
  <component name="CoverageDataManager">
32
- <SUITE FILE_PATH="coverage/cpay@test_it_does_something_useful__cpay.rcov" NAME="test_it_does_something_useful: cpay Coverage Results" MODIFIED="1540553859030" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="cpay" />
32
+ <SUITE FILE_PATH="coverage/cpay@test_it_does_something_useful__cpay.rcov" NAME="test_it_does_something_useful: cpay Coverage Results" MODIFIED="1540604257818" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="cpay" />
33
+ </component>
34
+ <component name="DatabaseView">
35
+ <option name="SHOW_INTERMEDIATE" value="true" />
36
+ <option name="GROUP_DATA_SOURCES" value="true" />
37
+ <option name="GROUP_SCHEMA" value="true" />
38
+ <option name="GROUP_CONTENTS" value="false" />
39
+ <option name="SORT_POSITIONED" value="false" />
40
+ <option name="SHOW_EMPTY_GROUPS" value="false" />
41
+ <option name="AUTO_SCROLL_FROM_SOURCE" value="false" />
42
+ <option name="HIDDEN_KINDS">
43
+ <set />
44
+ </option>
45
+ <expand />
46
+ <select />
33
47
  </component>
34
48
  <component name="FUSProjectUsageTrigger">
35
49
  <session id="1975939896">
@@ -41,26 +55,35 @@
41
55
  </usages-collector>
42
56
  <usages-collector id="statistics.file.extensions.open">
43
57
  <counts>
44
- <entry key="gemspec" value="1" />
45
- <entry key="md" value="1" />
46
- <entry key="rb" value="8" />
58
+ <entry key="Gemfile" value="1" />
59
+ <entry key="Rakefile" value="1" />
60
+ <entry key="gemspec" value="3" />
61
+ <entry key="gitignore" value="1" />
62
+ <entry key="md" value="3" />
63
+ <entry key="rb" value="10" />
64
+ <entry key="txt" value="1" />
65
+ <entry key="yml" value="1" />
47
66
  </counts>
48
67
  </usages-collector>
49
68
  <usages-collector id="statistics.file.types.open">
50
69
  <counts>
51
- <entry key="Markdown" value="1" />
52
- <entry key="Ruby" value="9" />
70
+ <entry key="Markdown" value="3" />
71
+ <entry key="PLAIN_TEXT" value="2" />
72
+ <entry key="Ruby" value="15" />
73
+ <entry key="YAML" value="1" />
53
74
  </counts>
54
75
  </usages-collector>
55
76
  <usages-collector id="statistics.file.extensions.edit">
56
77
  <counts>
57
- <entry key="gemspec" value="75" />
58
- <entry key="rb" value="2019" />
78
+ <entry key="gemspec" value="82" />
79
+ <entry key="md" value="1307" />
80
+ <entry key="rb" value="2936" />
59
81
  </counts>
60
82
  </usages-collector>
61
83
  <usages-collector id="statistics.file.types.edit">
62
84
  <counts>
63
- <entry key="Ruby" value="2094" />
85
+ <entry key="Markdown" value="1116" />
86
+ <entry key="Ruby" value="3209" />
64
87
  </counts>
65
88
  </usages-collector>
66
89
  <usages-collector id="statistics.js.language.service.starts" />
@@ -70,47 +93,56 @@
70
93
  </component>
71
94
  <component name="FileEditorManager">
72
95
  <leaf>
73
- <file pinned="false" current-in-tab="false">
74
- <entry file="file://$USER_HOME$/.rbenv/versions/2.5.1/lib/ruby/2.5.0/cgi/core.rb">
96
+ <file pinned="false" current-in-tab="true">
97
+ <entry file="file://$PROJECT_DIR$/test/cpay_test.rb">
75
98
  <provider selected="true" editor-type-id="text-editor">
76
- <state relative-caret-position="-165">
77
- <caret line="383" selection-start-line="383" selection-end-line="383" />
99
+ <state relative-caret-position="76">
100
+ <caret line="9" lean-forward="true" selection-start-line="9" selection-end-line="9" />
78
101
  </state>
79
102
  </provider>
80
103
  </entry>
81
104
  </file>
82
105
  <file pinned="false" current-in-tab="false">
83
- <entry file="file://$PROJECT_DIR$/test/cpay_test.rb">
84
- <provider selected="true" editor-type-id="text-editor">
85
- <state relative-caret-position="1617">
86
- <caret line="77" column="32" selection-start-line="77" selection-start-column="32" selection-end-line="77" selection-end-column="32" />
87
- </state>
88
- </provider>
106
+ <entry file="file://$PROJECT_DIR$/Gemfile">
107
+ <provider selected="true" editor-type-id="text-editor" />
89
108
  </entry>
90
109
  </file>
91
110
  <file pinned="false" current-in-tab="false">
92
- <entry file="file://$USER_HOME$/.rbenv/versions/2.5.1/lib/ruby/2.5.0/json/common.rb">
93
- <provider selected="true" editor-type-id="text-editor">
94
- <state relative-caret-position="196">
95
- <caret line="223" selection-start-line="223" selection-end-line="223" />
111
+ <entry file="file://$PROJECT_DIR$/LICENSE.txt">
112
+ <provider selected="true" editor-type-id="text-editor" />
113
+ </entry>
114
+ </file>
115
+ <file pinned="false" current-in-tab="false">
116
+ <entry file="file://$PROJECT_DIR$/Rakefile">
117
+ <provider selected="true" editor-type-id="text-editor" />
118
+ </entry>
119
+ </file>
120
+ <file pinned="false" current-in-tab="false">
121
+ <entry file="file://$PROJECT_DIR$/README.md">
122
+ <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
123
+ <state split_layout="SPLIT">
124
+ <first_editor relative-caret-position="605">
125
+ <caret line="173" column="11" selection-start-line="173" selection-start-column="11" selection-end-line="173" selection-end-column="11" />
126
+ </first_editor>
127
+ <second_editor />
96
128
  </state>
97
129
  </provider>
98
130
  </entry>
99
131
  </file>
100
132
  <file pinned="false" current-in-tab="false">
101
- <entry file="file://$PROJECT_DIR$/cpay.gemspec">
133
+ <entry file="file://$PROJECT_DIR$/lib/cpay/version.rb">
102
134
  <provider selected="true" editor-type-id="text-editor">
103
- <state relative-caret-position="179">
104
- <caret line="10" lean-forward="true" selection-start-line="10" selection-end-line="10" />
135
+ <state relative-caret-position="21">
136
+ <caret line="1" column="18" selection-start-line="1" selection-start-column="18" selection-end-line="1" selection-end-column="18" />
105
137
  </state>
106
138
  </provider>
107
139
  </entry>
108
140
  </file>
109
- <file pinned="false" current-in-tab="true">
110
- <entry file="file://$PROJECT_DIR$/lib/cpay/version.rb">
141
+ <file pinned="false" current-in-tab="false">
142
+ <entry file="file://$PROJECT_DIR$/lib/cpay.rb">
111
143
  <provider selected="true" editor-type-id="text-editor">
112
- <state relative-caret-position="21">
113
- <caret line="1" column="16" selection-start-line="1" selection-start-column="16" selection-end-line="1" selection-end-column="16" />
144
+ <state relative-caret-position="325">
145
+ <caret line="247" column="58" selection-start-line="247" selection-start-column="44" selection-end-line="247" selection-end-column="58" />
114
146
  </state>
115
147
  </provider>
116
148
  </entry>
@@ -125,6 +157,8 @@
125
157
  <find>FIXME</find>
126
158
  <find>url_decode</find>
127
159
  <find>gsub</find>
160
+ <find>Write a longer description or delete this line</find>
161
+ <find>orderQuery</find>
128
162
  </findStrings>
129
163
  </component>
130
164
  <component name="Git.Settings">
@@ -135,8 +169,9 @@
135
169
  <list>
136
170
  <option value="$PROJECT_DIR$/cpay.gemspec" />
137
171
  <option value="$PROJECT_DIR$/lib/cpay.rb" />
138
- <option value="$PROJECT_DIR$/test/cpay_test.rb" />
172
+ <option value="$PROJECT_DIR$/README.md" />
139
173
  <option value="$PROJECT_DIR$/lib/cpay/version.rb" />
174
+ <option value="$PROJECT_DIR$/test/cpay_test.rb" />
140
175
  </list>
141
176
  </option>
142
177
  </component>
@@ -250,44 +285,44 @@
250
285
  <option name="number" value="Default" />
251
286
  <option name="presentableId" value="Default" />
252
287
  <updated>1540542021525</updated>
253
- <workItem from="1540542023212" duration="10096000" />
288
+ <workItem from="1540542023212" duration="19905000" />
254
289
  </task>
255
290
  <servers />
256
291
  </component>
257
292
  <component name="TestHistory">
258
- <history-entry file="test_it_does_something_useful__cpay - 2018.10.26 at 19h 28m 58s.xml">
293
+ <history-entry file="test_it_does_something_useful__cpay - 2018.10.27 at 09h 29m 33s.xml">
259
294
  <configuration name="test_it_does_something_useful: cpay" configurationId="TestUnitRunConfigurationType" />
260
295
  </history-entry>
261
- <history-entry file="test_it_does_something_useful__cpay - 2018.10.26 at 19h 29m 12s.xml">
296
+ <history-entry file="test_it_does_something_useful__cpay - 2018.10.27 at 09h 30m 17s.xml">
262
297
  <configuration name="test_it_does_something_useful: cpay" configurationId="TestUnitRunConfigurationType" />
263
298
  </history-entry>
264
- <history-entry file="test_it_does_something_useful__cpay - 2018.10.26 at 19h 29m 24s.xml">
299
+ <history-entry file="test_it_does_something_useful__cpay - 2018.10.27 at 09h 31m 08s.xml">
265
300
  <configuration name="test_it_does_something_useful: cpay" configurationId="TestUnitRunConfigurationType" />
266
301
  </history-entry>
267
- <history-entry file="test_it_does_something_useful__cpay - 2018.10.26 at 19h 29m 58s.xml">
302
+ <history-entry file="test_it_does_something_useful__cpay - 2018.10.27 at 09h 31m 40s.xml">
268
303
  <configuration name="test_it_does_something_useful: cpay" configurationId="TestUnitRunConfigurationType" />
269
304
  </history-entry>
270
- <history-entry file="test_it_does_something_useful__cpay - 2018.10.26 at 19h 30m 12s.xml">
305
+ <history-entry file="test_it_does_something_useful__cpay - 2018.10.27 at 09h 31m 52s.xml">
271
306
  <configuration name="test_it_does_something_useful: cpay" configurationId="TestUnitRunConfigurationType" />
272
307
  </history-entry>
273
- <history-entry file="test_it_does_something_useful__cpay - 2018.10.26 at 19h 32m 44s.xml">
308
+ <history-entry file="test_it_does_something_useful__cpay - 2018.10.27 at 09h 35m 20s.xml">
274
309
  <configuration name="test_it_does_something_useful: cpay" configurationId="TestUnitRunConfigurationType" />
275
310
  </history-entry>
276
- <history-entry file="test_it_does_something_useful__cpay - 2018.10.26 at 19h 33m 02s.xml">
311
+ <history-entry file="test_it_does_something_useful__cpay - 2018.10.27 at 09h 35m 27s.xml">
277
312
  <configuration name="test_it_does_something_useful: cpay" configurationId="TestUnitRunConfigurationType" />
278
313
  </history-entry>
279
- <history-entry file="test_it_does_something_useful__cpay - 2018.10.26 at 19h 33m 20s.xml">
314
+ <history-entry file="test_it_does_something_useful__cpay - 2018.10.27 at 09h 35m 59s.xml">
280
315
  <configuration name="test_it_does_something_useful: cpay" configurationId="TestUnitRunConfigurationType" />
281
316
  </history-entry>
282
- <history-entry file="test_it_does_something_useful__cpay - 2018.10.26 at 19h 37m 16s.xml">
317
+ <history-entry file="test_it_does_something_useful__cpay - 2018.10.27 at 09h 37m 09s.xml">
283
318
  <configuration name="test_it_does_something_useful: cpay" configurationId="TestUnitRunConfigurationType" />
284
319
  </history-entry>
285
- <history-entry file="test_it_does_something_useful__cpay - 2018.10.26 at 19h 37m 39s.xml">
320
+ <history-entry file="test_it_does_something_useful__cpay - 2018.10.27 at 09h 37m 38s.xml">
286
321
  <configuration name="test_it_does_something_useful: cpay" configurationId="TestUnitRunConfigurationType" />
287
322
  </history-entry>
288
323
  </component>
289
324
  <component name="TimeTrackingManager">
290
- <option name="totallyTimeSpent" value="10096000" />
325
+ <option name="totallyTimeSpent" value="19905000" />
291
326
  </component>
292
327
  <component name="ToolWindowManager">
293
328
  <frame x="0" y="0" width="1680" height="1050" extended-state="0" />
@@ -308,7 +343,7 @@
308
343
  <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
309
344
  <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
310
345
  <window_info anchor="bottom" id="TODO" order="6" />
311
- <window_info anchor="right" id="Database" />
346
+ <window_info anchor="right" id="Database" weight="0.32967034" />
312
347
  <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
313
348
  <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
314
349
  <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
@@ -324,14 +359,6 @@
324
359
  <entry file="file://$PROJECT_DIR$/test/test_helper.rb">
325
360
  <provider selected="true" editor-type-id="text-editor" />
326
361
  </entry>
327
- <entry file="file://$PROJECT_DIR$/CODE_OF_CONDUCT.md">
328
- <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
329
- <state split_layout="SPLIT">
330
- <first_editor />
331
- <second_editor />
332
- </state>
333
- </provider>
334
- </entry>
335
362
  <entry file="file://$USER_HOME$/.rbenv/versions/2.5.1/lib/ruby/2.5.0/json/common.rb">
336
363
  <provider selected="true" editor-type-id="text-editor">
337
364
  <state relative-caret-position="196">
@@ -339,13 +366,6 @@
339
366
  </state>
340
367
  </provider>
341
368
  </entry>
342
- <entry file="file://$PROJECT_DIR$/cpay.gemspec">
343
- <provider selected="true" editor-type-id="text-editor">
344
- <state relative-caret-position="179">
345
- <caret line="10" lean-forward="true" selection-start-line="10" selection-end-line="10" />
346
- </state>
347
- </provider>
348
- </entry>
349
369
  <entry file="file://$USER_HOME$/.rbenv/versions/2.5.1/lib/ruby/2.5.0/base64.rb">
350
370
  <provider selected="true" editor-type-id="text-editor">
351
371
  <state relative-caret-position="203">
@@ -353,31 +373,71 @@
353
373
  </state>
354
374
  </provider>
355
375
  </entry>
356
- <entry file="file://$PROJECT_DIR$/lib/cpay.rb">
376
+ <entry file="file://$USER_HOME$/.rbenv/versions/2.5.1/lib/ruby/2.5.0/cgi/core.rb">
357
377
  <provider selected="true" editor-type-id="text-editor">
358
- <state relative-caret-position="298">
359
- <caret line="88" column="35" lean-forward="true" selection-start-line="88" selection-start-column="35" selection-end-line="88" selection-end-column="35" />
378
+ <state relative-caret-position="-165">
379
+ <caret line="383" selection-start-line="383" selection-end-line="383" />
360
380
  </state>
361
381
  </provider>
362
382
  </entry>
363
- <entry file="file://$USER_HOME$/.rbenv/versions/2.5.1/lib/ruby/2.5.0/cgi/core.rb">
383
+ <entry file="file://$PROJECT_DIR$/CODE_OF_CONDUCT.md">
384
+ <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
385
+ <state split_layout="SPLIT">
386
+ <first_editor relative-caret-position="-1102" />
387
+ <second_editor />
388
+ </state>
389
+ </provider>
390
+ </entry>
391
+ <entry file="file://$PROJECT_DIR$/.travis.yml">
392
+ <provider selected="true" editor-type-id="text-editor" />
393
+ </entry>
394
+ <entry file="file://$PROJECT_DIR$/.gitignore">
395
+ <provider selected="true" editor-type-id="text-editor" />
396
+ </entry>
397
+ <entry file="file://$PROJECT_DIR$/LICENSE.txt">
398
+ <provider selected="true" editor-type-id="text-editor" />
399
+ </entry>
400
+ <entry file="file://$PROJECT_DIR$/Gemfile">
401
+ <provider selected="true" editor-type-id="text-editor" />
402
+ </entry>
403
+ <entry file="file://$PROJECT_DIR$/cpay.gemspec">
364
404
  <provider selected="true" editor-type-id="text-editor">
365
- <state relative-caret-position="-165">
366
- <caret line="383" selection-start-line="383" selection-end-line="383" />
405
+ <state relative-caret-position="420">
406
+ <caret line="20" lean-forward="true" selection-start-line="20" selection-end-line="20" />
367
407
  </state>
368
408
  </provider>
369
409
  </entry>
370
- <entry file="file://$PROJECT_DIR$/test/cpay_test.rb">
410
+ <entry file="file://$PROJECT_DIR$/Rakefile">
411
+ <provider selected="true" editor-type-id="text-editor" />
412
+ </entry>
413
+ <entry file="file://$PROJECT_DIR$/lib/cpay.rb">
371
414
  <provider selected="true" editor-type-id="text-editor">
372
- <state relative-caret-position="1617">
373
- <caret line="77" column="32" selection-start-line="77" selection-start-column="32" selection-end-line="77" selection-end-column="32" />
415
+ <state relative-caret-position="325">
416
+ <caret line="247" column="58" selection-start-line="247" selection-start-column="44" selection-end-line="247" selection-end-column="58" />
417
+ </state>
418
+ </provider>
419
+ </entry>
420
+ <entry file="file://$PROJECT_DIR$/README.md">
421
+ <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
422
+ <state split_layout="SPLIT">
423
+ <first_editor relative-caret-position="605">
424
+ <caret line="173" column="11" selection-start-line="173" selection-start-column="11" selection-end-line="173" selection-end-column="11" />
425
+ </first_editor>
426
+ <second_editor />
374
427
  </state>
375
428
  </provider>
376
429
  </entry>
377
430
  <entry file="file://$PROJECT_DIR$/lib/cpay/version.rb">
378
431
  <provider selected="true" editor-type-id="text-editor">
379
432
  <state relative-caret-position="21">
380
- <caret line="1" column="16" selection-start-line="1" selection-start-column="16" selection-end-line="1" selection-end-column="16" />
433
+ <caret line="1" column="18" selection-start-line="1" selection-start-column="18" selection-end-line="1" selection-end-column="18" />
434
+ </state>
435
+ </provider>
436
+ </entry>
437
+ <entry file="file://$PROJECT_DIR$/test/cpay_test.rb">
438
+ <provider selected="true" editor-type-id="text-editor">
439
+ <state relative-caret-position="76">
440
+ <caret line="9" lean-forward="true" selection-start-line="9" selection-end-line="9" />
381
441
  </state>
382
442
  </provider>
383
443
  </entry>
data/README.md CHANGED
@@ -1,9 +1,5 @@
1
1
  # Cpay
2
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
3
  ## Installation
8
4
 
9
5
  Add this line to your application's Gemfile:
@@ -22,17 +18,163 @@ Or install it yourself as:
22
18
 
23
19
  ## Usage
24
20
 
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.
21
+ ### 杉徳支付
22
+ ```ruby
23
+ #通用返回
24
+ {
25
+ code: 0,
26
+ # -1,代码出现异常,msg中显示异常信息
27
+ # 0, 返回正常数据data
28
+ # 2,签名验证错误
29
+ msg: '',
30
+ data: {},
31
+ # 杉徳返回数据,参照杉徳文档使用
32
+ cpay:{
33
+ ok: true,
34
+ # true为成功,
35
+ # false为非成功,例:多次查询订单会返回
36
+ # "respCode"=>"030096"(该订单查询次数超限,请稍后重试),
37
+ # 此时ok为false
38
+ msg: '',
39
+
40
+ }
41
+ # 辅助判断
42
+ }
30
43
 
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).
44
+ ```
45
+ #### 快捷支付
46
+ - 支付*
47
+
48
+ ```ruby
49
+ p = {
50
+ mid: mid,#商户id
51
+ privatekey: privatekey,#私钥
52
+ userid: userid,#用户id
53
+ orderid: orderid,#订单id
54
+ amount: amount,#订单金额
55
+ subject: subject,#订单标题
56
+ body: body,#订单描述
57
+ notifyurl: notifyurl,#异步通知地址(需报备)
58
+ fronturl: fronturl,#跳转地址
59
+ }
60
+ ret = Cpay::Sand::Fastpay.pay(p)
61
+ # 将ret显示到网页中
62
+
63
+ ```
64
+ - 回调
65
+ ```ruby
66
+ p = {
67
+ sign: sign, #回调sign
68
+ data: data, #回调data
69
+ publickey: publickey, #公钥
70
+ }
71
+ ret = Cpay::Sand::Fastpay.notify(p)
72
+ ```
73
+ - 查单
74
+ ```ruby
75
+ p = {
76
+ orderid: orderid, #订单号
77
+ mid: mid, #商户id
78
+ publickey: publickey, #公钥
79
+ privatekey: privatekey, #私钥
80
+ }
81
+ ret = Cpay::Sand::Fastpay.queryOrder(p)
82
+ #-----------------------------------------
83
+ if ret[:cpay][:next]
84
+ #(该订单查询次数超限,请稍后重试)需稍后再次请求
85
+ else
86
+ if ret[:cpay][:ok]
87
+ #订单成功
88
+ else
89
+ #订单未成功
90
+ end
91
+
92
+ end
93
+ #-----------------------------------------
94
+ if ret[:data]['head']['respCode'] == '000000'
95
+ if ret[:data]['body']['orderStatus'] == '00'
96
+ #订单成功
97
+ elsif ret[:data]['body']['orderStatus'] == '01'
98
+ #订单生成,未支付
99
+ elsif ret[:data]['body']['orderStatus'] == '02'
100
+ #失败
101
+ elsif ret[:data]['body']['orderStatus'] == '04'
102
+ #已退货
103
+ elsif ret[:data]['body']['orderStatus'] == '05'
104
+ #退款处理中
105
+ else
106
+ end
107
+ else
108
+ # 未请求到订单状态
109
+ end
110
+
111
+
112
+ ```
32
113
 
33
- ## Contributing
114
+ #### 代付
34
115
 
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.
116
+ - 代付
117
+ ```ruby
118
+ p = {
119
+ orderid: orderid, #订单号
120
+ amount: amount, #金额
121
+ accno: accno, #银行卡账号
122
+ accname: accname, #姓名
123
+ remark: remark, #备注
124
+ mid: mid, #商户id
125
+ publickey: publickey, #公钥
126
+ privatekey: privatekey, #私钥
127
+ }
128
+ ret = Cpay::Sand::Draw.agentpay(p)
129
+ #-----------------------------------------
130
+ if ret[:cpay][:ok]
131
+ #代付成功
132
+ else
133
+ #代付未成功
134
+ end
135
+ #-----------------------------------------
136
+ if ret[:data]['resultFlag']=='0'
137
+ #代付成功
138
+ elsif ret[:data]['resultFlag']=='1'
139
+ #代付成功
140
+ else
141
+ # 状态不明
142
+ end
143
+ ```
144
+ - 查询余额
145
+ ```ruby
146
+ p = {
147
+ orderid: orderid, #订单号
148
+ mid: mid, #商户id
149
+ publickey: publickey, #公钥
150
+ privatekey: privatekey, #私钥
151
+ }
152
+ ret = Cpay::Sand::Draw.queryBalance(p)
153
+ #-----------------------------------------
154
+ if ret[:cpay][:ok]
155
+ balance = ret[:cpay][:msg]
156
+ end
157
+
158
+ ```
159
+ - 代付订单查询
160
+ ```ruby
161
+ p={
162
+ orderid: orderid, #订单号
163
+ mid: mid, #商户id
164
+ tranTime: tranTime, #代付订单日期 '%Y%m%d%H%M%S'
165
+ publickey: publickey, #公钥
166
+ privatekey: privatekey, #私钥
167
+ }
168
+ ret = Cpay::Sand::Draw.queryOrder(p)
169
+ #-----------------------------------------
170
+ if ret[:cpay][:next]
171
+ if ret[:cpay][:ok]
172
+ #成功
173
+ else
174
+ #失败
175
+ end
176
+ end
177
+ ```
36
178
 
37
179
  ## License
38
180
 
@@ -95,7 +95,7 @@ module Cpay
95
95
 
96
96
  end
97
97
 
98
- def quickly_notify?(sign, data, publickey)
98
+ def notify(c_params)
99
99
  =begin
100
100
  return {
101
101
  orderid:'12311',
@@ -105,35 +105,36 @@ return {
105
105
  state: '1',
106
106
  }
107
107
  =end
108
- m_res = {
109
- orderid: '0',
110
- amount: '0',
111
- transid: '0',
112
- successcode: 'success',
113
- state: -1,
108
+ sign = c_params[:sign]
109
+ data = c_params[:data]
110
+ publickey = c_params[:publickey]
111
+ ret = {
112
+ code: -1,
114
113
  msg: '',
114
+ data: {}
115
115
  }
116
116
  begin
117
117
  if Utils.rsa_verify(data, sign, publickey)
118
118
  data = JSON data
119
- head = data['head']
120
- body = data['body']
121
- if head['respCode'] != '000000' || head['orderStatus'] != '1'
122
- m_res[:state] = 1
123
- else
124
- m_res[:orderid] = body["orderCode"]
125
- m_res[:transid] = body["tradeNo"]
126
- m_res[:amount] = body["totalAmount"]
127
- m_res[:state] = 0
128
- end
119
+ ret[:data] = data
120
+ ret[:code] = 0
121
+
122
+ ret[:cpay] = {
123
+ ok: data['body']['orderStatus'] == '1',
124
+ msg: '',
125
+ next: data['head']['respCode'] != '000000',
126
+ }
127
+ else
128
+ ret[:code] = 2
129
129
  end
130
130
  rescue Exception => ex
131
- m_res[:msg] = ex.to_s
131
+ ret[:msg] = ex.to_s
132
+ ret[:code] = -1
132
133
  end
133
- m_res
134
+ ret
134
135
  end
135
136
 
136
- def orderQuery(c_params)
137
+ def queryOrder(c_params)
137
138
  b_params = {
138
139
  body: {
139
140
  orderCode: c_params[:orderid].to_s, #订单号
@@ -142,7 +143,13 @@ return {
142
143
  uri: URI("https://cashier.sandpay.com.cn/gateway/api/order/query")
143
144
 
144
145
  }
145
- base_pay_act b_params, c_params, false
146
+ ret = base_pay_act b_params, c_params, false
147
+ ret[:cpay] = {
148
+ next: ret[:data]['head']['respCode'] == '030096',
149
+ ok: ret[:data]['body']['oriRespCode'] == '000000' && ret[:data]['body']['orderStatus'] == '00',
150
+ msg: ret[:data]['oriRespMsg']
151
+ }
152
+ ret
146
153
  end
147
154
 
148
155
  private
@@ -187,7 +194,7 @@ return {
187
194
  ret[:code] = 2
188
195
  else
189
196
  ret[:code] = 0
190
- ret[:data] = JSON(cgi_parse['data'][0])['head']
197
+ ret[:data] = JSON(cgi_parse['data'][0])
191
198
  end
192
199
  end
193
200
  rescue Exception => ex
@@ -195,8 +202,6 @@ return {
195
202
  ret[:code] = -1
196
203
  end
197
204
  ret
198
-
199
-
200
205
  end
201
206
 
202
207
  end
@@ -205,13 +210,14 @@ return {
205
210
  extend self
206
211
 
207
212
  def agentpay(c_params)
213
+ tranTime = Time.now.strftime('%Y%m%d%H%M%S')
208
214
  b_params = {
209
215
  uri: URI("https://caspay.sandpay.com.cn/agent-main/openapi/agentpay"),
210
216
  pt: {
211
217
  orderCode: c_params[:orderid].to_s,
212
218
  version: '01',
213
219
  productId: '00000004',
214
- tranTime: Time.now.strftime('%Y%m%d%H%M%S'),
220
+ tranTime: tranTime,
215
221
  tranAmt: c_params[:amount].to_s.rjust(12, '0'),
216
222
  currencyCode: '156',
217
223
  accAttr: '0',
@@ -223,21 +229,16 @@ return {
223
229
  transCode: 'RTPM',
224
230
  }
225
231
 
226
- base_draw_act b_params, c_params
227
-
228
-
229
- # if sand_res[:sign?]
230
- # sand_res_data = sand_res[:data]
231
- # res[:state] = sand_res_data['resultFlag']
232
- # res[:msg] = sand_res_data['respDesc']
233
- # else
234
- # res[:state] = 2
235
- # end
236
-
232
+ ret = base_draw_act b_params, c_params
233
+ ret[:cpay] = {
234
+ msg: ret[:data]['resultFlag'] == '0' ? "订单成功" : (ret[:data]['resultFlag'] == '1' ? "订单失败" : "处理中,需通过查单接口查询订单状态。"),
235
+ ok: ret[:data]['resultFlag'] == '0',
236
+ tranTime: tranTime
237
+ }
238
+ ret
237
239
  end
238
240
 
239
241
  def queryBalance(c_params)
240
-
241
242
  b_params = {
242
243
  uri: URI("https://caspay.sandpay.com.cn/agent-main/openapi/queryBalance"),
243
244
  pt: {
@@ -249,7 +250,13 @@ return {
249
250
  transCode: 'MBQU',
250
251
  }
251
252
 
252
- base_draw_act b_params, c_params
253
+ ret = base_draw_act b_params, c_params
254
+ ret[:cpay] = {
255
+ ok: ret[:data]['respCode'] == '0000',
256
+ msg: ret[:data]['balance'].to_i
257
+ }
258
+ ret
259
+
253
260
  end
254
261
 
255
262
  def queryOrder c_params
@@ -259,12 +266,17 @@ return {
259
266
  orderCode: c_params[:orderid].to_s,
260
267
  version: '01',
261
268
  productId: '00000004',
262
- tranTime: Time.now.strftime('%Y%m%d%H%M%S'),
269
+ tranTime: c_params[:tranTime],
263
270
  },
264
271
  transCode: 'ODQU',
265
272
  }
266
-
267
- base_draw_act b_params, c_params
273
+ ret = base_draw_act b_params, c_params
274
+ ret[:cpay] = {
275
+ ok: ret[:data]['resultFlag'] == '0',
276
+ next: ret[:data]['respCode'] != '0000' || ret[:data]['resultFlag'] == '2',
277
+ msg: ''
278
+ }
279
+ ret
268
280
  end
269
281
 
270
282
  private
@@ -280,7 +292,7 @@ return {
280
292
 
281
293
  uri = b_params[:uri]
282
294
  pt = b_params[:pt]
283
- aes_key = rand(36 ** 16).to_s(36)
295
+ aes_key = rand(36 ** 16).to_s(36).rjust(16, '0')
284
296
  data = {
285
297
  transCode: b_params[:transCode],
286
298
  accessType: '0',
@@ -289,6 +301,7 @@ return {
289
301
  encryptData: Utils.aes_encrypt(pt.to_json, aes_key),
290
302
  sign: Utils.rsa_sign(pt.to_json, c_params[:privatekey]),
291
303
  }
304
+ puts data
292
305
  res = Net::HTTP.post_form uri, data
293
306
  res_param = {}
294
307
  body = res.body
@@ -1,3 +1,3 @@
1
1
  module Cpay
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - chuanci
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-26 00:00:00.000000000 Z
11
+ date: 2018-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler