README.md in paypal-payouts-sdk-1.0.0 vs README.md in paypal-payouts-sdk-1.0.1
- old
+ new
@@ -1,24 +1,44 @@
# PayPal Payouts API SDK for Ruby
![PayPal Developer](homepage.jpg)
-__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.
+__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.
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/).
-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.
+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.
## Prerequisites
- Ruby 2.0.0 or above
- Bundler
+## Installations
+
+Add this line to your application's Gemfile:
+
+```
+gem 'paypal-payouts-sdk'
+```
+
+And then execute:
+
+```
+$ bundle
+```
+
+Or install it yourself as:
+
+```
+$ gem install paypal-payouts-sdk
+```
+
## Usage
### Binaries
-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.
+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.
For contributing or referring the samples, You can fork/refer this repository.
### Setting up credentials
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.
@@ -36,67 +56,67 @@
```
## Examples
### Creating a Payouts
-
+This code creates a Payout and prints the batch_id for the Payout.
#### Code:
```ruby
# Construct a request object and set desired parameters
-# Here, PayoutsPostRequest::new creates a POST request to /v1/payments/payouts
+# Here, PayoutsPostRequest.new creates a POST request to /v1/payments/payouts
body = {
sender_batch_header: {
recipient_type: 'EMAIL',
email_message: 'SDK payouts test txn',
note: 'Enjoy your Payout!!',
sender_batch_id: 'Test_SDK_1',
email_subject: 'This is a test transaction from SDK'
},
items: [{
- note: 'Your 5$ Payout!',
+ note: 'Your $1 Payout!',
amount: {
currency: 'USD',
value: '1.00'
},
receiver: 'payout-sdk-1@paypal.com',
sender_item_id: 'Test_txn_1'
}, {
- note: 'Your 5$ Payout!',
+ note: 'Your $1 Payout!',
amount: {
currency: 'USD',
value: '1.00'
},
receiver: 'payout-sdk-2@paypal.com',
sender_item_id: 'Test_txn_2'
}, {
- note: 'Your 5$ Payout!',
+ note: 'Your $1 Payout!',
amount: {
currency: 'USD',
value: '1.00'
},
receiver: 'payout-sdk-3@paypal.com',
sender_item_id: 'Test_txn_3'
}, {
- note: 'Your 5$ Payout!',
+ note: 'Your $1 Payout!',
amount: {
currency: 'USD',
value: '1.00'
},
receiver: 'payout-sdk-4@paypal.com',
sender_item_id: 'Test_txn_4'
}, {
- note: 'Your 5$ Payout!',
+ note: 'Your $1 Payout!',
amount: {
currency: 'USD',
value: '1.00'
},
receiver: 'payout-sdk-5@paypal.com',
sender_item_id: 'Test_txn_5'
}]
}
-request = PaypalPayoutsSdk::Payouts::PayoutsPostRequest::new
+request = PaypalPayoutsSdk::Payouts::PayoutsPostRequest.new
request.request_body(body)
begin
# Call API with your client and get a response for your call
response = client.execute(request)
@@ -109,17 +129,97 @@
puts ioe.status_code
puts ioe.headers["debug_id"]
end
```
+### Handle API Failure
+This will create a Payout with validation failure to showcase how to parse the failed response entity. Refer samples for more scenarios
+```ruby
+
+# Construct a request object and set desired parameters
+# Here, PayoutsPostRequest.new creates a POST request to /v1/payments/payouts
+body = {
+ sender_batch_header: {
+ recipient_type: 'EMAIL',
+ email_message: 'SDK payouts test txn',
+ note: 'Enjoy your Payout!!',
+ sender_batch_id: 'Test_SDK_1',
+ email_subject: 'This is a test transaction from SDK'
+ },
+ items: [{
+ note: 'Your $1 Payout!',
+ amount: {
+ currency: 'USD',
+ value: '1.0.0'
+ },
+ receiver: 'payout-sdk-1@paypal.com',
+ sender_item_id: 'Test_txn_1'
+ }, {
+ note: 'Your $1 Payout!',
+ amount: {
+ currency: 'USD',
+ value: '1.0.0'
+ },
+ receiver: 'payout-sdk-2@paypal.com',
+ sender_item_id: 'Test_txn_2'
+ }, {
+ note: 'Your $1 Payout!',
+ amount: {
+ currency: 'USD',
+ value: '1.0.0'
+ },
+ receiver: 'payout-sdk-3@paypal.com',
+ sender_item_id: 'Test_txn_3'
+ }, {
+ note: 'Your $1 Payout!',
+ amount: {
+ currency: 'USD',
+ value: '1.0.0'
+ },
+ receiver: 'payout-sdk-4@paypal.com',
+ sender_item_id: 'Test_txn_4'
+ }, {
+ note: 'Your $1 Payout!',
+ amount: {
+ currency: 'USD',
+ value: '1.0.0'
+ },
+ receiver: 'payout-sdk-5@paypal.com',
+ sender_item_id: 'Test_txn_5'
+ }]
+}
+request = PaypalPayoutsSdk::Payouts::PayoutsPostRequest.new
+request.request_body(body)
+
+begin
+ # Call API with your client and get a response for your call
+ client.execute(request)
+
+rescue PayPalHttp::HttpError => ioe
+ # Something went wrong server-side
+ puts "Status Code: #{ioe.status_code}"
+ puts "Response: #{ioe.result}"
+ puts "Name: #{ioe.result.name}"
+ puts "Message: #{ioe.result.message}"
+ puts "Information link: #{ioe.result.information_link}"
+ puts "Debug Id: #{ioe.result.debug_id}"
+ puts "Details: "
+ ioe.result.details.each { |detail|
+ puts "Error Location: #{detail["location"]}"
+ puts "Error Field: #{detail["field"]}"
+ puts "Error issue: #{detail["issue"]}"
+ }
+end
+```
+
### Retrieve a Payout Batch
Pass the batch_id from the previous sample to retrieve Payouts batch details
#### Code:
```ruby
-# Here, PayoutsGetRequest::new() creates a GET request to /v1/payments/payouts/<batch-id>
-request = PaypalPayoutsSdk::Payouts::PayoutsGetRequest::new("PAYOUT-BATCH-ID")
+# Here, PayoutsGetRequest.new creates a GET request to /v1/payments/payouts/<batch-id>
+request = PaypalPayoutsSdk::Payouts::PayoutsGetRequest.new("PAYOUT-BATCH-ID")
request.page(1)
request.page_size(10)
request.total_required(true)
begin
@@ -148,10 +248,10 @@
You can start off by trying out [Payouts Samples](samples/run_all.rb)
To try out different samples head to [this link](samples)
-Note: Update the `paypal_client.rb` with your sandbox client credentials or pass your client credentials as environment variable whie executing the samples.
+Note: Update the `paypal_client.rb` with your sandbox client credentials or pass your client credentials as environment variable while executing the samples.
## License
-Code released under [SDK LICENSE](LICENSE)
\ No newline at end of file
+Code released under [SDK LICENSE](LICENSE)