paypal-rest 1.0.0 → 1.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +16 -0
- data/bin/rake +29 -0
- data/bin/release +4 -0
- data/bin/rspec +29 -0
- data/lib/paypal/rest/bearer_token.rb +5 -1
- data/lib/paypal/rest/version.rb +1 -1
- data/lib/paypal/rest.rb +20 -6
- data/lib/paypal/webhooks/event.rb +5 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6a232625846c2f019c3b39ba9e48f3793812867bdcc47c8b2bb58be4849d63d
|
4
|
+
data.tar.gz: 780a910c3ecd50342a641c64e07e0692e7a6970f201d62928b5c6e8f9db789e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1fee1827129e2cc2695048c766d386320ea29b9f2730a0f3b908e0a88e60ddb5aff16321ed8101d1475e8abe512401bd5d75b79e452657c8ad9b1b19127a170
|
7
|
+
data.tar.gz: f82fa4d1d7cb11f68d5e49812ba653a55841cb348315c0e63349d39c734b9f0335320ea539eac42bcdd4bed9de6f122fcecb92d918f25e824fab2a7e4664cef0
|
data/.rubocop.yml
CHANGED
@@ -161,6 +161,7 @@ RSpec/ExampleLength:
|
|
161
161
|
Enabled: false
|
162
162
|
RSpec/ContextWording:
|
163
163
|
Prefixes:
|
164
|
+
- and
|
164
165
|
- but
|
165
166
|
- if
|
166
167
|
- when
|
@@ -173,6 +174,8 @@ Metrics/BlockLength:
|
|
173
174
|
- spec/**/*
|
174
175
|
Layout/ArgumentAlignment:
|
175
176
|
Enabled: false
|
177
|
+
Layout/FirstArgumentIndentation:
|
178
|
+
Enabled: false
|
176
179
|
Style/TrailingCommaInArrayLiteral:
|
177
180
|
EnforcedStyleForMultiline: consistent_comma
|
178
181
|
Style/TrailingCommaInArguments:
|
@@ -208,6 +211,9 @@ Naming/MethodParameterName:
|
|
208
211
|
AllowedNames:
|
209
212
|
- as
|
210
213
|
- id
|
214
|
+
Layout/LineLength:
|
215
|
+
Exclude:
|
216
|
+
- Gemfile
|
211
217
|
Metrics/AbcSize:
|
212
218
|
Enabled: false
|
213
219
|
Style/IfUnlessModifierOfIfUnless:
|
@@ -218,9 +224,19 @@ Style/SoleNestedConditional:
|
|
218
224
|
Enabled: false
|
219
225
|
Naming/VariableNumber:
|
220
226
|
EnforcedStyle: snake_case
|
227
|
+
Metrics/ModuleLength:
|
228
|
+
Exclude:
|
229
|
+
- spec/**/*
|
221
230
|
RSpec/SubjectStub:
|
222
231
|
Enabled: false
|
232
|
+
Metrics/ParameterLists:
|
233
|
+
Exclude:
|
234
|
+
- spec/**/*
|
223
235
|
Layout/ArrayAlignment:
|
224
236
|
Enabled: false
|
225
237
|
Layout/FirstArrayElementIndentation:
|
226
238
|
Enabled: false
|
239
|
+
Style/Alias:
|
240
|
+
EnforcedStyle: prefer_alias_method
|
241
|
+
Layout/FirstHashElementIndentation:
|
242
|
+
EnforcedStyle: consistent
|
data/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/release
ADDED
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
@@ -16,7 +16,7 @@ module Paypal
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def token
|
19
|
-
response[:access_token]
|
19
|
+
Util.deep_symbolize_keys(response)[:access_token]
|
20
20
|
end
|
21
21
|
|
22
22
|
def expires_at
|
@@ -42,6 +42,10 @@ module Paypal
|
|
42
42
|
faraday.response :json
|
43
43
|
end
|
44
44
|
end
|
45
|
+
|
46
|
+
def config
|
47
|
+
Paypal::REST.configuration
|
48
|
+
end
|
45
49
|
end
|
46
50
|
end
|
47
51
|
end
|
data/lib/paypal/rest/version.rb
CHANGED
data/lib/paypal/rest.rb
CHANGED
@@ -19,12 +19,24 @@ module Paypal
|
|
19
19
|
@configuration = nil
|
20
20
|
end
|
21
21
|
|
22
|
-
def create_order(params)
|
23
|
-
|
22
|
+
def create_order(full_response: false, **params)
|
23
|
+
if full_response
|
24
|
+
post("/v2/checkout/orders", params:, headers: {
|
25
|
+
Prefer: "return=representation",
|
26
|
+
}) # rubocop:disable Style/TrailingCommaInArguments, Layout/MultilineMethodCallBraceLayout
|
27
|
+
else
|
28
|
+
post("/v2/checkout/orders", params:)[:id]
|
29
|
+
end
|
24
30
|
end
|
25
31
|
|
26
|
-
def capture_payment_for_order(order_id)
|
27
|
-
|
32
|
+
def capture_payment_for_order(order_id, full_response: false)
|
33
|
+
if full_response
|
34
|
+
post("/v2/checkout/orders/#{order_id}/capture", headers: {
|
35
|
+
Prefer: "return=representation",
|
36
|
+
}) # rubocop:disable Style/TrailingCommaInArguments, Layout/MultilineMethodCallBraceLayout
|
37
|
+
else
|
38
|
+
post("/v2/checkout/orders/#{order_id}/capture")
|
39
|
+
end
|
28
40
|
end
|
29
41
|
|
30
42
|
def reset_connection
|
@@ -34,8 +46,10 @@ module Paypal
|
|
34
46
|
|
35
47
|
private
|
36
48
|
|
37
|
-
def post(path, params
|
38
|
-
|
49
|
+
def post(path, params: {}, headers: {})
|
50
|
+
reset_connection if @bearer_token&.expired?
|
51
|
+
|
52
|
+
response = connection.post(path, params, headers).body
|
39
53
|
|
40
54
|
response = JSON.parse(response) if response.is_a?(String)
|
41
55
|
response = Util.deep_symbolize_keys(response)
|
@@ -30,8 +30,12 @@ module Paypal
|
|
30
30
|
verify_cert_url && verify_cert && verify_signature
|
31
31
|
end
|
32
32
|
|
33
|
+
def type
|
34
|
+
@params[:event_type]
|
35
|
+
end
|
36
|
+
|
33
37
|
def data
|
34
|
-
@data ||= Util.deep_symbolize_keys(@params)
|
38
|
+
@data ||= Util.deep_symbolize_keys(@params)[:resource] || {}
|
35
39
|
end
|
36
40
|
|
37
41
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paypal-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elliot Crosby-McCullough
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -57,6 +57,9 @@ files:
|
|
57
57
|
- README.md
|
58
58
|
- Rakefile
|
59
59
|
- bin/console
|
60
|
+
- bin/rake
|
61
|
+
- bin/release
|
62
|
+
- bin/rspec
|
60
63
|
- bin/setup
|
61
64
|
- lib/paypal/rest.rb
|
62
65
|
- lib/paypal/rest/bearer_token.rb
|
@@ -73,7 +76,7 @@ metadata:
|
|
73
76
|
allowed_push_host: https://rubygems.org
|
74
77
|
homepage_uri: https://github.com/SmartCasual/paypal-rest
|
75
78
|
source_code_uri: https://github.com/SmartCasual/paypal-rest
|
76
|
-
changelog_uri: https://github.com/SmartCasual/paypal-rest/blob/1.
|
79
|
+
changelog_uri: https://github.com/SmartCasual/paypal-rest/blob/1.1.0/CHANGELOG.md
|
77
80
|
rubygems_mfa_required: 'true'
|
78
81
|
post_install_message:
|
79
82
|
rdoc_options: []
|