paypal-sdk-rest 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +87 -44
- data/Rakefile +1 -1
- data/lib/paypal-sdk/rest/api.rb +1 -1
- data/lib/paypal-sdk/rest/version.rb +1 -1
- data/spec/payments_examples_spec.rb +4 -0
- metadata +5 -6
- data/lib/paypal.rb +0 -5
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OWQ5ZjMxODJmNmY0OTc0MDhlOTU3ZDljYTJlZDQ3NWY5NTMxM2RmMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDdjODVlMjZjYjg4YjY4ZTFkMjJjMzRjNGIxMjU2YWFlMmRhZDJhMQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmZkMWJkNDViYTcyYzEzOTIzZDczODJlYjAwMzNkYjU2ZDMxZjUyNjYxOGYz
|
10
|
+
YWQ1NTAyNzM5MjQ5ZTc0MzI2ZmMzYzZkODdiMmZiMjFhNjlmMzhkZTExMTg5
|
11
|
+
NmY5MzE1ZDAwZTViNTk5NjRmZjU3ZTgwOGQwZjMxNzAyNDM4ZTc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmE4ZDNmMWUxOWJkZWViZTI1YTY0MTM3NDA1ZGFkNjUyMjNlMTI4ZDM1ZjM0
|
14
|
+
NTUwYzAyMzM2NDM0NjQ5OTA5YjA1YTJlYzM1NDJmMjg1YmUzOThkYmVlYmQ1
|
15
|
+
Y2U2MGQxYTVlMDUxMThiYTMxYzM3YWIxYzkyYjE3NDk2N2Y3MjM=
|
data/README.md
CHANGED
@@ -6,65 +6,68 @@ The PayPal REST SDK provides Ruby APIs to create, process and manage payment.
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# gem 'paypal-sdk-rest', :git => "https://github.com/paypal/rest-api-sdk-ruby.git"
|
9
|
+
```ruby
|
10
|
+
gem 'paypal-sdk-rest'
|
11
|
+
```
|
13
12
|
|
14
13
|
And then execute:
|
15
14
|
|
16
|
-
|
15
|
+
```sh
|
16
|
+
$ bundle
|
17
|
+
```
|
17
18
|
|
18
19
|
Or install it yourself as:
|
19
20
|
|
20
|
-
|
21
|
+
```sh
|
22
|
+
$ gem install paypal-sdk-rest
|
23
|
+
```
|
21
24
|
|
22
25
|
## Configuration
|
23
26
|
|
24
27
|
For Rails application:
|
25
28
|
|
26
|
-
|
29
|
+
```sh
|
30
|
+
rails g paypal:sdk:install
|
31
|
+
```
|
27
32
|
|
28
33
|
For other ruby application, create a configuration file(`config/paypal.yml`):
|
29
34
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
35
|
+
```yaml
|
36
|
+
development: &default
|
37
|
+
mode: sandbox
|
38
|
+
client_id: EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM
|
39
|
+
client_secret: EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM
|
40
|
+
# # with Proxy
|
41
|
+
# http_proxy: http://proxy-ipaddress:3129/
|
42
|
+
# # with CA File
|
43
|
+
# ssl_options:
|
44
|
+
# ca_file: config/cacert.pem
|
45
|
+
# # Override Endpoint
|
46
|
+
# rest_endpoint: https://api.sandbox.paypal.com
|
47
|
+
test:
|
48
|
+
<<: *default
|
49
|
+
production:
|
50
|
+
mode: live
|
51
|
+
client_id: CLIENT_ID
|
52
|
+
client_secret: CLIENT_SECRET
|
53
|
+
```
|
46
54
|
|
47
55
|
|
48
56
|
Load Configurations from specified file:
|
49
57
|
|
50
|
-
|
58
|
+
```ruby
|
59
|
+
PayPal::SDK::Core::Config.load('spec/config/paypal.yml', ENV['RACK_ENV'] || 'development')
|
60
|
+
```
|
51
61
|
|
52
62
|
Without configuration file:
|
53
63
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
# Class level
|
63
|
-
Payment.set_config( :client_id => "123" )
|
64
|
-
|
65
|
-
# Object level
|
66
|
-
payment.set_config( :client_id => "123" )
|
67
|
-
|
64
|
+
```ruby
|
65
|
+
PayPal::SDK.configure(
|
66
|
+
:mode => "sandbox", # "sandbox" or "live"
|
67
|
+
:client_id => "EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM",
|
68
|
+
:client_secret => "EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM",
|
69
|
+
:ssl_options => { } )
|
70
|
+
```
|
68
71
|
|
69
72
|
## Create Payment
|
70
73
|
|
@@ -73,9 +76,9 @@ require 'paypal-sdk-rest'
|
|
73
76
|
include PayPal::SDK::REST
|
74
77
|
|
75
78
|
PayPal::SDK::REST.set_config(
|
79
|
+
:mode => "sandbox", # "sandbox" or "live"
|
76
80
|
:client_id => "EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM",
|
77
|
-
:client_secret => "EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM"
|
78
|
-
:mode => "sandbox" )
|
81
|
+
:client_secret => "EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM")
|
79
82
|
|
80
83
|
# Build Payment object
|
81
84
|
@payment = Payment.new({
|
@@ -98,12 +101,19 @@ PayPal::SDK::REST.set_config(
|
|
98
101
|
:postal_code => "43210",
|
99
102
|
:country_code => "US" }}}]},
|
100
103
|
:transactions => [{
|
104
|
+
:item_list => {
|
105
|
+
:items => [{
|
106
|
+
:name => "item",
|
107
|
+
:sku => "item",
|
108
|
+
:price => "1",
|
109
|
+
:currency => "USD",
|
110
|
+
:quantity => 1 }]},
|
101
111
|
:amount => {
|
102
112
|
:total => "1.00",
|
103
113
|
:currency => "USD" },
|
104
114
|
:description => "This is the payment transaction description." }]})
|
105
115
|
|
106
|
-
#
|
116
|
+
# Create Payment and return the status(true or false)
|
107
117
|
if @payment.create
|
108
118
|
@payment.id # Payment Id
|
109
119
|
else
|
@@ -111,20 +121,21 @@ else
|
|
111
121
|
end
|
112
122
|
```
|
113
123
|
|
114
|
-
## Get Payment
|
124
|
+
## Get Payment details
|
115
125
|
|
116
126
|
```ruby
|
117
127
|
# Fetch Payment
|
118
128
|
payment = Payment.find("PAY-57363176S1057143SKE2HO3A")
|
119
129
|
|
120
|
-
# Get List of
|
130
|
+
# Get List of Payments
|
121
131
|
payment_history = Payment.all( :count => 10 )
|
122
|
-
|
123
132
|
payment_history.payments
|
124
133
|
```
|
125
134
|
|
126
135
|
## Execute Payment
|
127
136
|
|
137
|
+
Only for [Payment](https://github.com/paypal/rest-api-sdk-ruby/blob/master/samples/payment/create_with_paypal.rb) with `payment_method` as `"paypal"`
|
138
|
+
|
128
139
|
```ruby
|
129
140
|
payment = Payment.find("PAY-57363176S1057143SKE2HO3A")
|
130
141
|
|
@@ -133,4 +144,36 @@ if payment.execute( :payer_id => "DUFRQ8GWYMJXC" )
|
|
133
144
|
else
|
134
145
|
payment.error # Error Hash
|
135
146
|
end
|
147
|
+
|
148
|
+
## OpenID Connect
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
# Update client_id, client_secret and redirect_uri
|
152
|
+
PayPal::SDK.configure({
|
153
|
+
:openid_client_id => "client_id",
|
154
|
+
:openid_client_secret => "client_secret",
|
155
|
+
:openid_redirect_uri => "http://google.com"
|
156
|
+
})
|
157
|
+
include PayPal::SDK::OpenIDConnect
|
158
|
+
|
159
|
+
# Generate authorize URL to Get Authorize code
|
160
|
+
puts Tokeninfo.authorize_url( :scope => "openid profile" )
|
161
|
+
|
162
|
+
# Create tokeninfo by using Authorize Code from redirect_uri
|
163
|
+
tokeninfo = Tokeninfo.create("Replace with Authorize Code received on redirect_uri")
|
164
|
+
|
165
|
+
# Refresh tokeninfo object
|
166
|
+
tokeninfo.refresh
|
167
|
+
|
168
|
+
# Create tokeninfo by using refresh token
|
169
|
+
tokeninfo = Tokeninfo.refresh("Replace with refresh_token")
|
170
|
+
|
171
|
+
# Get Userinfo
|
172
|
+
userinfo = tokeninfo.userinfo
|
173
|
+
|
174
|
+
# Get Userinfo by using access token
|
175
|
+
userinfo = Userinfo.get("Replace with access_token")
|
176
|
+
|
177
|
+
# Get logout url
|
178
|
+
put tokeninfo.logout_url
|
136
179
|
```
|
data/Rakefile
CHANGED
data/lib/paypal-sdk/rest/api.rb
CHANGED
@@ -12,7 +12,7 @@ module PayPal
|
|
12
12
|
|
13
13
|
class << self
|
14
14
|
def user_agent
|
15
|
-
@user_agent ||= "PayPalSDK/rest-sdk-ruby #{VERSION} (
|
15
|
+
@user_agent ||= "PayPalSDK/rest-sdk-ruby #{VERSION} (#{sdk_library_details})"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -25,6 +25,10 @@ describe "Payments" do
|
|
25
25
|
"description" => "This is the payment transaction description." } ] }
|
26
26
|
|
27
27
|
|
28
|
+
it "Validate user-agent" do
|
29
|
+
PayPal::SDK::REST::API.user_agent.should match "PayPalSDK/rest-sdk-ruby"
|
30
|
+
end
|
31
|
+
|
28
32
|
describe "Examples" do
|
29
33
|
describe "REST" do
|
30
34
|
it "Modifiy global configuration" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paypal-sdk-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PayPal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: paypal-sdk-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.2.
|
19
|
+
version: 0.2.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.2.
|
26
|
+
version: 0.2.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: uuidtools
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,7 +53,6 @@ files:
|
|
53
53
|
- spec/config/paypal.yml
|
54
54
|
- spec/config/cert_key.pem
|
55
55
|
- lib/paypal-sdk-rest.rb
|
56
|
-
- lib/paypal.rb
|
57
56
|
- lib/paypal-sdk/rest.rb
|
58
57
|
- lib/paypal-sdk/rest/error_hash.rb
|
59
58
|
- lib/paypal-sdk/rest/get_api.rb
|
@@ -87,7 +86,7 @@ rubyforge_project:
|
|
87
86
|
rubygems_version: 2.0.0
|
88
87
|
signing_key:
|
89
88
|
specification_version: 4
|
90
|
-
summary: PayPal
|
89
|
+
summary: The PayPal REST SDK provides Ruby APIs to create, process and manage payment.
|
91
90
|
test_files:
|
92
91
|
- spec/log/http.log
|
93
92
|
- spec/payments_examples_spec.rb
|