paypalrb 0.1.1 → 0.1.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 +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +12 -5
- data/bin/console +2 -2
- data/lib/pay_pal/authentication.rb +1 -1
- data/lib/pay_pal/client.rb +5 -1
- data/lib/pay_pal/objects/identity.rb +4 -0
- data/lib/pay_pal/resources/identity.rb +10 -0
- data/lib/pay_pal/resources/orders.rb +6 -0
- data/lib/pay_pal/version.rb +1 -1
- data/lib/pay_pal.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32e63207df5329d80b150582834894e5a6b15c97a5e6b7b77ef28e79d0e2831b
|
4
|
+
data.tar.gz: ec267e0869c64b843a0507708014f6e1d4902ca38daa7da4a97882d92b1820af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aec2db6e9aec16e1082958e0cf0f71636d90f6e14b2ed912d05221d6fb22262923bf2350c6da08bc6f0cb29b3da2edf31f83fcbcebdfd00c99474b52a1b9e7c9
|
7
|
+
data.tar.gz: 1adaf024dbcc4a8dfc0ca9885ceec221fe7c378dcb9524633cda7e11c399734d32c39e0a8ebd0ff5d66fd0747cc0de27c5681f2fb3f835bbbfcbba0777876f74
|
data/Gemfile.lock
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
paypalrb (0.1.
|
4
|
+
paypalrb (0.1.2)
|
5
5
|
faraday (~> 2.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
dotenv (2.7.6)
|
11
|
-
faraday (2.
|
11
|
+
faraday (2.6.0)
|
12
12
|
faraday-net_http (>= 2.0, < 3.1)
|
13
13
|
ruby2_keywords (>= 0.0.4)
|
14
|
-
faraday-net_http (3.0.
|
14
|
+
faraday-net_http (3.0.1)
|
15
15
|
rake (13.0.6)
|
16
16
|
ruby2_keywords (0.0.5)
|
17
17
|
|
data/README.md
CHANGED
@@ -14,14 +14,18 @@ gem 'paypalrb'
|
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
|
-
###
|
17
|
+
### Authentication
|
18
18
|
|
19
|
-
|
20
|
-
An Access Token will be an OAuth2 token generated after authentication.
|
19
|
+
PayPal accepts authentication with either an access token or a client_id and client_secret.
|
21
20
|
|
21
|
+
This library has the ability to generate an access token like so:
|
22
22
|
|
23
23
|
```ruby
|
24
|
-
@authentication = PayPal::Authentication.new(
|
24
|
+
@authentication = PayPal::Authentication.new(
|
25
|
+
sandbox: true,
|
26
|
+
client_id: "",
|
27
|
+
client_secret: ""
|
28
|
+
)
|
25
29
|
|
26
30
|
@authentication.get_token
|
27
31
|
# => #<PayPal::AccessToken access_token="abc123", expires_in=123
|
@@ -30,7 +34,7 @@ An Access Token will be an OAuth2 token generated after authentication.
|
|
30
34
|
Then once you have an access token, set it like so:
|
31
35
|
|
32
36
|
```ruby
|
33
|
-
@client = PayPal::Client.new(access_token: "abc123")
|
37
|
+
@client = PayPal::Client.new(sandbox: true, access_token: "abc123")
|
34
38
|
```
|
35
39
|
|
36
40
|
### Products
|
@@ -73,6 +77,9 @@ Then once you have an access token, set it like so:
|
|
73
77
|
|
74
78
|
# Captures payment for an order. The buyer must first approve the order.
|
75
79
|
@client.orders.capture id: "123abc"
|
80
|
+
|
81
|
+
# Confirms a payment source for an order
|
82
|
+
@client.orders.confirm id: "123abc", source: {}
|
76
83
|
```
|
77
84
|
|
78
85
|
## Contributing
|
data/bin/console
CHANGED
@@ -14,9 +14,9 @@ require 'dotenv/load'
|
|
14
14
|
# require "pry"
|
15
15
|
# Pry.start
|
16
16
|
|
17
|
-
@authentication = PayPal::Authentication.new(client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
|
17
|
+
@authentication = PayPal::Authentication.new(sandbox: true, client_id: ENV["CLIENT_ID"], client_secret: ENV["CLIENT_SECRET"])
|
18
18
|
|
19
|
-
@client = PayPal::Client.new(access_token: ENV["ACCESS_TOKEN"])
|
19
|
+
@client = PayPal::Client.new(sandbox: true, access_token: ENV["ACCESS_TOKEN"])
|
20
20
|
|
21
21
|
require "irb"
|
22
22
|
IRB.start(__FILE__)
|
@@ -3,7 +3,7 @@ module PayPal
|
|
3
3
|
|
4
4
|
attr_reader :client_id, :client_secret, :sandbox
|
5
5
|
|
6
|
-
def initialize(client_id:, client_secret:, sandbox
|
6
|
+
def initialize(client_id:, client_secret:, sandbox:, adapter: Faraday.default_adapter)
|
7
7
|
@client_id = client_id
|
8
8
|
@client_secret = client_secret
|
9
9
|
@sandbox = sandbox
|
data/lib/pay_pal/client.rb
CHANGED
@@ -2,7 +2,7 @@ module PayPal
|
|
2
2
|
class Client
|
3
3
|
attr_reader :access_token, :sandbox, :adapter
|
4
4
|
|
5
|
-
def initialize(access_token:, sandbox
|
5
|
+
def initialize(access_token:, sandbox:, adapter: Faraday.default_adapter, stubs: nil)
|
6
6
|
@access_token = access_token
|
7
7
|
@sandbox = sandbox
|
8
8
|
@adapter = adapter
|
@@ -11,6 +11,10 @@ module PayPal
|
|
11
11
|
@stubs = stubs
|
12
12
|
end
|
13
13
|
|
14
|
+
def identity
|
15
|
+
IdentityResource.new(self)
|
16
|
+
end
|
17
|
+
|
14
18
|
def products
|
15
19
|
ProductsResource.new(self)
|
16
20
|
end
|
@@ -61,5 +61,11 @@ module PayPal
|
|
61
61
|
Order.new(response.body)
|
62
62
|
end
|
63
63
|
|
64
|
+
def confirm(id:, source:)
|
65
|
+
attributes = {payment_source: source}
|
66
|
+
response = post_request("v2/checkout/orders/#{id}/confirm-payment-source", body: attributes.merge(params))
|
67
|
+
Order.new(response.body)
|
68
|
+
end
|
69
|
+
|
64
70
|
end
|
65
71
|
end
|
data/lib/pay_pal/version.rb
CHANGED
data/lib/pay_pal.rb
CHANGED
@@ -15,9 +15,11 @@ module PayPal
|
|
15
15
|
|
16
16
|
autoload :ProductsResource, "pay_pal/resources/products"
|
17
17
|
autoload :OrdersResource, "pay_pal/resources/orders"
|
18
|
+
autoload :IdentityResource, "pay_pal/resources/identity"
|
18
19
|
|
19
20
|
autoload :AccessToken, "pay_pal/objects/access_token"
|
20
21
|
autoload :Product, "pay_pal/objects/product"
|
21
22
|
autoload :Order, "pay_pal/objects/order"
|
23
|
+
autoload :Identity, "pay_pal/objects/identity"
|
22
24
|
|
23
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paypalrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dean Perry
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -46,9 +46,11 @@ files:
|
|
46
46
|
- lib/pay_pal/error.rb
|
47
47
|
- lib/pay_pal/object.rb
|
48
48
|
- lib/pay_pal/objects/access_token.rb
|
49
|
+
- lib/pay_pal/objects/identity.rb
|
49
50
|
- lib/pay_pal/objects/order.rb
|
50
51
|
- lib/pay_pal/objects/product.rb
|
51
52
|
- lib/pay_pal/resource.rb
|
53
|
+
- lib/pay_pal/resources/identity.rb
|
52
54
|
- lib/pay_pal/resources/orders.rb
|
53
55
|
- lib/pay_pal/resources/products.rb
|
54
56
|
- lib/pay_pal/version.rb
|