adapay 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7656d2c7d5ae26c68f1f6ac9625d44331ba36d258ec59f69c064a68200437b44
4
+ data.tar.gz: a4e47fb1654d77c8d8eafaf13483c23b2e16ff9ac149c8f7df7dc9cd9d16e277
5
+ SHA512:
6
+ metadata.gz: 0eac2f1adb7e1321f10f32a081b6e3aa9c9a50186612ac04f216b29b582af61c0d6b3ea5abafd73db8ac3dfdaf46aa0df40135ec1a98d8d201d1d8135e58484e
7
+ data.tar.gz: f46342c812521345719cc687ca969779f70d58858dcbb1a5571eaceeb90f7763088759be4d453c77708ac884a46f0aad9743f8b086c02f572d91b42e168ad57a
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.2
6
+ before_install: gem install bundler -v 2.1.4
@@ -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 lanzhihengrj@gmail.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 [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in adapay.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 12.0'
9
+ gem 'rspec', '~> 3.0'
data/Gemfile.lock ADDED
@@ -0,0 +1,34 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ adapay (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.5.0)
10
+ rake (12.3.3)
11
+ rspec (3.11.0)
12
+ rspec-core (~> 3.11.0)
13
+ rspec-expectations (~> 3.11.0)
14
+ rspec-mocks (~> 3.11.0)
15
+ rspec-core (3.11.0)
16
+ rspec-support (~> 3.11.0)
17
+ rspec-expectations (3.11.0)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.11.0)
20
+ rspec-mocks (3.11.1)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.11.0)
23
+ rspec-support (3.11.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ adapay!
30
+ rake (~> 12.0)
31
+ rspec (~> 3.0)
32
+
33
+ BUNDLED WITH
34
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 lanzhiheng
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,99 @@
1
+ # Adapay
2
+
3
+ Welcome to Adapay! This is a simple gem for Adapay. What is Adapay? It's an pay platform which integrating multi pay channel. So you can use Alipay, Wechat, Union, etc.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'adapay'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install adapay
20
+
21
+ ## Usage
22
+
23
+ ### Configuration
24
+
25
+ Create `Create config/initializer/adapay.rb` and put following configurations into it
26
+
27
+ ```
28
+ Adapay.app_id = 'Your Adapay App Id
29
+ Adapay.app_key = 'Your Adapay App Key'
30
+ Adapay.backup_app_id = 'Your Backup Adapay App Id'
31
+ Adapay.backup_app_key = 'Your Backup Adapay App Key'
32
+ # Private key which generate by your platform
33
+ Adapay.merchant_private_key = File.read('merchant_private_key')
34
+ # Public Key From Adapay Platform
35
+ Adapay.platform_public_key = File.read('adapay_platform_public_key')
36
+ ```
37
+
38
+ ### backup_app_id
39
+
40
+ What is `backup_app_id`? Imagine, if you have more than one applications in Adapay, most of api you want to issue in application with `app_id` and others on `backup_app_id`. How to do that? You Just can call the method with params `app_id=xxxx`.
41
+
42
+ ### 1. Create Payment in default application
43
+
44
+ ``` ruby
45
+ params = {
46
+ order_no: 'number',
47
+ pay_channel: 'alipay',
48
+ pay_amt: format('%.2f', 100),
49
+ expend: {
50
+ open_id: ''
51
+ },
52
+ pay_mode: 'delay',
53
+ goods_title: 'payment',
54
+ goods_desc: 'payment',
55
+ device_info: {
56
+ device_ip: '127.0.0.1'
57
+ },
58
+ notify_url: notification_url
59
+ }
60
+
61
+ res = Adapay.create_refund(params)
62
+ ```
63
+
64
+ ## 1. Create Payment in other application with backup_app_id
65
+
66
+ ``` ruby
67
+ params = {
68
+ order_no: 'number',
69
+ pay_channel: 'alipay',
70
+ pay_amt: format('%.2f', 100),
71
+ expend: {
72
+ open_id: ''
73
+ },
74
+ pay_mode: 'delay',
75
+ goods_title: 'payment',
76
+ goods_desc: 'payment',
77
+ device_info: {
78
+ device_ip: '127.0.0.1'
79
+ },
80
+ notify_url: notification_url
81
+ }
82
+
83
+ res = Adapay.create_refund(params.merge(app_id: Adapay.backup_app_id))
84
+ ```
85
+
86
+ This Gem can auto search the `backup_app_key` from `Adapay.id_key_map`. You can check the source code from [here](https://github.com/lanzhiheng/adapay/blob/master/lib/adapay.rb#L80).
87
+
88
+ ## Contributing
89
+
90
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/adapay. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/adapay/blob/master/CODE_OF_CONDUCT.md).
91
+
92
+
93
+ ## License
94
+
95
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
96
+
97
+ ## Code of Conduct
98
+
99
+ Everyone interacting in the Adapay project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/adapay/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/adapay.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/adapay/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'adapay'
7
+ spec.version = Adapay::VERSION
8
+ spec.authors = ['lanzhiheng']
9
+ spec.email = ['lanzhihengrj@gmail.com']
10
+
11
+ spec.summary = 'Gem for Adapay'
12
+ spec.description = 'Gem for Adapay'
13
+ spec.homepage = 'https://www.adapay.tech/'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
16
+
17
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
18
+
19
+ spec.metadata['homepage_uri'] = 'https://www.adapay.tech/'
20
+ spec.metadata['source_code_uri'] = 'https://github.com/lanzhiheng/adapay'
21
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ end
28
+ spec.bindir = 'exe'
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ['lib']
31
+ end
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'adapay'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -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,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Adapay
4
+ VERSION = '1.0.0'
5
+ end
data/lib/adapay.rb ADDED
@@ -0,0 +1,375 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'adapay/version'
4
+
5
+ module Adapay
6
+ class << self
7
+ attr_accessor :app_id, :app_key, :backup_app_id, :backup_app_key
8
+ attr_reader :merchant_private_key, :platform_public_key
9
+
10
+ def extra_data_from_response(response)
11
+ extra_data_from_body(response.body)
12
+ end
13
+
14
+ def extra_data_from_body(body)
15
+ data = JSON.parse(body)['data']
16
+ JSON.parse(data)
17
+ end
18
+
19
+ def valid_channels
20
+ # https://docs.adapay.tech/api/appendix.html#id2
21
+ %i[
22
+ alipay
23
+ alipay_qr
24
+ alipay_wap
25
+ alipay_lite
26
+ alipay_pub
27
+ alipay_scan
28
+ wx_pub
29
+ wx_lite
30
+ wx_scan
31
+ union
32
+ union_qr
33
+ union_wap
34
+ union_scan
35
+ union_online
36
+ fast_pay
37
+ b2c
38
+ b2b
39
+ ]
40
+ end
41
+
42
+ def sdk_version
43
+ "ruby_#{VERSION}"
44
+ end
45
+
46
+ def endpoint
47
+ 'https://api.adapay.tech'
48
+ end
49
+
50
+ def page_endpoint
51
+ 'https://page.adapay.tech'
52
+ end
53
+
54
+ def merchant_public_key
55
+ merchant_private_key.public_key
56
+ end
57
+
58
+ def merchant_private_key=(key)
59
+ @merchant_private_key = OpenSSL::PKey::RSA.new(key)
60
+ end
61
+
62
+ def platform_public_key=(key)
63
+ @platform_public_key = OpenSSL::PKey::RSA.new(key)
64
+ end
65
+
66
+ def sign(content)
67
+ Base64.strict_encode64(merchant_private_key.sign('SHA1', content))
68
+ end
69
+
70
+ def verify(sign, content)
71
+ sign_string = Base64.strict_decode64(sign)
72
+ platform_public_key.public_key.verify('SHA1', sign_string, content)
73
+ end
74
+
75
+ def merchant_verify(sign, content)
76
+ sign_string = Base64.strict_decode64(sign)
77
+ merchant_public_key.public_key.verify('SHA1', sign_string, content)
78
+ end
79
+
80
+ def id_key_map
81
+ {
82
+ app_id => app_key,
83
+ backup_app_id => backup_app_key
84
+ }
85
+ end
86
+
87
+ def build_request_info(method, url, params)
88
+ headers = build_common_headers(params[:app_id])
89
+
90
+ if method.to_s.downcase == 'post'
91
+ plain_text = url + params.to_json
92
+ signature = sign(plain_text)
93
+
94
+ headers.merge({
95
+ 'Content-type' => 'application/json',
96
+ signature: signature
97
+ })
98
+ else
99
+ plain_text = url + get_original_str(params)
100
+ signature = sign(plain_text)
101
+
102
+ headers.merge({
103
+ signature: signature
104
+ })
105
+ end
106
+ end
107
+
108
+ def create_refund(params)
109
+ payment_id = params.delete(:payment_id)
110
+ path = "/v1/payments/#{payment_id}/refunds"
111
+
112
+ send_request(:post, path, params)
113
+ end
114
+
115
+ # https://docs.adapay.tech/api/trade.html#query-refund
116
+ def query_refund(params)
117
+ path = '/v1/payments/refunds'
118
+
119
+ send_request(:get, path, params)
120
+ end
121
+
122
+ def create_payment(params)
123
+ path = '/v1/payments'
124
+
125
+ params = { app_id: app_id }.merge(params)
126
+
127
+ send_request(:post, path, params)
128
+ end
129
+
130
+ def close_payment(params)
131
+ payment_id = params.delete(:payment_id)
132
+ path = "/v1/payments/#{payment_id}/close"
133
+
134
+ send_request(:post, path, params)
135
+ end
136
+
137
+ def query_payment_list
138
+ path = '/v1/payments/list'
139
+
140
+ params = { app_id: app_id }
141
+
142
+ send_request(:get, path, params)
143
+ end
144
+
145
+ def query_payment(params)
146
+ payment_id = params.delete(:payment_id)
147
+ path = "/v1/payments/#{payment_id}"
148
+
149
+ send_request(:get, path, params)
150
+ end
151
+
152
+ ## ---
153
+
154
+ # https://docs.adapay.tech/api/trade.html#member-create
155
+ def create_member(params)
156
+ path = '/v1/members'
157
+
158
+ params = {
159
+ app_id: app_id
160
+ }.merge(params)
161
+
162
+ send_request(:post, path, params)
163
+ end
164
+
165
+ # https://docs.adapay.tech/api/trade.html#id39
166
+ def query_member(params)
167
+ member_id = params.delete(:member_id)
168
+
169
+ params = {
170
+ app_id: app_id
171
+ }.merge(params)
172
+
173
+ path = "/v1/members/#{member_id}"
174
+
175
+ send_request(:get, path, params)
176
+ end
177
+
178
+ # https://docs.adapay.tech/api/trade.html#id40
179
+ def update_member(params)
180
+ path = '/v1/members/update'
181
+
182
+ params = {
183
+ app_id: app_id
184
+ }.merge(params)
185
+
186
+ send_request(:post, path, params)
187
+ end
188
+
189
+ # https://docs.adapay.tech/api/trade.html#id42
190
+ def query_member_list
191
+ path = '/v1/members/list'
192
+
193
+ params = { app_id: app_id }
194
+
195
+ send_request(:get, path, params)
196
+ end
197
+
198
+ ## ---
199
+
200
+ def create_settle_account(params)
201
+ path = '/v1/settle_accounts'
202
+
203
+ params = {
204
+ app_id: app_id,
205
+ channel: 'bank_account'
206
+ }.merge(params)
207
+ send_request(:post, path, params)
208
+ end
209
+
210
+ def query_settle_account(params)
211
+ settle_account_id = params.delete(:settle_account_id)
212
+
213
+ path = "/v1/settle_accounts/#{settle_account_id}"
214
+
215
+ params = {
216
+ app_id: app_id
217
+ }.merge(params)
218
+
219
+ send_request(:get, path, params)
220
+ end
221
+
222
+ # https://docs.adapay.tech/api/trade.html#id50
223
+ def delete_settle_account(params)
224
+ path = '/v1/settle_accounts/delete'
225
+
226
+ params = {
227
+ app_id: app_id
228
+ }.merge(params)
229
+
230
+ send_request(:post, path, params)
231
+ end
232
+
233
+ # https://docs.adapay.tech/api/trade.html#settle-account-modify
234
+ def update_settle_account(params)
235
+ path = '/v1/settle_accounts/modify'
236
+
237
+ params = {
238
+ app_id: app_id
239
+ }.merge(params)
240
+ send_request(:post, path, params)
241
+ end
242
+
243
+ def query_settle_account_detail(params)
244
+ path = '/v1/settle_accounts/settle_details'
245
+ params = {
246
+ app_id: app_id
247
+ }.merge(params)
248
+
249
+ send_request(:get, path, params)
250
+ end
251
+
252
+ def query_settle_account_balance(params)
253
+ path = '/v1/settle_accounts/balance'
254
+
255
+ params = {
256
+ app_id: app_id
257
+ }.merge(params)
258
+
259
+ send_request(:get, path, params)
260
+ end
261
+
262
+ # -- 钱包
263
+
264
+ def cash(params)
265
+ path = '/v1/cashs'
266
+
267
+ params = {
268
+ app_id: app_id
269
+ }.merge(params)
270
+
271
+ send_request(:post, path, params)
272
+ end
273
+
274
+ def query_cash(params)
275
+ path = '/v1/cashs/stat'
276
+
277
+ params = {
278
+ app_id: app_id
279
+ }.merge(params)
280
+
281
+ send_request(:get, path, params)
282
+ end
283
+
284
+ # -- 撤销支付
285
+
286
+ # https://docs.adapay.tech/api/trade.html#payment-reverse-create
287
+ def create_payment_reverse(params)
288
+ path = '/v1/payments/reverse'
289
+
290
+ params = {
291
+ app_id: app_id
292
+ }.merge(params)
293
+
294
+ send_request(:post, path, params)
295
+ end
296
+
297
+ def query_payment_reverse(params)
298
+ reverse_id = params.delete(:reverse_id)
299
+
300
+ path = "/v1/payments/reverse/#{reverse_id}"
301
+ send_request(:get, path, params)
302
+ end
303
+
304
+ def query_payment_reverse_list
305
+ params = {
306
+ app_id: app_id
307
+ }
308
+
309
+ path = '/v1/payments/reverse/list'
310
+ send_request(:get, path, params)
311
+ end
312
+
313
+ # -- 确认支付
314
+ # https://docs.adapay.tech/api/trade.html#payment-confirm-create
315
+ def create_payment_confirm(params)
316
+ params = {
317
+ app_id: app_id
318
+ }.merge(params)
319
+
320
+ path = '/v1/payments/confirm'
321
+ send_request(:post, path, params)
322
+ end
323
+
324
+ # https://docs.adapay.tech/api/trade.html#id59
325
+ def query_payment_confirm(params)
326
+ payment_confirm_id = params.delete(:payment_confirm_id)
327
+
328
+ path = "/v1/payments/confirm/#{payment_confirm_id}"
329
+
330
+ params = {
331
+ app_id: app_id
332
+ }.merge(params)
333
+
334
+ send_request(:get, path, params)
335
+ end
336
+
337
+ def query_payment_confirm_list(params)
338
+ path = '/v1/payments/confirm/list'
339
+
340
+ params = {
341
+ app_id: app_id
342
+ }.merge(params)
343
+
344
+ send_request(:get, path, params)
345
+ end
346
+
347
+ private
348
+
349
+ def send_request(method, path, params)
350
+ url = endpoint + path
351
+ headers = build_request_info(method, url, params)
352
+ url += "?#{get_original_str(params)}" if method.downcase.to_s == 'get'
353
+
354
+ RestClient::Request.execute(method: method, url: url, headers: headers, payload: params.to_json)
355
+ rescue RestClient::BadRequest, RestClient::Unauthorized, RestClient::PaymentRequired => e
356
+ e.response
357
+ end
358
+
359
+ def get_original_str(params)
360
+ params.to_a.sort.map do |a, b|
361
+ value = b.is_a?(Hash) ? b.to_json : b
362
+ "#{a}=#{value}"
363
+ end.join('&')
364
+ end
365
+
366
+ def build_common_headers(real_id)
367
+ key = id_key_map[real_id]
368
+
369
+ {
370
+ authorization: key,
371
+ sdk_version: sdk_version
372
+ }
373
+ end
374
+ end
375
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: adapay
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - lanzhiheng
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-07-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Gem for Adapay
14
+ email:
15
+ - lanzhihengrj@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".rspec"
22
+ - ".travis.yml"
23
+ - CODE_OF_CONDUCT.md
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - LICENSE.txt
27
+ - README.md
28
+ - Rakefile
29
+ - adapay.gemspec
30
+ - bin/console
31
+ - bin/setup
32
+ - lib/adapay.rb
33
+ - lib/adapay/version.rb
34
+ homepage: https://www.adapay.tech/
35
+ licenses:
36
+ - MIT
37
+ metadata:
38
+ homepage_uri: https://www.adapay.tech/
39
+ source_code_uri: https://github.com/lanzhiheng/adapay
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 2.3.0
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubygems_version: 3.1.4
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: Gem for Adapay
59
+ test_files: []