paypal-payouts-sdk 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cae16ffc6b85208f19a7d0b8d0f3cd7b7463f7a4
4
+ data.tar.gz: 916515a9a3a44c4fd342aefd56886be36d3eec98
5
+ SHA512:
6
+ metadata.gz: 34f1aa2ed3a4cea063ebdf2c69a48602c663835fa254fa66fe966ae86ae2056d483006d28ba750472f486386b8ba33eb979fa7c7becbb51ea7b50cb5abd4e738
7
+ data.tar.gz: e7d1ccfc844455a8bf477e5099473b11b67357f03c2359f4b91d1f710eda357338e3b95e6f7d3e4ef237a6062a939d98c325f06733b7768fa10968d0417d9356
data/.gitignore ADDED
@@ -0,0 +1,141 @@
1
+
2
+ # Created by https://www.gitignore.io/api/ruby,rubymine+all
3
+
4
+ ### Ruby ###
5
+ *.gem
6
+ *.rbc
7
+ /.config
8
+ /coverage/
9
+ /InstalledFiles
10
+ /pkg/
11
+ /spec/reports/
12
+ /spec/examples.txt
13
+ /test/tmp/
14
+ /test/version_tmp/
15
+ /tmp/
16
+
17
+ # Used by dotenv library to load environment variables.
18
+ # .env
19
+
20
+ ## Specific to RubyMotion:
21
+ .dat*
22
+ .repl_history
23
+ build/
24
+ *.bridgesupport
25
+ build-iPhoneOS/
26
+ build-iPhoneSimulator/
27
+
28
+ ## Specific to RubyMotion (use of CocoaPods):
29
+ #
30
+ # We recommend against adding the Pods directory to your .gitignore. However
31
+ # you should judge for yourself, the pros and cons are mentioned at:
32
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
33
+ #
34
+ # vendor/Pods/
35
+
36
+ ## Documentation cache and generated files:
37
+ /.yardoc/
38
+ /_yardoc/
39
+ /doc/
40
+ /rdoc/
41
+
42
+ ## Environment normalization:
43
+ /.bundle/
44
+ /vendor/bundle
45
+ /lib/bundler/man/
46
+
47
+ # for a library or gem, you might want to ignore these files since the code is
48
+ # intended to run in multiple environments; otherwise, check them in:
49
+ Gemfile.lock
50
+ # .ruby-version
51
+ # .ruby-gemset
52
+
53
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
54
+ .rvmrc
55
+
56
+ ### RubyMine+all ###
57
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
58
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
59
+
60
+ # User-specific stuff
61
+ .idea/**/workspace.xml
62
+ .idea/**/tasks.xml
63
+ .idea/**/usage.statistics.xml
64
+ .idea/**/dictionaries
65
+ .idea/**/shelf
66
+
67
+ # Sensitive or high-churn files
68
+ .idea/**/dataSources/
69
+ .idea/**/dataSources.ids
70
+ .idea/**/dataSources.local.xml
71
+ .idea/**/sqlDataSources.xml
72
+ .idea/**/dynamic.xml
73
+ .idea/**/uiDesigner.xml
74
+ .idea/**/dbnavigator.xml
75
+
76
+ # Gradle
77
+ .idea/**/gradle.xml
78
+ .idea/**/libraries
79
+
80
+ # Gradle and Maven with auto-import
81
+ # When using Gradle or Maven with auto-import, you should exclude module files,
82
+ # since they will be recreated, and may cause churn. Uncomment if using
83
+ # auto-import.
84
+ # .idea/modules.xml
85
+ # .idea/*.iml
86
+ # .idea/modules
87
+
88
+ # CMake
89
+ cmake-build-*/
90
+
91
+ # Mongo Explorer plugin
92
+ .idea/**/mongoSettings.xml
93
+
94
+ # File-based project format
95
+ *.iws
96
+
97
+ # IntelliJ
98
+ out/
99
+
100
+ #Visual Studio Code Files
101
+ .vscode/
102
+
103
+ #Eclipse Files
104
+ .project
105
+
106
+ # mpeltonen/sbt-idea plugin
107
+ .idea_modules/
108
+
109
+ # JIRA plugin
110
+ atlassian-ide-plugin.xml
111
+
112
+ # Cursive Clojure plugin
113
+ .idea/replstate.xml
114
+
115
+ # Crashlytics plugin (for Android Studio and IntelliJ)
116
+ com_crashlytics_export_strings.xml
117
+ crashlytics.properties
118
+ crashlytics-build.properties
119
+ fabric.properties
120
+
121
+ # Editor-based Rest Client
122
+ .idea/httpRequests
123
+
124
+ ### RubyMine+all Patch ###
125
+ # Ignores the whole .idea folder and all .iml files
126
+ # See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
127
+
128
+ .idea/
129
+
130
+ # Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
131
+
132
+ *.iml
133
+ modules.xml
134
+ .idea/misc.xml
135
+ *.ipr
136
+
137
+ # Mac OS
138
+ .DS_Store
139
+
140
+
141
+ # End of https://www.gitignore.io/api/ruby,rubymine+all
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,86 @@
1
+ The PayPal Node SDK is released under the following license:
2
+
3
+ Copyright (c) 2013-2019 PAYPAL, INC.
4
+
5
+ SDK LICENSE
6
+
7
+ NOTICE TO USER: PayPal, Inc. is providing the Software and Documentation for use under the terms of
8
+ this Agreement. Any use, reproduction, modification or distribution of the Software or Documentation,
9
+ or any derivatives or portions hereof, constitutes your acceptance of this Agreement.
10
+
11
+ As used in this Agreement, "PayPal" means PayPal, Inc. "Software" means the software code accompanying
12
+ this agreement. "Documentation" means the documents, specifications and all other items accompanying
13
+ this Agreement other than the Software.
14
+
15
+ 1. LICENSE GRANT Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive,
16
+ worldwide, royalty free license to use, reproduce, prepare derivative works from, publicly display,
17
+ publicly perform, distribute and sublicense the Software for any purpose, provided the copyright notice
18
+ below appears in a conspicuous location within the source code of the distributed Software and this
19
+ license is distributed in the supporting documentation of the Software you distribute. Furthermore,
20
+ you must comply with all third party licenses in order to use the third party software contained in the
21
+ Software.
22
+
23
+ Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive, worldwide, royalty free
24
+ license to use, reproduce, publicly display, publicly perform, distribute and sublicense the Documentation
25
+ for any purpose. You may not modify the Documentation.
26
+
27
+ No title to the intellectual property in the Software or Documentation is transferred to you under the
28
+ terms of this Agreement. You do not acquire any rights to the Software or the Documentation except as
29
+ expressly set forth in this Agreement.
30
+
31
+ If you choose to distribute the Software in a commercial product, you do so with the understanding that
32
+ you agree to defend, indemnify and hold harmless PayPal and its suppliers against any losses, damages and
33
+ costs arising from the claims, lawsuits or other legal actions arising out of such distribution. You may
34
+ distribute the Software in object code form under your own license, provided that your license agreement:
35
+
36
+ (a) complies with the terms and conditions of this license agreement;
37
+
38
+ (b) effectively disclaims all warranties and conditions, express or implied, on behalf of PayPal;
39
+
40
+ (c) effectively excludes all liability for damages on behalf of PayPal;
41
+
42
+ (d) states that any provisions that differ from this Agreement are offered by you alone and not PayPal; and
43
+
44
+ (e) states that the Software is available from you or PayPal and informs licensees how to obtain it in a
45
+ reasonable manner on or through a medium customarily used for software exchange.
46
+
47
+ 2. DISCLAIMER OF WARRANTY
48
+ PAYPAL LICENSES THE SOFTWARE AND DOCUMENTATION TO YOU ONLY ON AN "AS IS" BASIS WITHOUT WARRANTIES OR CONDITIONS
49
+ OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY WARRANTIES OR CONDITIONS OF TITLE,
50
+ NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. PAYPAL MAKES NO WARRANTY THAT THE
51
+ SOFTWARE OR DOCUMENTATION WILL BE ERROR-FREE. Each user of the Software or Documentation is solely responsible
52
+ for determining the appropriateness of using and distributing the Software and Documentation and assumes all
53
+ risks associated with its exercise of rights under this Agreement, including but not limited to the risks and
54
+ costs of program errors, compliance with applicable laws, damage to or loss of data, programs, or equipment,
55
+ and unavailability or interruption of operations. Use of the Software and Documentation is made with the
56
+ understanding that PayPal will not provide you with any technical or customer support or maintenance. Some
57
+ states or jurisdictions do not allow the exclusion of implied warranties or limitations on how long an implied
58
+ warranty may last, so the above limitations may not apply to you. To the extent permissible, any implied
59
+ warranties are limited to ninety (90) days.
60
+
61
+
62
+ 3. LIMITATION OF LIABILITY
63
+ PAYPAL AND ITS SUPPLIERS SHALL NOT BE LIABLE FOR LOSS OR DAMAGE ARISING OUT OF THIS AGREEMENT OR FROM THE USE
64
+ OF THE SOFTWARE OR DOCUMENTATION. IN NO EVENT WILL PAYPAL OR ITS SUPPLIERS BE LIABLE TO YOU OR ANY THIRD PARTY
65
+ FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, INCIDENTAL, OR SPECIAL DAMAGES INCLUDING LOST PROFITS, LOST SAVINGS,
66
+ COSTS, FEES, OR EXPENSES OF ANY KIND ARISING OUT OF ANY PROVISION OF THIS AGREEMENT OR THE USE OR THE INABILITY
67
+ TO USE THE SOFTWARE OR DOCUMENTATION, HOWEVER CAUSED AND UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
68
+ STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
69
+ PAYPAL'S AGGREGATE LIABILITY AND THAT OF ITS SUPPLIERS UNDER OR IN CONNECTION WITH THIS AGREEMENT SHALL BE
70
+ LIMITED TO THE AMOUNT PAID BY YOU FOR THE SOFTWARE AND DOCUMENTATION.
71
+
72
+ 4. TRADEMARK USAGE
73
+ PayPal is a trademark PayPal, Inc. in the United States and other countries. Such trademarks may not be used
74
+ to endorse or promote any product unless expressly permitted under separate agreement with PayPal.
75
+
76
+ 5. TERM
77
+ Your rights under this Agreement shall terminate if you fail to comply with any of the material terms or
78
+ conditions of this Agreement and do not cure such failure in a reasonable period of time after becoming
79
+ aware of such noncompliance. If all your rights under this Agreement terminate, you agree to cease use
80
+ and distribution of the Software and Documentation as soon as reasonably practicable.
81
+
82
+ 6. GOVERNING LAW AND JURISDICTION. This Agreement is governed by the statutes and laws of the State of
83
+ California, without regard to the conflicts of law principles thereof. If any part of this Agreement is
84
+ found void and unenforceable, it will not affect the validity of the balance of the Agreement, which shall
85
+ remain valid and enforceable according to its terms. Any dispute arising out of or related to this Agreement
86
+ shall be brought in the courts of Santa Clara County, California, USA.
data/README.md ADDED
@@ -0,0 +1,157 @@
1
+ # PayPal Payouts API SDK for Ruby
2
+
3
+ ![PayPal Developer](homepage.jpg)
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.
6
+
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
+
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.
10
+
11
+ ## Prerequisites
12
+
13
+ - Ruby 2.0.0 or above
14
+ - Bundler
15
+
16
+ ## Usage
17
+ ### Binaries
18
+
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.
20
+
21
+ For contributing or referring the samples, You can fork/refer this repository.
22
+
23
+ ### Setting up credentials
24
+ Get client ID and client secret by going to https://developer.paypal.com/developer/applications and generating a REST API app. Get <b>Client ID</b> and <b>Secret</b> from there.
25
+
26
+ ```ruby
27
+ require 'paypal-payouts-sdk'
28
+
29
+
30
+ # Creating Access Token for Sandbox
31
+ client_id = "PAYPAL-CLIENT-ID"
32
+ client_secret = "PAYPAL-CLIENT-SECRET"
33
+ # Creating an environment
34
+ environment = PayPal::SandboxEnvironment.new(client_id, client_secret)
35
+ client = PayPal::PayPalHttpClient.new(environment)
36
+ ```
37
+
38
+ ## Examples
39
+
40
+ ### Creating a Payouts
41
+
42
+ #### Code:
43
+ ```ruby
44
+
45
+ # Construct a request object and set desired parameters
46
+ # Here, PayoutsPostRequest::new creates a POST request to /v1/payments/payouts
47
+ body = {
48
+ sender_batch_header: {
49
+ recipient_type: 'EMAIL',
50
+ email_message: 'SDK payouts test txn',
51
+ note: 'Enjoy your Payout!!',
52
+ sender_batch_id: 'Test_SDK_1',
53
+ email_subject: 'This is a test transaction from SDK'
54
+ },
55
+ items: [{
56
+ note: 'Your 5$ Payout!',
57
+ amount: {
58
+ currency: 'USD',
59
+ value: '1.00'
60
+ },
61
+ receiver: 'payout-sdk-1@paypal.com',
62
+ sender_item_id: 'Test_txn_1'
63
+ }, {
64
+ note: 'Your 5$ Payout!',
65
+ amount: {
66
+ currency: 'USD',
67
+ value: '1.00'
68
+ },
69
+ receiver: 'payout-sdk-2@paypal.com',
70
+ sender_item_id: 'Test_txn_2'
71
+ }, {
72
+ note: 'Your 5$ Payout!',
73
+ amount: {
74
+ currency: 'USD',
75
+ value: '1.00'
76
+ },
77
+ receiver: 'payout-sdk-3@paypal.com',
78
+ sender_item_id: 'Test_txn_3'
79
+ }, {
80
+ note: 'Your 5$ Payout!',
81
+ amount: {
82
+ currency: 'USD',
83
+ value: '1.00'
84
+ },
85
+ receiver: 'payout-sdk-4@paypal.com',
86
+ sender_item_id: 'Test_txn_4'
87
+ }, {
88
+ note: 'Your 5$ Payout!',
89
+ amount: {
90
+ currency: 'USD',
91
+ value: '1.00'
92
+ },
93
+ receiver: 'payout-sdk-5@paypal.com',
94
+ sender_item_id: 'Test_txn_5'
95
+ }]
96
+ }
97
+ request = PaypalPayoutsSdk::Payouts::PayoutsPostRequest::new
98
+ request.request_body(body)
99
+
100
+ begin
101
+ # Call API with your client and get a response for your call
102
+ response = client.execute(request)
103
+
104
+ # If call returns body in response, you can get the deserialized version from the result attribute of the response
105
+ batch_id = response.result.batch_header.payout_batch_id
106
+ puts batch_id
107
+ rescue PayPalHttp::HttpError => ioe
108
+ # Something went wrong server-side
109
+ puts ioe.status_code
110
+ puts ioe.headers["debug_id"]
111
+ end
112
+ ```
113
+
114
+ ### Retrieve a Payout Batch
115
+ Pass the batch_id from the previous sample to retrieve Payouts batch details
116
+
117
+ #### Code:
118
+ ```ruby
119
+ # Here, PayoutsGetRequest::new() creates a GET request to /v1/payments/payouts/<batch-id>
120
+ request = PaypalPayoutsSdk::Payouts::PayoutsGetRequest::new("PAYOUT-BATCH-ID")
121
+ request.page(1)
122
+ request.page_size(10)
123
+ request.total_required(true)
124
+
125
+ begin
126
+ # Call API with your client and get a response for your call
127
+ response = client.execute(request)
128
+
129
+ # If call returns body in response, you can get the deserialized version from the result attribute of the response
130
+ batch_status = response.result.batch_header.batch_status
131
+ puts batch_status
132
+ rescue PayPalHttp::HttpError => ioe
133
+ # Something went wrong server-side
134
+ puts ioe.status_code
135
+ puts ioe.headers["debug_id"]
136
+ end
137
+ ```
138
+
139
+ ## Running tests
140
+
141
+ To run integration tests using your client id and secret, clone this repository and run the following command:
142
+ ```sh
143
+ $ bundle install
144
+ $ PAYPAL_CLIENT_ID=YOUR_SANDBOX_CLIENT_ID PAYPAL_CLIENT_SECRET=YOUR_SANDBOX_CLIENT_SECRET rspec spec
145
+ ```
146
+
147
+ ## Samples
148
+
149
+ You can start off by trying out [Payouts Samples](samples/run_all.rb)
150
+
151
+ To try out different samples head to [this link](samples)
152
+
153
+ Note: Update the `paypal_client.rb` with your sandbox client credentials or pass your client credentials as environment variable whie executing the samples.
154
+
155
+
156
+ ## License
157
+ Code released under [SDK LICENSE](LICENSE)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/gen.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ projectName: paypal-payouts-sdk
3
+ language: ruby
4
+ sourcePath: lib
5
+ testPath: spec
6
+ apiVersioning: false
data/homepage.jpg ADDED
Binary file
data/init ADDED
File without changes
@@ -0,0 +1,20 @@
1
+ module PayPal
2
+ class AccessToken
3
+ attr_accessor :access_token, :token_type, :expires_in, :date_created
4
+
5
+ def initialize(options)
6
+ @access_token = options.access_token
7
+ @token_type = options.token_type
8
+ @expires_in = options.expires_in
9
+ @date_created = Time.now
10
+ end
11
+
12
+ def isExpired
13
+ return Time.now > @date_created + @expires_in
14
+ end
15
+
16
+ def authorizationString
17
+ return "#{@token_type} #{@access_token}"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,38 @@
1
+ require 'paypalhttp'
2
+ require "base64"
3
+
4
+ module PayPal
5
+
6
+ SANDBOXAPI = 'https://api.sandbox.paypal.com'
7
+ LIVEAPI = 'https://api.paypal.com'
8
+ SANDBOXWEB = 'https://sandbox.paypal.com'
9
+ LIVEWEB = 'https://paypal.com'
10
+
11
+ class PayPalEnvironment < PayPalHttp::Environment
12
+ attr_accessor :client_id, :client_secret, :web_url
13
+
14
+ def initialize(client_id, client_secret, base_url, web_url)
15
+ super(base_url)
16
+ @client_id = client_id
17
+ @client_secret = client_secret
18
+ @web_url = web_url
19
+ end
20
+
21
+ def authorizationString
22
+ encoded = Base64.strict_encode64("#{@client_id}:#{@client_secret}")
23
+ return "Basic #{encoded}"
24
+ end
25
+ end
26
+
27
+ class SandboxEnvironment < PayPal::PayPalEnvironment
28
+ def initialize(client_id, client_secret)
29
+ super(client_id, client_secret, PayPal::SANDBOXAPI, PayPal::SANDBOXWEB)
30
+ end
31
+ end
32
+
33
+ class LiveEnvironment < PayPal::PayPalEnvironment
34
+ def initialize(client_id, client_secret)
35
+ super(client_id, client_secret, PayPal::LIVEAPI, PayPal::LIVEWEB)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,56 @@
1
+ require 'paypalhttp'
2
+ require 'openssl'
3
+ require_relative './version'
4
+
5
+ module PayPal
6
+ class PayPalHttpClient < PayPalHttp::HttpClient
7
+ attr_accessor :refresh_token
8
+
9
+ def initialize(environment, refresh_token = nil)
10
+ super(environment)
11
+ @refresh_token = refresh_token
12
+
13
+ add_injector(&method(:_sign_request))
14
+ add_injector(&method(:_add_headers))
15
+ end
16
+
17
+ def user_agent
18
+ library_details ||= "paypal-payouts-sdk #{VERSION}; ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}-#{RUBY_PLATFORM}"
19
+ begin
20
+ library_details << ";#{OpenSSL::OPENSSL_LIBRARY_VERSION}"
21
+ rescue NameError
22
+ library_details << ";OpenSSL #{OpenSSL::OPENSSL_VERSION}"
23
+ end
24
+
25
+ "PayPalSDK/rest-sdk-ruby #{VERSION} (#{library_details})"
26
+ end
27
+
28
+ def _sign_request(request)
29
+ if (!_has_auth_header(request) && !_is_auth_request(request))
30
+ if (!@access_token || @access_token.isExpired)
31
+ accessTokenRequest = PayPal::AccessTokenRequest.new(@environment, @refresh_token)
32
+ tokenResponse = execute(accessTokenRequest)
33
+ @access_token = PayPal::AccessToken.new(tokenResponse.result)
34
+ end
35
+ request.headers["Authorization"] = @access_token.authorizationString()
36
+ end
37
+ end
38
+
39
+ def _add_headers(request)
40
+ request.headers["Accept-Encoding"] = "gzip"
41
+ request.headers["sdk_name"] = "Payouts SDK"
42
+ request.headers["sdk_version"] = VERSION
43
+ request.headers["sdk_tech_stack"] = "Ruby" + RUBY_VERSION
44
+ request.headers["api_integration_type"] = "PAYPALSDK"
45
+ end
46
+
47
+ def _is_auth_request(request)
48
+ request.path == '/v1/oauth2/token' ||
49
+ request.path == '/v1/identity/openidconnect/tokenservice'
50
+ end
51
+
52
+ def _has_auth_header(request)
53
+ request.headers.key?("Authorization")
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,40 @@
1
+ module PayPal
2
+ class AccessTokenRequest
3
+ attr_accessor :path, :body, :headers, :verb
4
+
5
+ def initialize(environment, refreshToken = nil)
6
+ @path = "/v1/oauth2/token"
7
+ @body = {
8
+ :grant_type => "client_credentials",
9
+ }
10
+
11
+ if (refreshToken)
12
+ @body[:grant_type] = "refresh_token"
13
+ @body[:refresh_token] = refreshToken
14
+ end
15
+
16
+ @headers = {
17
+ "Content-Type" => "application/x-www-form-urlencoded",
18
+ "Authorization" => environment.authorizationString(),
19
+ }
20
+ @verb = "POST"
21
+ end
22
+ end
23
+
24
+ class RefreshTokenRequest
25
+ attr_accessor :path, :body, :headers, :verb
26
+
27
+ def initialize(environment, authorization_code)
28
+ @path = "/v1/identity/openidconnect/tokenservice"
29
+ @body = {
30
+ :grant_type => "authorization_code",
31
+ :code => authorization_code,
32
+ }
33
+ @headers = {
34
+ "Content-Type" => "application/x-www-form-urlencoded",
35
+ "Authorization" => environment.authorizationString(),
36
+ }
37
+ @verb = "POST"
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,3 @@
1
+ module PayPal
2
+ VERSION = "1.0.0"
3
+ end
data/lib/lib.rb ADDED
@@ -0,0 +1,9 @@
1
+ require_relative './core/access_token'
2
+ require_relative './core/paypal_environment'
3
+ require_relative './core/paypal_http_client'
4
+ require_relative './core/token_requests'
5
+ require_relative './core/version'
6
+ require_relative './payouts/payouts_post_request'
7
+ require_relative './payouts/payouts_get_request'
8
+ require_relative './payouts/payouts_item_get_request'
9
+ require_relative './payouts/payouts_item_cancel_request'
@@ -0,0 +1,49 @@
1
+ # This class was generated on Fri, 27 Dec 2019 11:58:02 IST by version 0.1.0-dev+904328-dirty of Braintree SDK Generator
2
+ # payouts_get_request.rb
3
+ # @version 0.1.0-dev+904328-dirty
4
+ # @type request
5
+ # @data H4sIAAAAAAAC/+wda3Mct+17fwVm0xnHM/eQ4zgPfVMlp742dVRLdqejek68XdwtIy65IbmSN5n89w5fe/uUZPl8SZz9ZAvkkgAIgCAA8n6JXpIMo8MoJ6UotJptUEeT6ARVLGmuqeDRYXSWihsFOkVgRKPSoDTRhQKxBgIrouMU3OczWPCYFQm63loSrkhsRgmfEJ6A0ClKSIgmsBYSKE/oNU0KwvwoQDVmahZNon8XKMtTIkmGGqWKDi9+ic7L3OCrtKR8E02iN0RSsmLo6VhTZImKJtE/sfSgAXoS1IQyZXEQnJUWZZVjTNcUE3ADGSyOpCSlm/ZgEr1CkvzAWRkdrglTaA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ODiAo7PjxaLmJ1nL8cS0cMGn7db9XWywObz2lYYA7Dud+qzf9vVCY8JmcCyk87UTFUrML5uXIy6dom2fd9zFPaIWoS/daWjw/kbn+NRpuj2UkBOpy48fdCLMxo40LtcFY12s+9ubqJ88P331/Pjo/PmJc8kt6o8UVN9awmZwTDis0GxMhaIclbLwCXAaX7n/2UcLS/8AruWGj6VwY9lWCCpnVDt7s6ZS6Ym7CuHGD6yol31LXbqHUcOce5L3fm4O8/A/PSjnKFV4kzXw1IzgyN0PHRt6jbxLSAP8MErsEHbJ/UrukaqMJgnDLllN+MPocmN4kXytEAhTwj61qoVEyAqmac6w3k/5M+/2mWItBS8zGjv+EKMPj9SkMfaebrJKXNN3Tec7gHpe8LNNFmlNNcNJMNCBOXvEXBXrNuYVqO/qommqnXh+A3xlRx63sIfJov/eCVFGWenF8siI5BUXN9ycFKobZfcwo26WWwXbT9oW6qwp1JkIQu377+2k/MndsdxifUMYQz1AUtXYJco1mQWXIZLkvwq01K9ZzuDUv9SpBbxBnona7dvg1QOBR8ZrfRQu3drzK7w+g0ysKEPIU8Ex3OXc62VUqjEbuIu6bWo/Lr+bi6i7lvHhKEMtRLJcIw6FT3zbWPswBh7GwMOnGnio63t/aHjI7vkdr3XB0PSewRuKN/bakfUT7DX32o8JPPy9kg+8X1ldo+3esKw33fPqMFXuOYobopyPVI3xh76IujXcbYHoNL1fqqBenb1/WnpeHe9t7tJkF7n7ezw737DHnPWYsx5z1mPO+k+Vsx78USz3W0/d+09NeHdl3C85bb236j0NW4RX2OegVMGMAim9r1/4ckjbn5fqISbA7ybG9tzVGkTHgmvk/teYInsXx2WP5j8qu/280Dr/l1Pgw+jvz88j96tU0WE0v34y9wc4NfdPGs1/aRUT/BpNorMrmldYPH+XY6wxObMb6LFIMDr84uDg17/8HwAA//8=
6
+ # DO NOT EDIT
7
+ require 'cgi'
8
+
9
+ module PaypalPayoutsSdk
10
+ module Payouts
11
+
12
+ #
13
+ # Shows the latest status of a batch payout. Includes the transaction status and other data for individual payout items.
14
+ #
15
+ class PayoutsGetRequest
16
+ attr_accessor :path, :body, :headers, :verb
17
+
18
+ def initialize(payout_batch_id)
19
+ @headers = {}
20
+ @body = nil
21
+ @verb = "GET"
22
+ @path = "/v1/payments/payouts/{payout_batch_id}?"
23
+
24
+ @path = @path.gsub("{payout_batch_id}", CGI::escape(payout_batch_id.to_s))
25
+ @headers["Content-Type"] = "application/json"
26
+ end
27
+
28
+ def fields(fields)
29
+ param = fields.to_s
30
+ @path += "fields=#{CGI::escape(param)}&"
31
+ end
32
+
33
+ def page(page)
34
+ param = page.to_s
35
+ @path += "page=#{CGI::escape(param)}&"
36
+ end
37
+
38
+ def page_size(page_size)
39
+ param = page_size.to_s
40
+ @path += "page_size=#{CGI::escape(param)}&"
41
+ end
42
+
43
+ def total_required(total_required)
44
+ param = total_required.to_s
45
+ @path += "total_required=#{CGI::escape(param)}&"
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,29 @@
1
+ # This class was generated on Fri, 27 Dec 2019 11:58:02 IST by version 0.1.0-dev+904328-dirty of Braintree SDK Generator
2
+ # payouts_item_cancel_request.rb
3
+ # @version 0.1.0-dev+904328-dirty
4
+ # @type request
5
+ # @data H4sIAAAAAAAC/+xb+2/cNvL//ftXDNQvkAbQ7rpNn/7NsF3Ed23ii50eCp/h5UqjFc8UqXIoO0LR//3Ah7R6rZO4zvYe+5O9M3zMZ2Y4Gg7J36JXrMDoMCpZrSpDM26wmCdMJiiiODpBSjQvDVcyOoyOHZmASahkIhgvMAXfEWy/GFY1nJ3M4SwDqUBJBNeKwOTY6WLbwj03OZfw4gBSVlPsmhydnwGrjCqY4QkTogaNptLSD5BVMiUwyv0glCnqObwlBJNzAtveMr3sUzOuMFMaHaedBF4czFJm57Gjz+EXVdkRmlE64MhJDAz+UR0cvEgSlaL7D41mklhidXRDhpmKfIvFpgmobNTt7avjH4/Ofjo9GbWeR3H0twp1fc40K9Cgpujw6jqOXiJLUQ+pPyhdDGnnzOQ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Afc5yo0S3QWMds4d+fu0Nrfr8O8TIpeoyX7RTUendgQPdzc41vwO5RhIj/w4JG4IZ/JgyR2iKniaChzD6tMfh8uPEVzyLSEwQcoGKjJKIxSVMLwU2G1HYd/L5ToMZbSSdcETrx9m18Mzintj70ZTpcaMv+vn3g1p4rKiYzmhDTcC4yZAN8rZoeRUZUPJW9LEF9exOrueP0FePfLHDe1xvhj6eycquKiDWx5Zl7yV6l7anYLbC39gGPWzPOjYYdKhUxd9py5U49Sh/c52y/1cYcs3OrAm7xlbXrja52+x8lBhaHZZTeqyu9wqSH3PhECzBVLLHIPyLGtw3VSTQq8GC3WKAXPwW3eXfv2MslCb9tRk9cDgmc1an4EX2+9f4e0FFGrFBUKZK4kh9d/VEnNp9eSd8hFrUCQep+RnJ43wcKndbeXu5XMJTAJLErtft+ipJoPFk/v49ipD9w52hritehJ4+4tf+8LDvvDw31p4eOAtzYg1+cUbFIPdmyz4mRNfCfRpQq0qoFzdDyqvj7jn/uj1EEL4ZBV8zPuA+P4xgR0uclWJ1O5RwyWi/nuyHX3hDC/wJhyoYV8FI9ZE1dzu1W28t22b9I9TeB/HyGeJ7Rix1cbVmbt3h2bQ258Jvvec58WLF9+35zxfz795vitF9d4R9RU1ZH3cgUmn+5+AxT8R24qnZY8x+fdym7bhtdlTpSzRsZIGZXg6F7kXMb6MufgnufP7l8aUP/kT0MPo/PXFZeTfDUaH0eLui0XzLG3RfRm6+K0fwH5ftE9FL2552Up0+q7ExGB64TAdqxSjwy8PDn7/v38BAAD//w==
6
+ # DO NOT EDIT
7
+ require 'cgi'
8
+
9
+ module PaypalPayoutsSdk
10
+ module Payouts
11
+
12
+ #
13
+ # Cancels an unclaimed payout item, by ID. If no one claims the unclaimed item within 30 days, the API automatically returns the funds to the sender. Use this call to cancel the unclaimed item before the automatic 30-day refund. You can cancel payout items with a <code>transaction_status</code> of <code>UNCLAIMED</code>.
14
+ #
15
+ class PayoutsItemCancelRequest
16
+ attr_accessor :path, :body, :headers, :verb
17
+
18
+ def initialize(payout_item_id)
19
+ @headers = {}
20
+ @body = nil
21
+ @verb = "POST"
22
+ @path = "/v1/payments/payouts-item/{payout_item_id}/cancel?"
23
+
24
+ @path = @path.gsub("{payout_item_id}", CGI::escape(payout_item_id.to_s))
25
+ @headers["Content-Type"] = "application/json"
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ # This class was generated on Fri, 27 Dec 2019 11:58:02 IST by version 0.1.0-dev+904328-dirty of Braintree SDK Generator
2
+ # payouts_item_get_request.rb
3
+ # @version 0.1.0-dev+904328-dirty
4
+ # @type request
5
+ # @data H4sIAAAAAAAC/+xb63PbuBH/3r9ih9eZnGcoyXe5p795bF/j9pq4sZNOx/VYELkSUYMADwta4WTyv3fwIM2XHMdxdH3ok61dPPa3u1gsFuD76CXLMTqIClap0tCEG8ynKzRRHB0jJZoXhisZHUTnmVoTpGgYFwRLpYGB7wS2TwyLCk6Pp3AI/yz3958niUrR/Ye+1bVtdc1Tz53dsSFDURBUqgSeojR8WUGKkmNqx89RGprC6dJPZ38Cp9Agdr0SJqEkBJPhJ89t1N2ktn89Bd6iBL4EbkCw5IaADYY2mkliiVXP2NDTKI7+VqKuzphmORrUFB1cXsXRC2Qp6j71F6XzPu2MmaxDex9dVIW1FhnN5SqKo7dMc7YQ2LFiDTeKo79gFVgDg15kCKfHoJY18NqUzrjrjCeZVQ9lal2b3WI61JpVXoz9OHqNLH0lRRUdLJkgtITfSq4xjQ6MLjGOzrQqUBuOFB3IUogPV74NkvGDWKIlUaEkoac1OM+8VKdWqrrJEPXHcbbRkWGmJGAyBWUy1A24neu2XPfBZg6Etp0/7qd27ltuqr6TdulDO5aS/1YinLHqjInJCiVqZjCFROW5ktadTcYMCC5vyCmFUKaoJ87aGhPkt6gnxFOElg5oCm8IU+f3RrPkhsvV5+rA+Xrcd+SjUmuUSQWJkreoySIbKCcJja47je6UNM4fKisZTgYaSZU62YKJ8V2SMbnCa2uhjvx9zlDyugXYFt6knI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e+EOjThEqVne9tOp9ZbWc9hBA+WgUf8h4Q3z8lsMN5pkqR2jNqeES05ibjEp7vQ8qqbR07Dc/xOlyoYVcFA9ZI1dye1W28t23r9I+T//hozchnic0YsdXG5al7d4em19vfCX70nuf58+c/N/c8309/2NuWojrfEXUV1Wd92oVJq/vvgMV/IrYRT8MeYnJGbrUNX5s9VcoSHSlpUIZP5yL3RYwvY87+Re7+/oUxxV/9DehB9KeTi8h/RhgdRLPbb2b1V2mz9uees/fd+PUhiqPzG140kpy8KzAxmJ47LEcqxejg2/39D3/4NwAAAP//
6
+ # DO NOT EDIT
7
+ require 'cgi'
8
+
9
+ module PaypalPayoutsSdk
10
+ module Payouts
11
+
12
+ #
13
+ # Shows details for a payout item, by ID. A <code>payout_item_id</code> helps you identify denied payments. If a payment is denied, you can use the <code>payout_item_id</code> to identify the payment even if it lacks a <code>transaction_id</code>.
14
+ #
15
+ class PayoutsItemGetRequest
16
+ attr_accessor :path, :body, :headers, :verb
17
+
18
+ def initialize(payout_item_id)
19
+ @headers = {}
20
+ @body = nil
21
+ @verb = "GET"
22
+ @path = "/v1/payments/payouts-item/{payout_item_id}?"
23
+
24
+ @path = @path.gsub("{payout_item_id}", CGI::escape(payout_item_id.to_s))
25
+ @headers["Content-Type"] = "application/json"
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,39 @@
1
+ # This class was generated on Fri, 27 Dec 2019 11:58:02 IST by version 0.1.0-dev+904328-dirty of Braintree SDK Generator
2
+ # payouts_post_request.rb
3
+ # @version 0.1.0-dev+904328-dirty
4
+ # @type request
5
+ # @data H4sIAAAAAAAC/+xc3XPbNhJ/v79ih72HeIYSnc+2nrkH104n6qWOL3Y703E9MkSuRNQgwABgHE0n//sNvihSpGTFUZT2Tm8WPvcLi90flv4zOiMFRkdRSeai0mpYCqWjODpFlUpaaip4dBSdSCQaFRCYEJ3m4AYPYcRB5wg/Xbw5A4nvKlQaJiKbx1ASZYbfKOQZyrGdNs6RZChvgPAMCIcb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cgi'
8
+
9
+ module PaypalPayoutsSdk
10
+ module Payouts
11
+
12
+ #
13
+ # Creates a batch payout. In the JSON request body, pass a `sender_batch_header` and an `items` array. The `sender_batch_header` defines how to handle the payout. The `items` array defines the payout items.<br/>You can make payouts to one or more recipients.<blockquote><strong>Notes:</strong> <ul><li><p>PayPal does not process duplicate payouts. If you specify a <code>sender_batch_id</code> that was used in the last 30 days, the API rejects the request with an error message that shows the duplicate <code>sender_batch_id</code> and includes a HATEOAS link to the original payout with the same <code>sender_batch_id</code>.</p><p>If you receive an HTTP <code>5<i>nn</i></code> status code, you can safely retry the request with the same <code>sender_batch_id</code>.</p></li><li><p>The Payouts API does not support build notation (BN) codes. In a future Payouts release, you can optionally provide BN codes in the <code>PayPal-Partner-Attribution-Id</code> request header.</p><p>For information about the <code>PayPal-Partner-Attribution-Id</code> header, see <a href="/docs/api/reference/api-requests/#http-request-headers">HTTP request headers</a>. To learn about or request a BN code, contact your partner manager or see <a href="https://www.paypal.com/us/webapps/mpp/partner-program">PayPal Partner Program</a>.</p></li></ul></blockquote>
14
+ #
15
+ class PayoutsPostRequest
16
+ attr_accessor :path, :body, :headers, :verb
17
+
18
+ def initialize()
19
+ @headers = {}
20
+ @body = nil
21
+ @verb = "POST"
22
+ @path = "/v1/payments/payouts?"
23
+ @headers["Content-Type"] = "application/json"
24
+ end
25
+
26
+ def pay_pal_partner_attribution_id(pay_pal_partner_attribution_id)
27
+ @headers["PayPal-Partner-Attribution-Id"] = pay_pal_partner_attribution_id
28
+ end
29
+
30
+ def pay_pal_request_id(pay_pal_request_id)
31
+ @headers["PayPal-Request-Id"] = pay_pal_request_id
32
+ end
33
+
34
+ def request_body(createPayoutRequest)
35
+ @body = createPayoutRequest
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1 @@
1
+ require_relative './lib'
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'core/version'
4
+
5
+ Gem::Specification.new do |spec|
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"
10
+ spec.authors = ["http://developer.paypal.com"]
11
+ spec.email = 'dl-paypal-payouts-sdk@paypal.com'
12
+ spec.homepage = 'https://github.com/paypal/Payouts-Ruby-SDK'
13
+ spec.license = 'https://github.com/paypal/Payouts-Ruby-SDK/blob/master/LICENSE'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'paypalhttp', '~> 1.0.0'
23
+
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec', '~> 3.0'
26
+ spec.add_development_dependency 'webmock'
27
+ end
@@ -0,0 +1,38 @@
1
+ require_relative 'paypal_client'
2
+ require_relative 'create_payouts'
3
+ require_relative 'get_payouts'
4
+
5
+ include PaypalPayoutsSdk::Payouts
6
+
7
+ module Samples
8
+ class CancelPayoutItem
9
+
10
+ # Cancels an UNCLAIMED payout item
11
+ # An item can be cancelled only when the item status is UNCLAIMED and the batch status is SUCCESS
12
+ # Upon cancelling the item status becomes RETURNED and the funds returned back to the sender
13
+ def cancel_payout_item(item_id, debug = false)
14
+ request = PayoutsItemCancelRequest.new(item_id)
15
+
16
+ begin
17
+ response = PayPalClient::client.execute(request)
18
+
19
+ puts "Status Code: #{response.status_code}"
20
+ puts "Status: #{response.result.status}"
21
+ puts "Payout Item Id: #{response.result.payout_item_id}"
22
+ puts "Payout Item Status: #{response.result.transaction_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
+ return response
30
+ rescue PayPalHttp::HttpError => ioe
31
+ # Exception occured while processing the payouts.
32
+ puts " Status Code: #{ioe.status_code}"
33
+ puts " Debug Id: #{ioe.result.debug_id}"
34
+ puts " Response: #{ioe.result}"
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,95 @@
1
+ require_relative 'paypal_client'
2
+ require 'securerandom'
3
+ include PaypalPayoutsSdk::Payouts
4
+
5
+ module Samples
6
+ class CreatePayouts
7
+
8
+ # Creates a payout batch with 5 payout items
9
+ # Calls the create batch api (POST - /v1/payments/payouts)
10
+ # A maximum of 15000 payout items are supported in a single batch request
11
+ def create_payouts(debug = false)
12
+ sender_batch_id = 'Test_sdk_' + SecureRandom.base64(6)
13
+ body = {
14
+ sender_batch_header: {
15
+ recipient_type: 'EMAIL',
16
+ email_message: 'SDK payouts test txn',
17
+ note: 'Enjoy your Payout!!',
18
+ sender_batch_id: sender_batch_id,
19
+ email_subject: 'This is a test transaction from SDK'
20
+ },
21
+ items: [{
22
+ note: 'Your 5$ Payout!',
23
+ amount: {
24
+ currency: 'USD',
25
+ value: '1.00'
26
+ },
27
+ receiver: 'payout-sdk-1@paypal.com',
28
+ sender_item_id: 'Test_txn_1'
29
+ }, {
30
+ note: 'Your 5$ Payout!',
31
+ amount: {
32
+ currency: 'USD',
33
+ value: '1.00'
34
+ },
35
+ receiver: 'payout-sdk-2@paypal.com',
36
+ sender_item_id: 'Test_txn_2'
37
+ }, {
38
+ note: 'Your 5$ Payout!',
39
+ amount: {
40
+ currency: 'USD',
41
+ value: '1.00'
42
+ },
43
+ receiver: 'payout-sdk-3@paypal.com',
44
+ sender_item_id: 'Test_txn_3'
45
+ }, {
46
+ note: 'Your 5$ Payout!',
47
+ amount: {
48
+ currency: 'USD',
49
+ value: '1.00'
50
+ },
51
+ receiver: 'payout-sdk-4@paypal.com',
52
+ sender_item_id: 'Test_txn_4'
53
+ }, {
54
+ note: 'Your 5$ Payout!',
55
+ amount: {
56
+ currency: 'USD',
57
+ value: '1.00'
58
+ },
59
+ receiver: 'payout-sdk-5@paypal.com',
60
+ sender_item_id: 'Test_txn_5'
61
+ }]
62
+ }
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
87
+ end
88
+
89
+ end
90
+ end
91
+
92
+ # This is the driver function which invokes the create_payouts function to create an payouts batch.
93
+ if __FILE__ == $0
94
+ Samples::CreatePayouts::new().create_payouts(true)
95
+ end
@@ -0,0 +1,43 @@
1
+ require_relative 'paypal_client'
2
+ require_relative 'create_payouts'
3
+ require_relative 'get_payouts'
4
+
5
+ include PaypalPayoutsSdk::Payouts
6
+
7
+ module Samples
8
+ class GetPayoutItem
9
+
10
+ # Retrieves the details of an individual Payout item provided the item_id
11
+ def get_payout_item(item_id, debug = false)
12
+ request = PayoutsItemGetRequest.new(item_id)
13
+
14
+ begin
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"]}"
25
+ end
26
+ puts PayPalClient::openstruct_to_hash(response.result).to_json
27
+ return response
28
+ rescue PayPalHttp::HttpError => ioe
29
+ # 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}"
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ # This is the driver function which invokes the get_payout_item function to retrieve a Payout Item
39
+ 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
42
+ Samples::GetPayoutItem::new().get_payout_item(id, true)
43
+ end
@@ -0,0 +1,49 @@
1
+ require_relative 'paypal_client'
2
+ require_relative 'create_payouts'
3
+
4
+ include PaypalPayoutsSdk::Payouts
5
+
6
+ module Samples
7
+ class GetPayouts
8
+
9
+ # Retries a Payout batch details provided the batch_id
10
+ # This API is paginated - by default 1000 payout items are retrieved
11
+ # Use pagination links to navigate through all the items, use total_required to get the total pages
12
+ def get_payouts(batch_id, debug = false)
13
+ request = PayoutsGetRequest.new(batch_id)
14
+ # Optional parameters, page_size defaults to 1000
15
+ request.page(1)
16
+ request.page_size(10)
17
+ request.total_required(true)
18
+
19
+ begin
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
34
+ return response
35
+ rescue PayPalHttp::HttpError => ioe
36
+ # 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}"
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ # This is the driver function which invokes the get_payouts function to retrieve a Payouts Batch
46
+ if __FILE__ == $0
47
+ id = Samples::CreatePayouts::new().create_payouts(true).result.batch_header.payout_batch_id
48
+ Samples::GetPayouts::new().get_payouts(id, true)
49
+ end
@@ -0,0 +1,40 @@
1
+ require '../lib/paypal-payouts-sdk'
2
+
3
+ module PayPalClient
4
+ class << self
5
+
6
+ # Setting up and Returns PayPal SDK environment with PayPal Access credentials.
7
+ # For demo purpose, we are using SandboxEnvironment. In production this will be
8
+ # LiveEnvironment.
9
+ def environment
10
+ client_id = ENV['PAYPAL_CLIENT_ID'] || '<<PAYPAL-CLIENT-ID>>'
11
+ client_secret = ENV['PAYPAL_CLIENT_SECRET'] || '<<PAYPAL-CLIENT-SECRET>>'
12
+
13
+ PayPal::SandboxEnvironment.new(client_id, client_secret)
14
+ end
15
+
16
+ # Returns PayPal HTTP client instance with environment which has access
17
+ # credentials context. This can be used invoke PayPal API's provided the
18
+ # credentials have the access to do so.
19
+ def client
20
+ PayPal::PayPalHttpClient.new(self.environment)
21
+ end
22
+
23
+ # Utility to convert Openstruct Object to JSON hash.
24
+ def openstruct_to_hash(object, hash = {})
25
+ object.each_pair do |key, value|
26
+ hash[key] = value.is_a?(OpenStruct) ? openstruct_to_hash(value) : value.is_a?(Array) ? array_to_hash(value) : value
27
+ end
28
+ hash
29
+ end
30
+
31
+ # Utility to convert Array of OpenStruct into Hash.
32
+ def array_to_hash(array, hash = [])
33
+ array.each do |item|
34
+ x = item.is_a?(OpenStruct) ? openstruct_to_hash(item) : item.is_a?(Array) ? array_to_hash(item) : item
35
+ hash << x
36
+ end
37
+ hash
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,51 @@
1
+ require_relative 'create_payouts'
2
+ require_relative 'get_payouts'
3
+ require_relative 'get_payout_item'
4
+ require_relative 'cancel_payout_item'
5
+
6
+ include PayPalHttp
7
+
8
+ # Create Payouts Batch
9
+ puts "Creating Payouts Batch"
10
+ create_resp = Samples::CreatePayouts::new().create_payouts(true)
11
+ if create_resp.status_code == 201
12
+ # Retrieve Payout batch details
13
+ batch_id = create_resp.result.batch_header.payout_batch_id
14
+ puts "Retrieving Payouts batch details with id: #{batch_id}"
15
+ get_resp = Samples::GetPayouts::new().get_payouts(batch_id, true)
16
+ if get_resp.status_code == 200
17
+ # Retrieve Payout Item details
18
+ item_id = get_resp.result.items[0].payout_item_id
19
+ puts "Retrieving Payouts item detail with id: #{item_id}"
20
+ get_item_resp = Samples::GetPayoutItem::new().get_payout_item(item_id, true)
21
+ if get_item_resp.status_code == 200
22
+ # Wait till batch status becomes SUCCESS to cancel an UNCLAIMED payout item - this is just for demonstration purpose
23
+ # Defer using this while integration
24
+ # Note: Use Webhooks to get LIVE status updates for Payouts Batch and Item
25
+ puts "Check if all Payouts items are processed"
26
+ var = 0
27
+ until var == 5
28
+ sleep 2
29
+ get_resp = Samples::GetPayouts::new().get_payouts(batch_id, true)
30
+ if get_resp.result.batch_header.batch_status == 'SUCCESS'
31
+ # Cancel UNCLAIMED Payout item
32
+ puts "Cancelling unclaimed Payouts item with id: #{item_id}"
33
+ cancel_resp = Samples::CancelPayoutItem.new().cancel_payout_item(item_id, true)
34
+ if cancel_resp.status_code == 200
35
+ puts "Successfully cancelled unclaimed Payouts item with id: #{item_id}"
36
+ else
37
+ puts "Failed to cancel unclaimed Payouts item with id: #{item_id}"
38
+ end
39
+ break
40
+ end
41
+ var = var + 1
42
+ end
43
+ else
44
+ puts "Failed to retrieve Payouts item detail with id: #{item_id}"
45
+ end
46
+ else
47
+ puts "Failed to retrieve Payouts batch detail with id: #{batch_id}"
48
+ end
49
+ else
50
+ puts "Failed to crate Payouts batch"
51
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: paypal-payouts-sdk
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - http://developer.paypal.com
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-01-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: paypalhttp
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: This repository contains PayPal's Ruby SDK for Payouts REST API
70
+ email: dl-paypal-payouts-sdk@paypal.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - ".gitignore"
76
+ - Gemfile
77
+ - LICENSE
78
+ - README.md
79
+ - Rakefile
80
+ - gen.yml
81
+ - homepage.jpg
82
+ - init
83
+ - lib/core/access_token.rb
84
+ - lib/core/paypal_environment.rb
85
+ - lib/core/paypal_http_client.rb
86
+ - lib/core/token_requests.rb
87
+ - lib/core/version.rb
88
+ - lib/lib.rb
89
+ - lib/payouts/payouts_get_request.rb
90
+ - lib/payouts/payouts_item_cancel_request.rb
91
+ - lib/payouts/payouts_item_get_request.rb
92
+ - lib/payouts/payouts_post_request.rb
93
+ - lib/paypal-payouts-sdk.rb
94
+ - paypal-payouts-sdk.gemspec
95
+ - samples/cancel_payout_item.rb
96
+ - samples/create_payouts.rb
97
+ - samples/get_payout_item.rb
98
+ - samples/get_payouts.rb
99
+ - samples/paypal_client.rb
100
+ - samples/run_all.rb
101
+ homepage: https://github.com/paypal/Payouts-Ruby-SDK
102
+ licenses:
103
+ - https://github.com/paypal/Payouts-Ruby-SDK/blob/master/LICENSE
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.5.2.3
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: This repository contains PayPal's Ruby SDK for Payouts REST API
125
+ test_files: []