paypal-payouts-sdk 1.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: cae16ffc6b85208f19a7d0b8d0f3cd7b7463f7a4
4
- data.tar.gz: 916515a9a3a44c4fd342aefd56886be36d3eec98
2
+ SHA256:
3
+ metadata.gz: 598861fd1faeb51dc3004c3ce7eb867dacab94dc5bf07f0054a388745d0266ac
4
+ data.tar.gz: 57b8b3adc6b021c078d53c6e58d52644e536ea29e6c597e943818396def22d71
5
5
  SHA512:
6
- metadata.gz: 34f1aa2ed3a4cea063ebdf2c69a48602c663835fa254fa66fe966ae86ae2056d483006d28ba750472f486386b8ba33eb979fa7c7becbb51ea7b50cb5abd4e738
7
- data.tar.gz: e7d1ccfc844455a8bf477e5099473b11b67357f03c2359f4b91d1f710eda357338e3b95e6f7d3e4ef237a6062a939d98c325f06733b7768fa10968d0417d9356
6
+ metadata.gz: 379b7a34c7d71d527a676b06f8f8f59655d228e2a4210fe406adb7528700016eb99eba2eaefeafc59185a9a0680a4dd9cc12015159c2c745bbdb66bc1870d251
7
+ data.tar.gz: b57381faa439a1519a8bc21349c7fbbcb8bc75768aa990120571b7222598e31da4205311cb6cc6c4ae5610dcfbadbea0280874cbc49c4e9421db804bd3a6c7f2
@@ -0,0 +1,11 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "bundler" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "daily"
@@ -0,0 +1,70 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ master ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ master ]
20
+ schedule:
21
+ - cron: '42 8 * * 2'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: [ 'ruby' ]
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37
+ # Learn more about CodeQL language support at https://git.io/codeql-language-support
38
+
39
+ steps:
40
+ - name: Checkout repository
41
+ uses: actions/checkout@v2
42
+
43
+ # Initializes the CodeQL tools for scanning.
44
+ - name: Initialize CodeQL
45
+ uses: github/codeql-action/init@v1
46
+ with:
47
+ languages: ${{ matrix.language }}
48
+ # If you wish to specify custom queries, you can do so here or in a config file.
49
+ # By default, queries listed here will override any specified in a config file.
50
+ # Prefix the list here with "+" to use these queries and those in the config file.
51
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
52
+
53
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54
+ # If this step fails, then you should remove it and run the build manually (see below)
55
+ - name: Autobuild
56
+ uses: github/codeql-action/autobuild@v1
57
+
58
+ # ℹ️ Command-line programs to run using the OS shell.
59
+ # 📚 https://git.io/JvXDl
60
+
61
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62
+ # and modify them (or add more) to build your code if your project
63
+ # uses a compiled language
64
+
65
+ #- run: |
66
+ # make bootstrap
67
+ # make release
68
+
69
+ - name: Perform CodeQL Analysis
70
+ uses: github/codeql-action/analyze@v1
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=YOUR_SANDBOX_CLIENT_ID PAYPAL_CLIENT_SECRET=YOUR_SANDBOX_CLIENT_SECRET bundle exec rspec"
9
+ sudo: false
10
+ notifications:
11
+ recipients:
12
+ - dl-paypal-payouts-sdk@paypal.com
13
+ on_success: change
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- The PayPal Node SDK is released under the following license:
1
+ The PayPal Ruby SDK is released under the following license:
2
2
 
3
- Copyright (c) 2013-2019 PAYPAL, INC.
3
+ Copyright (c) 2013-2020 PAYPAL, INC.
4
4
 
5
5
  SDK LICENSE
6
6
 
data/README.md CHANGED
@@ -2,21 +2,41 @@
2
2
 
3
3
  ![PayPal Developer](homepage.jpg)
4
4
 
5
- __Welcome to PayPal Ruby SDK__. This repository contains PayPal's NodeJS SDK and samples for [v1/payments/payouts](https://developer.paypal.com/docs/api/payments.payouts-batch/v1/) APIs.
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/checkout/reference/server-integration/setup-sdk/) for additional information about setting up the SDK's.
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/checkout/reference/server-integration) for configuring and working with SDK without forking this code.
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::new creates a POST request to /v1/payments/payouts
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 5$ Payout!',
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 5$ Payout!',
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 5$ Payout!',
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 5$ Payout!',
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 5$ Payout!',
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::new
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::new() creates a GET request to /v1/payments/payouts/<batch-id>
120
- request = PaypalPayoutsSdk::Payouts::PayoutsGetRequest::new("PAYOUT-BATCH-ID")
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 whie executing the samples.
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
@@ -1,3 +1,3 @@
1
1
  module PayPal
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -4,9 +4,9 @@ require 'core/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'paypal-payouts-sdk'
7
- spec.version = PayPal::VERSION
8
- spec.summary = "This repository contains PayPal's Ruby SDK for Payouts REST API"
9
- spec.description = "This repository contains PayPal's Ruby SDK for Payouts REST API"
7
+ spec.version = "2.0.1"
8
+ spec.summary = "Deprecated."
9
+ spec.description = "[Deprecated] This repository contains PayPal's Ruby SDK for Payouts REST API"
10
10
  spec.authors = ["http://developer.paypal.com"]
11
11
  spec.email = 'dl-paypal-payouts-sdk@paypal.com'
12
12
  spec.homepage = 'https://github.com/paypal/Payouts-Ruby-SDK'
@@ -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.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'
@@ -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 5$ Payout!',
93
+ note: 'Your 1$ Payout!',
23
94
  amount: {
24
95
  currency: 'USD',
25
- value: '1.00'
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 5$ Payout!',
101
+ note: 'Your 1$ Payout!',
31
102
  amount: {
32
103
  currency: 'USD',
33
- value: '1.00'
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 5$ Payout!',
109
+ note: 'Your 1$ Payout!',
39
110
  amount: {
40
111
  currency: 'USD',
41
- value: '1.00'
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 5$ Payout!',
117
+ note: 'Your 1$ Payout!',
47
118
  amount: {
48
119
  currency: 'USD',
49
- value: '1.00'
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 5$ Payout!',
125
+ note: 'Your 1$ Payout!',
55
126
  amount: {
56
127
  currency: 'USD',
57
- value: '1.00'
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
- request = PayoutsPostRequest.new()
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
@@ -13,23 +13,27 @@ module Samples
13
13
 
14
14
  begin
15
15
  response = PayPalClient::client.execute(request)
16
-
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"]}"
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 " Status Code: #{ioe.status_code}"
31
- puts " Debug Id: #{ioe.result.debug_id}"
32
- puts " Response: #{ioe.result}"
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(true).result.batch_header.payout_batch_id
41
- id = Samples::GetPayouts::new().get_payouts(batch_id, true).result.items[0].payout_item_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
@@ -18,25 +18,29 @@ module Samples
18
18
 
19
19
  begin
20
20
  response = PayPalClient::client.execute(request)
21
-
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
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 " Status Code: #{ioe.status_code}"
38
- puts " Debug Id: #{ioe.result.debug_id}"
39
- puts " Response: #{ioe.result}"
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(true).result.batch_header.payout_batch_id
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.0
4
+ version: 2.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: 2020-01-17 00:00:00.000000000 Z
11
+ date: 2023-10-17 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.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.0
26
+ version: 1.0.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,13 +66,17 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: This repository contains PayPal's Ruby SDK for Payouts REST API
69
+ description: "[Deprecated] This repository contains PayPal's Ruby SDK for Payouts
70
+ REST API"
70
71
  email: dl-paypal-payouts-sdk@paypal.com
71
72
  executables: []
72
73
  extensions: []
73
74
  extra_rdoc_files: []
74
75
  files:
76
+ - ".github/dependabot.yml"
77
+ - ".github/workflows/codeql-analysis.yml"
75
78
  - ".gitignore"
79
+ - ".travis.yml"
76
80
  - Gemfile
77
81
  - LICENSE
78
82
  - README.md
@@ -102,7 +106,7 @@ homepage: https://github.com/paypal/Payouts-Ruby-SDK
102
106
  licenses:
103
107
  - https://github.com/paypal/Payouts-Ruby-SDK/blob/master/LICENSE
104
108
  metadata: {}
105
- post_install_message:
109
+ post_install_message:
106
110
  rdoc_options: []
107
111
  require_paths:
108
112
  - lib
@@ -117,9 +121,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
121
  - !ruby/object:Gem::Version
118
122
  version: '0'
119
123
  requirements: []
120
- rubyforge_project:
121
- rubygems_version: 2.5.2.3
122
- signing_key:
124
+ rubygems_version: 3.4.10
125
+ signing_key:
123
126
  specification_version: 4
124
- summary: This repository contains PayPal's Ruby SDK for Payouts REST API
127
+ summary: Deprecated.
125
128
  test_files: []