paypal-payouts-sdk 1.0.0 → 1.0.1
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 +5 -5
- data/.travis.yml +13 -0
- data/LICENSE +2 -2
- data/README.md +115 -15
- data/lib/core/version.rb +1 -1
- data/paypal-payouts-sdk.gemspec +1 -1
- data/samples/create_payouts.rb +84 -35
- data/samples/get_payout_item.rb +21 -15
- data/samples/get_payouts.rb +23 -17
- data/samples/run_all.rb +12 -0
- metadata +9 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: c6426aa92a7e63a7de2d7391e94959d6e5f43bb3c32e961cdb053151eac391c7
|
|
4
|
+
data.tar.gz: 7e3e89891ea2225ae8da2967c4ad9f63870145c33e94e76478b2ca1cff0e4e30
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e7df5c89d8b7d08fb5ca9b4539cd68fe394028d883ac4151df25f5278e15c902c5ee33ad89bac87d230e346e568079afab7418be83d22a8c9479227782c5f12b
|
|
7
|
+
data.tar.gz: 9b8e02f8c035605ba228fab69e6c5d19e864930d312f600768c2a23f66d7df19375058d0c97590b80598826065c3906ee5669d131ae57fec70d39130f4b06f90
|
data/.travis.yml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
sudo: required
|
|
2
|
+
dist: trusty
|
|
3
|
+
language: ruby
|
|
4
|
+
rvm:
|
|
5
|
+
- "2.0.0"
|
|
6
|
+
- "2.2.5"
|
|
7
|
+
- "2.3.1"
|
|
8
|
+
script: "PAYPAL_CLIENT_ID=AdV4d6nLHabWLyemrw4BKdO9LjcnioNIOgoz7vD611ObbDUL0kJQfzrdhXEBwnH8QmV-7XZjvjRWn0kg PAYPAL_CLIENT_SECRET=EPKoPC_haZMTq5uM9WXuzoxUVdgzVqHyD5avCyVC1NCIUJeVaNNUZMnzduYIqrdw-carG9LBAizFGMyK bundle exec rspec"
|
|
9
|
+
sudo: false
|
|
10
|
+
notifications:
|
|
11
|
+
recipients:
|
|
12
|
+
- dl-paypal-payouts-sdk@paypal.com
|
|
13
|
+
on_success: change
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -2,21 +2,41 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
__Welcome to PayPal Ruby SDK__. This repository contains PayPal's
|
|
5
|
+
__Welcome to PayPal Ruby SDK__. This repository contains PayPal's Ruby SDK and samples for [v1/payments/payouts](https://developer.paypal.com/docs/api/payments.payouts-batch/v1/) APIs.
|
|
6
6
|
|
|
7
7
|
This is a part of the next major PayPal SDK. It includes a simplified interface to only provide simple model objects and blueprints for HTTP calls. This repo currently contains functionality for PayPal Payouts APIs which includes [Payouts](https://developer.paypal.com/docs/api/payments.payouts-batch/v1/).
|
|
8
8
|
|
|
9
|
-
Please refer to the [PayPal Payouts Integration Guide](https://developer.paypal.com/docs/payouts/) for more information. Also refer to [Setup your SDK](https://developer.paypal.com/docs/
|
|
9
|
+
Please refer to the [PayPal Payouts Integration Guide](https://developer.paypal.com/docs/payouts/) for more information. Also refer to [Setup your SDK](https://developer.paypal.com/docs/payouts/reference/setup-sdk) for additional information about setting up the SDK.
|
|
10
10
|
|
|
11
11
|
## Prerequisites
|
|
12
12
|
|
|
13
13
|
- Ruby 2.0.0 or above
|
|
14
14
|
- Bundler
|
|
15
15
|
|
|
16
|
+
## Installations
|
|
17
|
+
|
|
18
|
+
Add this line to your application's Gemfile:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
gem 'paypal-payouts-sdk'
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
And then execute:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
$ bundle
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Or install it yourself as:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
$ gem install paypal-payouts-sdk
|
|
34
|
+
```
|
|
35
|
+
|
|
16
36
|
## Usage
|
|
17
37
|
### Binaries
|
|
18
38
|
|
|
19
|
-
It is not mandatory to fork this repository for using the PayPal SDK. You can refer [PayPal Payouts SDK](https://developer.paypal.com/docs/
|
|
39
|
+
It is not mandatory to fork this repository for using the PayPal SDK. You can refer [PayPal Payouts SDK](https://developer.paypal.com/docs/payouts/reference/setup-sdk/#install-the-sdk) for configuring and working with SDK without forking this code.
|
|
20
40
|
|
|
21
41
|
For contributing or referring the samples, You can fork/refer this repository.
|
|
22
42
|
|
|
@@ -38,12 +58,12 @@ client = PayPal::PayPalHttpClient.new(environment)
|
|
|
38
58
|
## Examples
|
|
39
59
|
|
|
40
60
|
### Creating a Payouts
|
|
41
|
-
|
|
61
|
+
This code creates a Payout and prints the batch_id for the Payout.
|
|
42
62
|
#### Code:
|
|
43
63
|
```ruby
|
|
44
64
|
|
|
45
65
|
# Construct a request object and set desired parameters
|
|
46
|
-
# Here, PayoutsPostRequest
|
|
66
|
+
# Here, PayoutsPostRequest.new creates a POST request to /v1/payments/payouts
|
|
47
67
|
body = {
|
|
48
68
|
sender_batch_header: {
|
|
49
69
|
recipient_type: 'EMAIL',
|
|
@@ -53,7 +73,7 @@ body = {
|
|
|
53
73
|
email_subject: 'This is a test transaction from SDK'
|
|
54
74
|
},
|
|
55
75
|
items: [{
|
|
56
|
-
note: 'Your
|
|
76
|
+
note: 'Your $1 Payout!',
|
|
57
77
|
amount: {
|
|
58
78
|
currency: 'USD',
|
|
59
79
|
value: '1.00'
|
|
@@ -61,7 +81,7 @@ body = {
|
|
|
61
81
|
receiver: 'payout-sdk-1@paypal.com',
|
|
62
82
|
sender_item_id: 'Test_txn_1'
|
|
63
83
|
}, {
|
|
64
|
-
note: 'Your
|
|
84
|
+
note: 'Your $1 Payout!',
|
|
65
85
|
amount: {
|
|
66
86
|
currency: 'USD',
|
|
67
87
|
value: '1.00'
|
|
@@ -69,7 +89,7 @@ body = {
|
|
|
69
89
|
receiver: 'payout-sdk-2@paypal.com',
|
|
70
90
|
sender_item_id: 'Test_txn_2'
|
|
71
91
|
}, {
|
|
72
|
-
note: 'Your
|
|
92
|
+
note: 'Your $1 Payout!',
|
|
73
93
|
amount: {
|
|
74
94
|
currency: 'USD',
|
|
75
95
|
value: '1.00'
|
|
@@ -77,7 +97,7 @@ body = {
|
|
|
77
97
|
receiver: 'payout-sdk-3@paypal.com',
|
|
78
98
|
sender_item_id: 'Test_txn_3'
|
|
79
99
|
}, {
|
|
80
|
-
note: 'Your
|
|
100
|
+
note: 'Your $1 Payout!',
|
|
81
101
|
amount: {
|
|
82
102
|
currency: 'USD',
|
|
83
103
|
value: '1.00'
|
|
@@ -85,7 +105,7 @@ body = {
|
|
|
85
105
|
receiver: 'payout-sdk-4@paypal.com',
|
|
86
106
|
sender_item_id: 'Test_txn_4'
|
|
87
107
|
}, {
|
|
88
|
-
note: 'Your
|
|
108
|
+
note: 'Your $1 Payout!',
|
|
89
109
|
amount: {
|
|
90
110
|
currency: 'USD',
|
|
91
111
|
value: '1.00'
|
|
@@ -94,7 +114,7 @@ body = {
|
|
|
94
114
|
sender_item_id: 'Test_txn_5'
|
|
95
115
|
}]
|
|
96
116
|
}
|
|
97
|
-
request = PaypalPayoutsSdk::Payouts::PayoutsPostRequest
|
|
117
|
+
request = PaypalPayoutsSdk::Payouts::PayoutsPostRequest.new
|
|
98
118
|
request.request_body(body)
|
|
99
119
|
|
|
100
120
|
begin
|
|
@@ -111,13 +131,93 @@ rescue PayPalHttp::HttpError => ioe
|
|
|
111
131
|
end
|
|
112
132
|
```
|
|
113
133
|
|
|
134
|
+
### Handle API Failure
|
|
135
|
+
This will create a Payout with validation failure to showcase how to parse the failed response entity. Refer samples for more scenarios
|
|
136
|
+
```ruby
|
|
137
|
+
|
|
138
|
+
# Construct a request object and set desired parameters
|
|
139
|
+
# Here, PayoutsPostRequest.new creates a POST request to /v1/payments/payouts
|
|
140
|
+
body = {
|
|
141
|
+
sender_batch_header: {
|
|
142
|
+
recipient_type: 'EMAIL',
|
|
143
|
+
email_message: 'SDK payouts test txn',
|
|
144
|
+
note: 'Enjoy your Payout!!',
|
|
145
|
+
sender_batch_id: 'Test_SDK_1',
|
|
146
|
+
email_subject: 'This is a test transaction from SDK'
|
|
147
|
+
},
|
|
148
|
+
items: [{
|
|
149
|
+
note: 'Your $1 Payout!',
|
|
150
|
+
amount: {
|
|
151
|
+
currency: 'USD',
|
|
152
|
+
value: '1.0.0'
|
|
153
|
+
},
|
|
154
|
+
receiver: 'payout-sdk-1@paypal.com',
|
|
155
|
+
sender_item_id: 'Test_txn_1'
|
|
156
|
+
}, {
|
|
157
|
+
note: 'Your $1 Payout!',
|
|
158
|
+
amount: {
|
|
159
|
+
currency: 'USD',
|
|
160
|
+
value: '1.0.0'
|
|
161
|
+
},
|
|
162
|
+
receiver: 'payout-sdk-2@paypal.com',
|
|
163
|
+
sender_item_id: 'Test_txn_2'
|
|
164
|
+
}, {
|
|
165
|
+
note: 'Your $1 Payout!',
|
|
166
|
+
amount: {
|
|
167
|
+
currency: 'USD',
|
|
168
|
+
value: '1.0.0'
|
|
169
|
+
},
|
|
170
|
+
receiver: 'payout-sdk-3@paypal.com',
|
|
171
|
+
sender_item_id: 'Test_txn_3'
|
|
172
|
+
}, {
|
|
173
|
+
note: 'Your $1 Payout!',
|
|
174
|
+
amount: {
|
|
175
|
+
currency: 'USD',
|
|
176
|
+
value: '1.0.0'
|
|
177
|
+
},
|
|
178
|
+
receiver: 'payout-sdk-4@paypal.com',
|
|
179
|
+
sender_item_id: 'Test_txn_4'
|
|
180
|
+
}, {
|
|
181
|
+
note: 'Your $1 Payout!',
|
|
182
|
+
amount: {
|
|
183
|
+
currency: 'USD',
|
|
184
|
+
value: '1.0.0'
|
|
185
|
+
},
|
|
186
|
+
receiver: 'payout-sdk-5@paypal.com',
|
|
187
|
+
sender_item_id: 'Test_txn_5'
|
|
188
|
+
}]
|
|
189
|
+
}
|
|
190
|
+
request = PaypalPayoutsSdk::Payouts::PayoutsPostRequest.new
|
|
191
|
+
request.request_body(body)
|
|
192
|
+
|
|
193
|
+
begin
|
|
194
|
+
# Call API with your client and get a response for your call
|
|
195
|
+
client.execute(request)
|
|
196
|
+
|
|
197
|
+
rescue PayPalHttp::HttpError => ioe
|
|
198
|
+
# Something went wrong server-side
|
|
199
|
+
puts "Status Code: #{ioe.status_code}"
|
|
200
|
+
puts "Response: #{ioe.result}"
|
|
201
|
+
puts "Name: #{ioe.result.name}"
|
|
202
|
+
puts "Message: #{ioe.result.message}"
|
|
203
|
+
puts "Information link: #{ioe.result.information_link}"
|
|
204
|
+
puts "Debug Id: #{ioe.result.debug_id}"
|
|
205
|
+
puts "Details: "
|
|
206
|
+
ioe.result.details.each { |detail|
|
|
207
|
+
puts "Error Location: #{detail["location"]}"
|
|
208
|
+
puts "Error Field: #{detail["field"]}"
|
|
209
|
+
puts "Error issue: #{detail["issue"]}"
|
|
210
|
+
}
|
|
211
|
+
end
|
|
212
|
+
```
|
|
213
|
+
|
|
114
214
|
### Retrieve a Payout Batch
|
|
115
215
|
Pass the batch_id from the previous sample to retrieve Payouts batch details
|
|
116
216
|
|
|
117
217
|
#### Code:
|
|
118
218
|
```ruby
|
|
119
|
-
# Here, PayoutsGetRequest
|
|
120
|
-
request = PaypalPayoutsSdk::Payouts::PayoutsGetRequest
|
|
219
|
+
# Here, PayoutsGetRequest.new creates a GET request to /v1/payments/payouts/<batch-id>
|
|
220
|
+
request = PaypalPayoutsSdk::Payouts::PayoutsGetRequest.new("PAYOUT-BATCH-ID")
|
|
121
221
|
request.page(1)
|
|
122
222
|
request.page_size(10)
|
|
123
223
|
request.total_required(true)
|
|
@@ -150,8 +250,8 @@ You can start off by trying out [Payouts Samples](samples/run_all.rb)
|
|
|
150
250
|
|
|
151
251
|
To try out different samples head to [this link](samples)
|
|
152
252
|
|
|
153
|
-
Note: Update the `paypal_client.rb` with your sandbox client credentials or pass your client credentials as environment variable
|
|
253
|
+
Note: Update the `paypal_client.rb` with your sandbox client credentials or pass your client credentials as environment variable while executing the samples.
|
|
154
254
|
|
|
155
255
|
|
|
156
256
|
## License
|
|
157
|
-
Code released under [SDK LICENSE](LICENSE)
|
|
257
|
+
Code released under [SDK LICENSE](LICENSE)
|
data/lib/core/version.rb
CHANGED
data/paypal-payouts-sdk.gemspec
CHANGED
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
20
20
|
spec.require_paths = ['lib']
|
|
21
21
|
|
|
22
|
-
spec.add_dependency 'paypalhttp', '~> 1.0.
|
|
22
|
+
spec.add_dependency 'paypalhttp', '~> 1.0.1'
|
|
23
23
|
|
|
24
24
|
spec.add_development_dependency 'rake', '~> 10.0'
|
|
25
25
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
data/samples/create_payouts.rb
CHANGED
|
@@ -9,7 +9,78 @@ module Samples
|
|
|
9
9
|
# Calls the create batch api (POST - /v1/payments/payouts)
|
|
10
10
|
# A maximum of 15000 payout items are supported in a single batch request
|
|
11
11
|
def create_payouts(debug = false)
|
|
12
|
+
body = build_create_payload()
|
|
13
|
+
request = PayoutsPostRequest.new()
|
|
14
|
+
request.request_body(body)
|
|
15
|
+
|
|
16
|
+
begin
|
|
17
|
+
response = PayPalClient::client.execute(request)
|
|
18
|
+
if debug
|
|
19
|
+
puts "Status Code: #{response.status_code}"
|
|
20
|
+
puts "Status: #{response.result.status}"
|
|
21
|
+
puts "Payout Batch ID: #{response.result.batch_header.payout_batch_id}"
|
|
22
|
+
puts "Payout Batch Status: #{response.result.batch_header.batch_status}"
|
|
23
|
+
puts "Links: "
|
|
24
|
+
for link in response.result.links
|
|
25
|
+
# this could also be called as link.rel or link.href but as method is a reserved keyword for ruby avoid calling link.method
|
|
26
|
+
puts "\t#{link["rel"]}: #{link["href"]}\tCall Type: #{link["method"]}"
|
|
27
|
+
end
|
|
28
|
+
puts PayPalClient::openstruct_to_hash(response.result).to_json
|
|
29
|
+
end
|
|
30
|
+
return response
|
|
31
|
+
rescue PayPalHttp::HttpError => ioe
|
|
32
|
+
# Exception occured while processing the payouts.
|
|
33
|
+
puts " Status Code: #{ioe.status_code}"
|
|
34
|
+
puts " Debug Id: #{ioe.result.debug_id}"
|
|
35
|
+
puts " Response: #{ioe.result}"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Creates a payout batch with 5 payout items having invalid amount
|
|
40
|
+
# Calls the create batch api (POST - /v1/payments/payouts)
|
|
41
|
+
# A maximum of 15000 payout items are supported in a single batch request
|
|
42
|
+
def create_payouts_failure(debug = false)
|
|
43
|
+
body = build_create_payload(true)
|
|
44
|
+
request = PayoutsPostRequest.new()
|
|
45
|
+
request.request_body(body)
|
|
46
|
+
|
|
47
|
+
begin
|
|
48
|
+
response = PayPalClient::client.execute(request)
|
|
49
|
+
if debug
|
|
50
|
+
puts "Status Code: #{response.status_code}"
|
|
51
|
+
puts "Status: #{response.result.status}"
|
|
52
|
+
puts "Payout Batch ID: #{response.result.batch_header.payout_batch_id}"
|
|
53
|
+
puts "Payout Batch Status: #{response.result.batch_header.batch_status}"
|
|
54
|
+
puts "Links: "
|
|
55
|
+
for link in response.result.links
|
|
56
|
+
# this could also be called as link.rel or link.href but as method is a reserved keyword for ruby avoid calling link.method
|
|
57
|
+
puts "\t#{link["rel"]}: #{link["href"]}\tCall Type: #{link["method"]}"
|
|
58
|
+
end
|
|
59
|
+
puts PayPalClient::openstruct_to_hash(response.result).to_json
|
|
60
|
+
end
|
|
61
|
+
return response
|
|
62
|
+
rescue PayPalHttp::HttpError => ioe
|
|
63
|
+
# Exception occured while processing the payouts.
|
|
64
|
+
puts "Status Code: #{ioe.status_code}"
|
|
65
|
+
puts "Response: #{ioe.result}"
|
|
66
|
+
puts "Name: #{ioe.result.name}"
|
|
67
|
+
puts "Message: #{ioe.result.message}"
|
|
68
|
+
puts "Information link: #{ioe.result.information_link}"
|
|
69
|
+
puts "Debug Id: #{ioe.result.debug_id}"
|
|
70
|
+
puts "Details: "
|
|
71
|
+
ioe.result.details.each { |detail|
|
|
72
|
+
puts "Error Location: #{detail["location"]}"
|
|
73
|
+
puts "Error Field: #{detail["field"]}"
|
|
74
|
+
puts "Error issue: #{detail["issue"]}"
|
|
75
|
+
}
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
private
|
|
80
|
+
|
|
81
|
+
def build_create_payload(include_validation_failure = false)
|
|
12
82
|
sender_batch_id = 'Test_sdk_' + SecureRandom.base64(6)
|
|
83
|
+
amount = include_validation_failure ? '1.0.0' : '1.00'
|
|
13
84
|
body = {
|
|
14
85
|
sender_batch_header: {
|
|
15
86
|
recipient_type: 'EMAIL',
|
|
@@ -19,77 +90,55 @@ module Samples
|
|
|
19
90
|
email_subject: 'This is a test transaction from SDK'
|
|
20
91
|
},
|
|
21
92
|
items: [{
|
|
22
|
-
note: 'Your
|
|
93
|
+
note: 'Your 1$ Payout!',
|
|
23
94
|
amount: {
|
|
24
95
|
currency: 'USD',
|
|
25
|
-
value:
|
|
96
|
+
value: amount
|
|
26
97
|
},
|
|
27
98
|
receiver: 'payout-sdk-1@paypal.com',
|
|
28
99
|
sender_item_id: 'Test_txn_1'
|
|
29
100
|
}, {
|
|
30
|
-
note: 'Your
|
|
101
|
+
note: 'Your 1$ Payout!',
|
|
31
102
|
amount: {
|
|
32
103
|
currency: 'USD',
|
|
33
|
-
value:
|
|
104
|
+
value: amount
|
|
34
105
|
},
|
|
35
106
|
receiver: 'payout-sdk-2@paypal.com',
|
|
36
107
|
sender_item_id: 'Test_txn_2'
|
|
37
108
|
}, {
|
|
38
|
-
note: 'Your
|
|
109
|
+
note: 'Your 1$ Payout!',
|
|
39
110
|
amount: {
|
|
40
111
|
currency: 'USD',
|
|
41
|
-
value:
|
|
112
|
+
value: amount
|
|
42
113
|
},
|
|
43
114
|
receiver: 'payout-sdk-3@paypal.com',
|
|
44
115
|
sender_item_id: 'Test_txn_3'
|
|
45
116
|
}, {
|
|
46
|
-
note: 'Your
|
|
117
|
+
note: 'Your 1$ Payout!',
|
|
47
118
|
amount: {
|
|
48
119
|
currency: 'USD',
|
|
49
|
-
value:
|
|
120
|
+
value: amount
|
|
50
121
|
},
|
|
51
122
|
receiver: 'payout-sdk-4@paypal.com',
|
|
52
123
|
sender_item_id: 'Test_txn_4'
|
|
53
124
|
}, {
|
|
54
|
-
note: 'Your
|
|
125
|
+
note: 'Your 1$ Payout!',
|
|
55
126
|
amount: {
|
|
56
127
|
currency: 'USD',
|
|
57
|
-
value:
|
|
128
|
+
value: amount
|
|
58
129
|
},
|
|
59
130
|
receiver: 'payout-sdk-5@paypal.com',
|
|
60
131
|
sender_item_id: 'Test_txn_5'
|
|
61
132
|
}]
|
|
62
133
|
}
|
|
63
|
-
|
|
64
|
-
request.request_body(body)
|
|
65
|
-
|
|
66
|
-
begin
|
|
67
|
-
response = PayPalClient::client.execute(request)
|
|
68
|
-
if debug
|
|
69
|
-
puts "Status Code: #{response.status_code}"
|
|
70
|
-
puts "Status: #{response.result.status}"
|
|
71
|
-
puts "Payout Batch ID: #{response.result.batch_header.payout_batch_id}"
|
|
72
|
-
puts "Payout Batch Status: #{response.result.batch_header.batch_status}"
|
|
73
|
-
puts "Links: "
|
|
74
|
-
for link in response.result.links
|
|
75
|
-
# this could also be called as link.rel or link.href but as method is a reserved keyword for ruby avoid calling link.method
|
|
76
|
-
puts "\t#{link["rel"]}: #{link["href"]}\tCall Type: #{link["method"]}"
|
|
77
|
-
end
|
|
78
|
-
puts PayPalClient::openstruct_to_hash(response.result).to_json
|
|
79
|
-
end
|
|
80
|
-
return response
|
|
81
|
-
rescue PayPalHttp::HttpError => ioe
|
|
82
|
-
# Exception occured while processing the payouts.
|
|
83
|
-
puts " Status Code: #{ioe.status_code}"
|
|
84
|
-
puts " Debug Id: #{ioe.result.debug_id}"
|
|
85
|
-
puts " Response: #{ioe.result}"
|
|
86
|
-
end
|
|
134
|
+
return body
|
|
87
135
|
end
|
|
88
|
-
|
|
89
136
|
end
|
|
90
137
|
end
|
|
91
138
|
|
|
92
139
|
# This is the driver function which invokes the create_payouts function to create an payouts batch.
|
|
93
140
|
if __FILE__ == $0
|
|
94
141
|
Samples::CreatePayouts::new().create_payouts(true)
|
|
142
|
+
#Simulate failure in create payload to showcase validation failure and how to parse the reason for failure
|
|
143
|
+
Samples::CreatePayouts::new().create_payouts_failure(true)
|
|
95
144
|
end
|
data/samples/get_payout_item.rb
CHANGED
|
@@ -13,23 +13,27 @@ module Samples
|
|
|
13
13
|
|
|
14
14
|
begin
|
|
15
15
|
response = PayPalClient::client.execute(request)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
if debug
|
|
17
|
+
puts "Status Code: #{response.status_code}"
|
|
18
|
+
puts "Status: #{response.result.status}"
|
|
19
|
+
puts "Payout Item Id: #{response.result.payout_item_id}"
|
|
20
|
+
puts "Payout Item Status: #{response.result.transaction_status}"
|
|
21
|
+
puts "Links: "
|
|
22
|
+
for link in response.result.links
|
|
23
|
+
# this could also be called as link.rel or link.href but as method is a reserved keyword for ruby avoid calling link.method
|
|
24
|
+
puts "\t#{link["rel"]}: #{link["href"]}\tCall Type: #{link["method"]}"
|
|
25
|
+
end
|
|
26
|
+
puts PayPalClient::openstruct_to_hash(response.result).to_json
|
|
25
27
|
end
|
|
26
|
-
puts PayPalClient::openstruct_to_hash(response.result).to_json
|
|
27
28
|
return response
|
|
28
29
|
rescue PayPalHttp::HttpError => ioe
|
|
29
30
|
# Exception occured while processing the payouts.
|
|
30
|
-
puts "
|
|
31
|
-
puts "
|
|
32
|
-
puts "
|
|
31
|
+
puts "Status Code: #{ioe.status_code}"
|
|
32
|
+
puts "Response: #{ioe.result}"
|
|
33
|
+
puts "Name: #{ioe.result.name}"
|
|
34
|
+
puts "Message: #{ioe.result.message}"
|
|
35
|
+
puts "Information link: #{ioe.result.information_link}"
|
|
36
|
+
puts "Debug Id: #{ioe.result.debug_id}"
|
|
33
37
|
end
|
|
34
38
|
end
|
|
35
39
|
end
|
|
@@ -37,7 +41,9 @@ end
|
|
|
37
41
|
|
|
38
42
|
# This is the driver function which invokes the get_payout_item function to retrieve a Payout Item
|
|
39
43
|
if __FILE__ == $0
|
|
40
|
-
batch_id = Samples::CreatePayouts::new().create_payouts(
|
|
41
|
-
id = Samples::GetPayouts::new().get_payouts(batch_id
|
|
44
|
+
batch_id = Samples::CreatePayouts::new().create_payouts().result.batch_header.payout_batch_id
|
|
45
|
+
id = Samples::GetPayouts::new().get_payouts(batch_id).result.items[0].payout_item_id
|
|
42
46
|
Samples::GetPayoutItem::new().get_payout_item(id, true)
|
|
47
|
+
puts "Retrieve an invalid payout item id"
|
|
48
|
+
Samples::GetPayoutItem::new().get_payout_item("DUMMY", true)
|
|
43
49
|
end
|
data/samples/get_payouts.rb
CHANGED
|
@@ -18,25 +18,29 @@ module Samples
|
|
|
18
18
|
|
|
19
19
|
begin
|
|
20
20
|
response = PayPalClient::client.execute(request)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
if debug
|
|
22
|
+
puts "Status Code: #{response.status_code}"
|
|
23
|
+
puts "Status: #{response.result.status}"
|
|
24
|
+
puts "Payout Batch ID: #{response.result.batch_header.payout_batch_id}"
|
|
25
|
+
puts "Payout Batch Status: #{response.result.batch_header.batch_status}"
|
|
26
|
+
puts "Items count: #{response.result.items.length}"
|
|
27
|
+
puts "First item id: #{response.result.items[0].payout_item_id}"
|
|
28
|
+
puts "Links: "
|
|
29
|
+
for link in response.result.links
|
|
30
|
+
# this could also be called as link.rel or link.href but as method is a reserved keyword for ruby avoid calling link.method
|
|
31
|
+
puts "\t#{link["rel"]}: #{link["href"]}\tCall Type: #{link["method"]}"
|
|
32
|
+
end
|
|
33
|
+
puts PayPalClient::openstruct_to_hash(response.result).to_json
|
|
34
|
+
end
|
|
34
35
|
return response
|
|
35
36
|
rescue PayPalHttp::HttpError => ioe
|
|
36
37
|
# Exception occured while processing the payouts.
|
|
37
|
-
puts "
|
|
38
|
-
puts "
|
|
39
|
-
puts "
|
|
38
|
+
puts "Status Code: #{ioe.status_code}"
|
|
39
|
+
puts "Response: #{ioe.result}"
|
|
40
|
+
puts "Name: #{ioe.result.name}"
|
|
41
|
+
puts "Message: #{ioe.result.message}"
|
|
42
|
+
puts "Information link: #{ioe.result.information_link}"
|
|
43
|
+
puts "Debug Id: #{ioe.result.debug_id}"
|
|
40
44
|
end
|
|
41
45
|
end
|
|
42
46
|
end
|
|
@@ -44,6 +48,8 @@ end
|
|
|
44
48
|
|
|
45
49
|
# This is the driver function which invokes the get_payouts function to retrieve a Payouts Batch
|
|
46
50
|
if __FILE__ == $0
|
|
47
|
-
id = Samples::CreatePayouts::new().create_payouts(
|
|
51
|
+
id = Samples::CreatePayouts::new().create_payouts().result.batch_header.payout_batch_id
|
|
48
52
|
Samples::GetPayouts::new().get_payouts(id, true)
|
|
53
|
+
puts "Retrieve an invalid payout id"
|
|
54
|
+
Samples::GetPayouts::new().get_payouts("DUMMY", true)
|
|
49
55
|
end
|
data/samples/run_all.rb
CHANGED
|
@@ -33,6 +33,10 @@ if create_resp.status_code == 201
|
|
|
33
33
|
cancel_resp = Samples::CancelPayoutItem.new().cancel_payout_item(item_id, true)
|
|
34
34
|
if cancel_resp.status_code == 200
|
|
35
35
|
puts "Successfully cancelled unclaimed Payouts item with id: #{item_id}"
|
|
36
|
+
|
|
37
|
+
# Run cancel failure scenario
|
|
38
|
+
puts "Simulate failure on cancelling an already cancelled Payout item with id: #{item_id}"
|
|
39
|
+
Samples::CancelPayoutItem.new().cancel_payout_item(item_id, true)
|
|
36
40
|
else
|
|
37
41
|
puts "Failed to cancel unclaimed Payouts item with id: #{item_id}"
|
|
38
42
|
end
|
|
@@ -49,3 +53,11 @@ if create_resp.status_code == 201
|
|
|
49
53
|
else
|
|
50
54
|
puts "Failed to crate Payouts batch"
|
|
51
55
|
end
|
|
56
|
+
|
|
57
|
+
# Execute all failure cases
|
|
58
|
+
puts "Create a payout with validation failure"
|
|
59
|
+
Samples::CreatePayouts::new().create_payouts_failure(true)
|
|
60
|
+
puts "Retrieving an invalid payout"
|
|
61
|
+
Samples::GetPayouts::new().get_payouts("DUMMY", true)
|
|
62
|
+
puts "Retrieving an invalid payout item"
|
|
63
|
+
Samples::GetPayoutItem::new().get_payout_item("DUMMY", true)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: paypal-payouts-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- http://developer.paypal.com
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-09-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: paypalhttp
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 1.0.
|
|
19
|
+
version: 1.0.1
|
|
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: 1.0.
|
|
26
|
+
version: 1.0.1
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rake
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -73,6 +73,7 @@ extensions: []
|
|
|
73
73
|
extra_rdoc_files: []
|
|
74
74
|
files:
|
|
75
75
|
- ".gitignore"
|
|
76
|
+
- ".travis.yml"
|
|
76
77
|
- Gemfile
|
|
77
78
|
- LICENSE
|
|
78
79
|
- README.md
|
|
@@ -102,7 +103,7 @@ homepage: https://github.com/paypal/Payouts-Ruby-SDK
|
|
|
102
103
|
licenses:
|
|
103
104
|
- https://github.com/paypal/Payouts-Ruby-SDK/blob/master/LICENSE
|
|
104
105
|
metadata: {}
|
|
105
|
-
post_install_message:
|
|
106
|
+
post_install_message:
|
|
106
107
|
rdoc_options: []
|
|
107
108
|
require_paths:
|
|
108
109
|
- lib
|
|
@@ -117,9 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
117
118
|
- !ruby/object:Gem::Version
|
|
118
119
|
version: '0'
|
|
119
120
|
requirements: []
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
signing_key:
|
|
121
|
+
rubygems_version: 3.0.9
|
|
122
|
+
signing_key:
|
|
123
123
|
specification_version: 4
|
|
124
124
|
summary: This repository contains PayPal's Ruby SDK for Payouts REST API
|
|
125
125
|
test_files: []
|