paypal-sdk-rest 1.7.5 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +4 -14
- data/README.md +45 -255
- data/lib/lib.rb +88 -0
- data/lib/paypal/core/access_token.rb +20 -0
- data/lib/paypal/core/paypal_environment.rb +38 -0
- data/lib/paypal/core/paypal_http_client.rb +51 -0
- data/lib/paypal/core/token_requests.rb +40 -0
- data/lib/paypal/core/version.rb +3 -0
- data/lib/v1/billing_agreements/agreement_bill_balance_request.rb +35 -0
- data/lib/v1/billing_agreements/agreement_cancel_request.rb +35 -0
- data/lib/v1/billing_agreements/agreement_create_request.rb +33 -0
- data/lib/v1/billing_agreements/agreement_execute_request.rb +31 -0
- data/lib/v1/billing_agreements/agreement_get_request.rb +31 -0
- data/lib/v1/billing_agreements/agreement_re_activate_request.rb +35 -0
- data/lib/v1/billing_agreements/agreement_set_balance_request.rb +35 -0
- data/lib/v1/billing_agreements/agreement_suspend_request.rb +35 -0
- data/lib/v1/billing_agreements/agreement_transactions_request.rb +41 -0
- data/lib/v1/billing_agreements/agreement_update_request.rb +35 -0
- data/lib/v1/billing_plans/plan_create_request.rb +33 -0
- data/lib/v1/billing_plans/plan_get_request.rb +31 -0
- data/lib/v1/billing_plans/plan_list_request.rb +49 -0
- data/lib/v1/billing_plans/plan_update_request.rb +35 -0
- data/lib/v1/identity/user_consent.rb +45 -0
- data/lib/v1/identity/userinfo_get_request.rb +33 -0
- data/lib/v1/invoices/invoice_cancel_request.rb +35 -0
- data/lib/v1/invoices/invoice_create_request.rb +33 -0
- data/lib/v1/invoices/invoice_delete_external_payment_request.rb +33 -0
- data/lib/v1/invoices/invoice_delete_external_refund_request.rb +33 -0
- data/lib/v1/invoices/invoice_delete_request.rb +31 -0
- data/lib/v1/invoices/invoice_get_request.rb +31 -0
- data/lib/v1/invoices/invoice_list_request.rb +44 -0
- data/lib/v1/invoices/invoice_next_invoice_number_request.rb +29 -0
- data/lib/v1/invoices/invoice_qr_code_request.rb +46 -0
- data/lib/v1/invoices/invoice_record_payment_request.rb +35 -0
- data/lib/v1/invoices/invoice_record_refund_request.rb +35 -0
- data/lib/v1/invoices/invoice_remind_request.rb +35 -0
- data/lib/v1/invoices/invoice_search_request.rb +33 -0
- data/lib/v1/invoices/invoice_send_request.rb +36 -0
- data/lib/v1/invoices/invoice_update_request.rb +40 -0
- data/lib/v1/invoices/template_create_request.rb +33 -0
- data/lib/v1/invoices/template_delete_request.rb +31 -0
- data/lib/v1/invoices/template_get_request.rb +31 -0
- data/lib/v1/invoices/template_list_request.rb +34 -0
- data/lib/v1/invoices/template_update_request.rb +35 -0
- data/lib/v1/orders/orders_cancel_request.rb +31 -0
- data/lib/v1/orders/orders_create_request.rb +33 -0
- data/lib/v1/orders/orders_get_request.rb +31 -0
- data/lib/v1/orders/orders_pay_request.rb +35 -0
- data/lib/v1/payment_experience/web_profile_create_request.rb +33 -0
- data/lib/v1/payment_experience/web_profile_delete_request.rb +31 -0
- data/lib/v1/payment_experience/web_profile_get_request.rb +31 -0
- data/lib/v1/payment_experience/web_profile_list_request.rb +29 -0
- data/lib/v1/payment_experience/web_profile_partial_update_request.rb +35 -0
- data/lib/v1/payment_experience/web_profile_update_request.rb +35 -0
- data/lib/v1/payments/authorization_capture_request.rb +35 -0
- data/lib/v1/payments/authorization_get_request.rb +31 -0
- data/lib/v1/payments/authorization_reauthorize_request.rb +35 -0
- data/lib/v1/payments/authorization_void_request.rb +31 -0
- data/lib/v1/payments/capture_get_request.rb +31 -0
- data/lib/v1/payments/capture_refund_request.rb +35 -0
- data/lib/v1/payments/order_authorize_request.rb +35 -0
- data/lib/v1/payments/order_capture_request.rb +35 -0
- data/lib/v1/payments/order_get_request.rb +31 -0
- data/lib/v1/payments/order_void_request.rb +31 -0
- data/lib/v1/payments/payment_create_request.rb +33 -0
- data/lib/v1/payments/payment_execute_request.rb +35 -0
- data/lib/v1/payments/payment_get_request.rb +31 -0
- data/lib/v1/payments/payment_list_request.rb +69 -0
- data/lib/v1/payments/payment_update_request.rb +35 -0
- data/lib/v1/payments/refund_get_request.rb +31 -0
- data/lib/v1/payments/sale_get_request.rb +31 -0
- data/lib/v1/payments/sale_refund_request.rb +35 -0
- data/lib/v1/sync/search_get_request.rb +99 -0
- data/lib/v1/vault/credit_card_create_request.rb +33 -0
- data/lib/v1/vault/credit_card_delete_request.rb +31 -0
- data/lib/v1/vault/credit_card_get_request.rb +31 -0
- data/lib/v1/vault/credit_card_list_request.rb +79 -0
- data/lib/v1/vault/credit_card_update_request.rb +35 -0
- data/lib/v1/webhooks/available_event_type_list_request.rb +29 -0
- data/lib/v1/webhooks/event_get_request.rb +31 -0
- data/lib/v1/webhooks/event_list_request.rb +54 -0
- data/lib/v1/webhooks/event_resend_request.rb +35 -0
- data/lib/v1/webhooks/simulate_event_request.rb +33 -0
- data/lib/v1/webhooks/webhook_create_request.rb +33 -0
- data/lib/v1/webhooks/webhook_delete_request.rb +31 -0
- data/lib/v1/webhooks/webhook_get_request.rb +31 -0
- data/lib/v1/webhooks/webhook_list_event_subscriptions_request.rb +31 -0
- data/lib/v1/webhooks/webhook_list_request.rb +34 -0
- data/lib/v1/webhooks/webhook_update_request.rb +35 -0
- data/lib/v1/webhooks/webhook_verify_signature_request.rb +33 -0
- data/spec/integration/test_harness.rb +25 -0
- data/spec/integration/v1/billing_agreements/agreement_create_spec.rb +63 -0
- data/spec/integration/v1/billing_plans/plan_create_spec.rb +12 -0
- data/spec/integration/v1/billing_plans/plan_get_spec.rb +16 -0
- data/spec/integration/v1/billing_plans/plan_helper.rb +71 -0
- data/spec/integration/v1/billing_plans/plan_list_spec.rb +16 -0
- data/spec/integration/v1/billing_plans/plan_update_spec.rb +19 -0
- data/spec/integration/v1/identity/userinfo_get_spec.rb +65 -0
- data/spec/integration/v1/invoices/invoice_cancel_spec.rb +23 -0
- data/spec/integration/v1/invoices/invoice_create_spec.rb +15 -0
- data/spec/integration/v1/invoices/invoice_delete_external_payment_spec.rb +23 -0
- data/spec/integration/v1/invoices/invoice_delete_external_refund_spec.rb +21 -0
- data/spec/integration/v1/invoices/invoice_delete_spec.rb +16 -0
- data/spec/integration/v1/invoices/invoice_get_spec.rb +18 -0
- data/spec/integration/v1/invoices/invoice_helper.rb +171 -0
- data/spec/integration/v1/invoices/invoice_list_spec.rb +20 -0
- data/spec/integration/v1/invoices/invoice_next_invoice_number_spec.rb +14 -0
- data/spec/integration/v1/invoices/invoice_qr_code_spec.rb +18 -0
- data/spec/integration/v1/invoices/invoice_record_payment_spec.rb +14 -0
- data/spec/integration/v1/invoices/invoice_record_refund_spec.rb +14 -0
- data/spec/integration/v1/invoices/invoice_remind_spec.rb +22 -0
- data/spec/integration/v1/invoices/invoice_search_spec.rb +20 -0
- data/spec/integration/v1/invoices/invoice_send_spec.rb +15 -0
- data/spec/integration/v1/invoices/invoice_update_spec.rb +26 -0
- data/spec/integration/v1/invoices/template_create_spec.rb +14 -0
- data/spec/integration/v1/invoices/template_delete_spec.rb +15 -0
- data/spec/integration/v1/invoices/template_get_spec.rb +18 -0
- data/spec/integration/v1/invoices/template_list_spec.rb +15 -0
- data/spec/integration/v1/invoices/template_update_spec.rb +62 -0
- data/spec/integration/v1/orders/orders_cancel_spec.rb +15 -0
- data/spec/integration/v1/orders/orders_create_spec.rb +17 -0
- data/spec/integration/v1/orders/orders_get_spec.rb +18 -0
- data/spec/integration/v1/orders/orders_helper.rb +36 -0
- data/spec/integration/v1/orders/orders_pay_spec.rb +19 -0
- data/spec/integration/v1/payment_experience/pe_helper.rb +35 -0
- data/spec/integration/v1/payment_experience/web_profile_create_spec.rb +20 -0
- data/spec/integration/v1/payment_experience/web_profile_delete_spec.rb +15 -0
- data/spec/integration/v1/payment_experience/web_profile_get_spec.rb +17 -0
- data/spec/integration/v1/payment_experience/web_profile_list_spec.rb +18 -0
- data/spec/integration/v1/payment_experience/web_profile_partial_update_spec.rb +32 -0
- data/spec/integration/v1/payment_experience/web_profile_update_spec.rb +44 -0
- data/spec/integration/v1/payments/authorization_capture_spec.rb +17 -0
- data/spec/integration/v1/payments/authorization_get_spec.rb +18 -0
- data/spec/integration/v1/payments/authorization_reauthorize_spec.rb +26 -0
- data/spec/integration/v1/payments/authorization_void_spec.rb +19 -0
- data/spec/integration/v1/payments/capture_get_spec.rb +20 -0
- data/spec/integration/v1/payments/capture_refund_spec.rb +27 -0
- data/spec/integration/v1/payments/order_authorize_spec.rb +20 -0
- data/spec/integration/v1/payments/order_capture_spec.rb +21 -0
- data/spec/integration/v1/payments/order_get_spec.rb +14 -0
- data/spec/integration/v1/payments/order_void_spec.rb +14 -0
- data/spec/integration/v1/payments/payment_create_spec.rb +13 -0
- data/spec/integration/v1/payments/payment_execute_spec.rb +19 -0
- data/spec/integration/v1/payments/payment_get_spec.rb +17 -0
- data/spec/integration/v1/payments/payment_list_spec.rb +16 -0
- data/spec/integration/v1/payments/payment_update_spec.rb +28 -0
- data/spec/integration/v1/payments/payments_helper.rb +72 -0
- data/spec/integration/v1/payments/refund_get_spec.rb +19 -0
- data/spec/integration/v1/payments/sale_get_spec.rb +18 -0
- data/spec/integration/v1/payments/sale_refund_spec.rb +18 -0
- data/spec/integration/v1/sync/search_get_spec.rb +34 -0
- data/spec/integration/v1/vault/credit_card_create_spec.rb +16 -0
- data/spec/integration/v1/vault/credit_card_delete_spec.rb +16 -0
- data/spec/integration/v1/vault/credit_card_get_spec.rb +17 -0
- data/spec/integration/v1/vault/credit_card_list_spec.rb +18 -0
- data/spec/integration/v1/vault/credit_card_update_spec.rb +26 -0
- data/spec/integration/v1/vault/vault_helper.rb +28 -0
- data/spec/integration/v1/webhooks/available_event_type_list_spec.rb +16 -0
- data/spec/integration/v1/webhooks/webhook_create_spec.rb +12 -0
- data/spec/integration/v1/webhooks/webhook_delete_spec.rb +13 -0
- data/spec/integration/v1/webhooks/webhook_get_spec.rb +16 -0
- data/spec/integration/v1/webhooks/webhook_helper.rb +43 -0
- data/spec/integration/v1/webhooks/webhook_list_event_subscriptions_spec.rb +16 -0
- data/spec/integration/v1/webhooks/webhook_list_spec.rb +15 -0
- data/spec/integration/v1/webhooks/webhook_update_spec.rb +29 -0
- data/spec/integration/v1/webhooks/webhook_verify_signature_spec.rb +20 -0
- data/spec/spec_helper.rb +97 -28
- data/spec/unit/paypal_http_client_spec.rb +264 -0
- metadata +257 -126
- data/Rakefile +0 -15
- data/data/DigiCertHighAssuranceEVRootCA.pem +0 -23
- data/data/DigiCertSHA2ExtendedValidationServerCA.pem +0 -28
- data/data/paypal.crt +0 -171
- data/lib/generators/paypal/sdk/USAGE +0 -3
- data/lib/generators/paypal/sdk/install_generator.rb +0 -17
- data/lib/generators/paypal/sdk/templates/paypal.rb +0 -2
- data/lib/generators/paypal/sdk/templates/paypal.yml +0 -29
- data/lib/paypal-sdk/core/api/base.rb +0 -169
- data/lib/paypal-sdk/core/api/data_types/array_with_block.rb +0 -44
- data/lib/paypal-sdk/core/api/data_types/base.rb +0 -225
- data/lib/paypal-sdk/core/api/data_types/enum.rb +0 -26
- data/lib/paypal-sdk/core/api/data_types/simple_types.rb +0 -52
- data/lib/paypal-sdk/core/api/ipn.rb +0 -66
- data/lib/paypal-sdk/core/api/rest.rb +0 -177
- data/lib/paypal-sdk/core/api.rb +0 -20
- data/lib/paypal-sdk/core/authentication.rb +0 -66
- data/lib/paypal-sdk/core/config.rb +0 -253
- data/lib/paypal-sdk/core/credential/base.rb +0 -27
- data/lib/paypal-sdk/core/credential/certificate.rb +0 -32
- data/lib/paypal-sdk/core/credential/signature.rb +0 -22
- data/lib/paypal-sdk/core/credential/third_party/subject.rb +0 -25
- data/lib/paypal-sdk/core/credential/third_party/token.rb +0 -39
- data/lib/paypal-sdk/core/credential.rb +0 -16
- data/lib/paypal-sdk/core/exceptions.rb +0 -112
- data/lib/paypal-sdk/core/logging.rb +0 -50
- data/lib/paypal-sdk/core/openid_connect/api.rb +0 -50
- data/lib/paypal-sdk/core/openid_connect/data_types.rb +0 -73
- data/lib/paypal-sdk/core/openid_connect/get_api.rb +0 -28
- data/lib/paypal-sdk/core/openid_connect/request_data_type.rb +0 -52
- data/lib/paypal-sdk/core/openid_connect/set_api.rb +0 -36
- data/lib/paypal-sdk/core/openid_connect.rb +0 -140
- data/lib/paypal-sdk/core/util/http_helper.rb +0 -171
- data/lib/paypal-sdk/core/util/oauth_signature.rb +0 -64
- data/lib/paypal-sdk/core/util/ordered_hash.rb +0 -165
- data/lib/paypal-sdk/core/util.rb +0 -11
- data/lib/paypal-sdk/rest/api.rb +0 -23
- data/lib/paypal-sdk/rest/data_types.rb +0 -2597
- data/lib/paypal-sdk/rest/error_hash.rb +0 -39
- data/lib/paypal-sdk/rest/get_api.rb +0 -20
- data/lib/paypal-sdk/rest/request_data_type.rb +0 -53
- data/lib/paypal-sdk/rest/set_api.rb +0 -42
- data/lib/paypal-sdk/rest/version.rb +0 -7
- data/lib/paypal-sdk/rest.rb +0 -39
- data/lib/paypal-sdk-core.rb +0 -38
- data/lib/paypal-sdk-rest.rb +0 -2
- data/spec/README.md +0 -22
- data/spec/config/cacert.pem +0 -171
- data/spec/config/cert_key.pem +0 -33
- data/spec/config/paypal.yml +0 -35
- data/spec/config/sample_data.yml +0 -3
- data/spec/core/api/data_type_spec.rb +0 -289
- data/spec/core/api/rest_spec.rb +0 -211
- data/spec/core/config_spec.rb +0 -192
- data/spec/core/logging_spec.rb +0 -28
- data/spec/core/openid_connect_spec.rb +0 -153
- data/spec/invoice_examples_spec.rb +0 -38
- data/spec/payments_examples_spec.rb +0 -437
- data/spec/payouts_examples_spec.rb +0 -74
- data/spec/rest/data_types_spec.rb +0 -62
- data/spec/rest/error_hash_spec.rb +0 -83
- data/spec/subscription_examples_spec.rb +0 -227
- data/spec/support/sample_data.rb +0 -5
- data/spec/web_profile_examples_spec.rb +0 -106
- data/spec/webhooks_examples_spec.rb +0 -93
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 45787495ebb89e16774f4eec5eb3927a445e7f7a
|
4
|
+
data.tar.gz: 54d9b9db9a19ee483c1918894ca2d0ce34a3e0dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d82a1c5976df45733b87b2deb887db6f91d4fc390db57464c9c748b1874420051785e0c15e69083b9571e7bbf715472de8d9aeb93ed1d418df296afa80345262
|
7
|
+
data.tar.gz: 826180fe0c068f828a73d2cf5863631b1158c15cd5c0e9d5d875881781b6c12a54d5585aad1560a5176c8839a49b868c26b3cfefb1daa90026ccc9d32417fa96
|
data/Gemfile
CHANGED
@@ -1,15 +1,5 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
gem 'rake', :require => false
|
8
|
-
|
9
|
-
group :test do
|
10
|
-
gem 'simplecov', :require => false
|
11
|
-
gem 'rspec'
|
12
|
-
gem 'webmock'
|
13
|
-
end
|
14
|
-
|
15
|
-
gem 'releasinator', '~> 0.6'
|
3
|
+
gem "rspec"
|
4
|
+
gem "webmock"
|
5
|
+
gem "braintreehttp", '0.4.4'
|
data/README.md
CHANGED
@@ -1,282 +1,72 @@
|
|
1
|
-
#
|
2
|
-
This SDK is deprecated. You can continue to use it, but no new features or support requests will be accepted.
|
3
|
-
For alternatives, please visit [the current SDK homepage on the PayPal Developer Portal](https://developer.paypal.com/docs/api/rest-sdks/)
|
1
|
+
# PayPal SDK 2.0.0-beta [![Build Status](https://travis-ci.org/paypal/PayPal-ruby-SDK.svg?branch=2.0-beta)](https://travis-ci.org/paypal/PayPal-ruby-SDK)
|
4
2
|
|
5
|
-
|
3
|
+
This is a preview of how PayPal SDKs will look in the next major version. We've simplified the interface to only provide HTTPRequest that can easily be called via our HttpClient.
|
6
4
|
|
7
|
-
|
8
|
-
The PayPal REST SDK provides Ruby APIs to create, process and manage payment.
|
9
|
-
|
10
|
-
## PayPal Checkout v2
|
11
|
-
Please note that if you are integrating with PayPal Checkout, this SDK and corresponding API [v1/payments](https://developer.paypal.com/docs/api/payments/v1/) are in the process of being deprecated.
|
12
|
-
|
13
|
-
We recommend that you integrate with API [v2/checkout/orders](https://developer.paypal.com/docs/api/orders/v2/) and [v2/payments](https://developer.paypal.com/docs/api/payments/v2/). Please refer to the [Checkout Ruby SDK](https://github.com/paypal/Checkout-Ruby-SDK) to continue with the integration.
|
14
|
-
|
15
|
-
|
16
|
-
## 2.0 Release Candidate!
|
17
|
-
We're releasing a [brand new version of our SDK!](https://github.com/paypal/PayPal-Ruby-SDK/tree/2.0-beta) 2.0 is currently at release candidate status, and represents a full refactor, with the goal of making all of our APIs extremely easy to use. 2.0 includes all of the existing APIs (except payouts), and includes the new Orders API (disputes and Marketplace coming soon). Check out the [FAQ and migration guide](https://github.com/paypal/PayPal-Ruby-SDK/tree/2.0-beta/docs), and let us know if you have any suggestions or issues!
|
18
|
-
|
19
|
-
## Prerequisites
|
20
|
-
- Ruby 2.0.0 or above
|
21
|
-
- Bundler
|
22
|
-
|
23
|
-
## Installation
|
24
|
-
|
25
|
-
Add this line to your application's Gemfile:
|
26
|
-
|
27
|
-
```ruby
|
28
|
-
gem 'paypal-sdk-rest'
|
29
|
-
```
|
30
|
-
|
31
|
-
And then execute:
|
32
|
-
|
33
|
-
```sh
|
34
|
-
$ bundle
|
35
|
-
```
|
36
|
-
|
37
|
-
Or install it yourself as:
|
38
|
-
|
39
|
-
```sh
|
40
|
-
$ gem install paypal-sdk-rest
|
41
|
-
```
|
42
|
-
|
43
|
-
## Configuration
|
44
|
-
|
45
|
-
For Rails application:
|
46
|
-
|
47
|
-
```sh
|
48
|
-
rails g paypal:sdk:install
|
49
|
-
```
|
50
|
-
|
51
|
-
For other ruby application, create a configuration file(`config/paypal.yml`):
|
52
|
-
|
53
|
-
```yaml
|
54
|
-
development: &default
|
55
|
-
mode: sandbox
|
56
|
-
client_id: EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM
|
57
|
-
client_secret: EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM
|
58
|
-
# # with Proxy
|
59
|
-
# http_proxy: http://proxy-ipaddress:3129/
|
60
|
-
# # with CA File
|
61
|
-
# ssl_options:
|
62
|
-
# ca_file: config/cacert.pem
|
63
|
-
# # Override Endpoint
|
64
|
-
# rest_endpoint: https://api.sandbox.paypal.com
|
65
|
-
test:
|
66
|
-
<<: *default
|
67
|
-
production:
|
68
|
-
mode: live
|
69
|
-
client_id: CLIENT_ID
|
70
|
-
client_secret: CLIENT_SECRET
|
71
|
-
```
|
72
|
-
|
73
|
-
|
74
|
-
Load Configurations from specified file:
|
75
|
-
|
76
|
-
```ruby
|
77
|
-
PayPal::SDK::Core::Config.load('spec/config/paypal.yml', ENV['RACK_ENV'] || 'development')
|
78
|
-
```
|
79
|
-
|
80
|
-
Without configuration file:
|
81
|
-
|
82
|
-
```ruby
|
83
|
-
PayPal::SDK.configure(
|
84
|
-
:mode => "sandbox", # "sandbox" or "live"
|
85
|
-
:client_id => "EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM",
|
86
|
-
:client_secret => "EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM",
|
87
|
-
:ssl_options => { } )
|
88
|
-
```
|
89
|
-
|
90
|
-
Logger configuration:
|
91
|
-
|
92
|
-
```ruby
|
93
|
-
PayPal::SDK.logger = Logger.new(STDERR)
|
94
|
-
|
95
|
-
# change log level to INFO
|
96
|
-
PayPal::SDK.logger.level = Logger::INFO
|
97
|
-
```
|
98
|
-
**NOTE**: At `DEBUG` level, all requests/responses are logged except when `mode` is set to `live`. In order to disable request/response printing, set the log level to `INFO` or less verbose ones.
|
99
|
-
|
100
|
-
|
101
|
-
### OpenIDConnect Samples
|
5
|
+
### Creating a Payment
|
102
6
|
|
103
7
|
```ruby
|
104
8
|
require 'paypal-sdk-rest'
|
105
9
|
|
106
|
-
|
107
|
-
PayPal::SDK.configure({
|
108
|
-
:openid_client_id => "client_id",
|
109
|
-
:openid_client_secret => "client_secret",
|
110
|
-
:openid_redirect_uri => "http://google.com"
|
111
|
-
})
|
112
|
-
include PayPal::SDK::OpenIDConnect
|
113
|
-
|
114
|
-
# Generate URL to Get Authorize code
|
115
|
-
puts Tokeninfo.authorize_url( :scope => "openid profile" )
|
116
|
-
|
117
|
-
# Create tokeninfo by using AuthorizeCode from redirect_uri
|
118
|
-
tokeninfo = Tokeninfo.create("Replace with Authorize Code received on redirect_uri")
|
119
|
-
puts tokeninfo.to_hash
|
120
|
-
|
121
|
-
# Refresh tokeninfo object
|
122
|
-
tokeninfo = tokeninfo.refresh
|
123
|
-
puts tokeninfo.to_hash
|
124
|
-
|
125
|
-
# Create tokeninfo by using refresh token
|
126
|
-
tokeninfo = Tokeninfo.refresh("Replace with refresh_token")
|
127
|
-
puts tokeninfo.to_hash
|
128
|
-
|
129
|
-
# Get Userinfo
|
130
|
-
userinfo = tokeninfo.userinfo
|
131
|
-
puts userinfo.to_hash
|
132
|
-
|
133
|
-
# Get logout url
|
134
|
-
put tokeninfo.logout_url
|
135
|
-
```
|
136
|
-
|
137
|
-
## Create Payment
|
10
|
+
include PayPal::V1::Payments
|
138
11
|
|
139
|
-
|
140
|
-
|
141
|
-
include PayPal::SDK::REST
|
12
|
+
environment = PayPal::SandboxEnvironment.new('AdV4d6nLHabWLyemrw4BKdO9LjcnioNIOgoz7vD611ObbDUL0kJQfzrdhXEBwnH8QmV-7XZjvjRWn0kg', 'EPKoPC_haZMTq5uM9WXuzoxUVdgzVqHyD5avCyVC1NCIUJeVaNNUZMnzduYIqrdw-carG9LBAizFGMyK')
|
13
|
+
client = PayPal::PayPalHttpClient.new(environment)
|
142
14
|
|
143
|
-
|
144
|
-
:
|
145
|
-
:
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
:payer => {
|
152
|
-
:payment_method => "paypal" },
|
15
|
+
payment = {
|
16
|
+
:intent => "sale",
|
17
|
+
:transactions => [
|
18
|
+
:amount => {
|
19
|
+
:currency => "USD",
|
20
|
+
:amount => "10"
|
21
|
+
}
|
22
|
+
],
|
153
23
|
:redirect_urls => {
|
154
|
-
:
|
155
|
-
:
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
:price => "5",
|
162
|
-
:currency => "USD",
|
163
|
-
:quantity => 1 }]},
|
164
|
-
:amount => {
|
165
|
-
:total => "5",
|
166
|
-
:currency => "USD" },
|
167
|
-
:description => "This is the payment transaction description." }]})
|
168
|
-
|
169
|
-
if @payment.create
|
170
|
-
@payment.id # Payment Id
|
171
|
-
else
|
172
|
-
@payment.error # Error Hash
|
173
|
-
end
|
174
|
-
```
|
175
|
-
|
176
|
-
## Get Payment details
|
177
|
-
|
178
|
-
```ruby
|
179
|
-
# Fetch Payment
|
180
|
-
payment = Payment.find("PAY-57363176S1057143SKE2HO3A")
|
24
|
+
:cancel_url => "http://example.com/cancel",
|
25
|
+
:return_url => "http://example.com/return"
|
26
|
+
},
|
27
|
+
:payer => {
|
28
|
+
:payment_method" => "paypal"
|
29
|
+
}
|
30
|
+
}
|
181
31
|
|
182
|
-
# Get List of Payments
|
183
|
-
payment_history = Payment.all( :count => 10 )
|
184
|
-
payment_history.payments
|
185
|
-
```
|
186
32
|
|
187
|
-
|
33
|
+
request = PaymentCreateRequest.new
|
34
|
+
request.request_body(payment);
|
188
35
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
payment.error # Error Hash
|
36
|
+
begin
|
37
|
+
response = client.execute(request)
|
38
|
+
puts response.status_code
|
39
|
+
puts response.result
|
40
|
+
rescue BraintreeHttp::HttpError => e
|
41
|
+
puts e.status_code
|
42
|
+
puts e.result
|
197
43
|
end
|
198
44
|
```
|
199
45
|
|
200
|
-
|
201
|
-
[Future Payments](https://developer.paypal.com/docs/integration/mobile/make-future-payment/) sample is available [here](https://github.com/paypal/rest-api-sdk-ruby/blob/master/samples/payment/create_future_payment.rb#L149)
|
202
|
-
|
203
|
-
## Webhook event validation
|
204
|
-
See [webhook event validation code sample](https://github.com/paypal/PayPal-Ruby-SDK/blob/master/samples/notifications/verify_webhook_event.rb) and [webhook event validation docs](https://developer.paypal.com/docs/integration/direct/rest-webhooks-overview/#event-signature)
|
205
|
-
|
206
|
-
## OpenID Connect
|
207
|
-
|
208
|
-
```ruby
|
209
|
-
# Update client_id, client_secret and redirect_uri
|
210
|
-
PayPal::SDK.configure({
|
211
|
-
:openid_client_id => "client_id",
|
212
|
-
:openid_client_secret => "client_secret",
|
213
|
-
:openid_redirect_uri => "http://google.com"
|
214
|
-
})
|
215
|
-
include PayPal::SDK::OpenIDConnect
|
216
|
-
|
217
|
-
# Generate authorize URL to Get Authorize code
|
218
|
-
puts Tokeninfo.authorize_url( :scope => "openid profile" )
|
46
|
+
If you're migrating from v1, check out our [Migration Guide](./docs/Migrating.md) or our [Frequently Asked Questions](./docs/FAQ.md).
|
219
47
|
|
220
|
-
|
221
|
-
tokeninfo = Tokeninfo.create("Replace with Authorize Code received on redirect_uri")
|
48
|
+
## Building
|
222
49
|
|
223
|
-
|
224
|
-
tokeninfo.refresh
|
50
|
+
To try this out, update the version of `paypalrestsdk` in your `Gemfile` to `2.0.0.rc1`.
|
225
51
|
|
226
|
-
|
227
|
-
tokeninfo = Tokeninfo.refresh("Replace with refresh_token")
|
52
|
+
Please feel free to create an issue in this repo with any feedback, questions, or concerns you have.
|
228
53
|
|
229
|
-
|
230
|
-
userinfo = tokeninfo.userinfo
|
54
|
+
## Running tests
|
231
55
|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
logout_url = tokeninfo.logout_url
|
56
|
+
To run integration tests using your client id and secret, clone this repository and run the following command:
|
57
|
+
```sh
|
58
|
+
$ bundle install
|
59
|
+
$ rspec spec/integration
|
237
60
|
```
|
238
|
-
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/paypal/rest-api-sdk-ruby/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
239
|
-
|
240
|
-
|
241
|
-
## Payouts
|
242
|
-
|
243
|
-
To make Payouts, you should enable this option in your account at http://developer.paypal.com.
|
244
61
|
|
245
|
-
|
246
|
-
@payout = Payout.new(
|
247
|
-
{
|
248
|
-
:sender_batch_header => {
|
249
|
-
:sender_batch_id => SecureRandom.hex(8),
|
250
|
-
:email_subject => 'You have a Payout!',
|
251
|
-
},
|
252
|
-
:items => [
|
253
|
-
{
|
254
|
-
:recipient_type => 'EMAIL',
|
255
|
-
:amount => {
|
256
|
-
:value => '1.0',
|
257
|
-
:currency => 'USD'
|
258
|
-
},
|
259
|
-
:note => 'Thanks for your patronage!',
|
260
|
-
:receiver => 'shirt-supplier-one@mail.com',
|
261
|
-
:sender_item_id => "2014031400023",
|
262
|
-
}
|
263
|
-
]
|
264
|
-
}
|
265
|
-
)
|
62
|
+
*NOTE*: This API is still in beta, is subject to change, and should not be used in production.
|
266
63
|
|
267
|
-
|
268
|
-
@payout_batch = @payout.create
|
269
|
-
logger.info "Created Payout with [#{@payout_batch.batch_header.payout_batch_id}]"
|
270
|
-
rescue ResourceNotFound => err
|
271
|
-
logger.error @payout.error.inspect
|
272
|
-
end
|
273
|
-
```
|
64
|
+
## Feedback
|
274
65
|
|
275
|
-
|
276
|
-
[Braintree Direct](https://www.braintreepayments.com/products/braintree-direct) is PayPal's preferred integration solution for accepting direct credit card payments in your mobile app or website. Braintree, a PayPal service, is the easiest way to accept credit cards, PayPal, and many other payment methods.
|
66
|
+
If you have any suggestions/remarks/feedback related to SDK 2.0.0, feel free to create an issue.
|
277
67
|
|
278
68
|
## License
|
279
|
-
|
69
|
+
PayPal-Ruby-SDK is open source. See the [LICENSE](./LICENSE) file for more info.
|
280
70
|
|
281
|
-
## Contributions
|
282
|
-
|
71
|
+
## Contributions
|
72
|
+
Pull requests and new issues are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
|
data/lib/lib.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
|
2
|
+
require_relative './paypal/core/access_token'
|
3
|
+
require_relative './paypal/core/paypal_environment'
|
4
|
+
require_relative './paypal/core/paypal_http_client'
|
5
|
+
require_relative './paypal/core/token_requests'
|
6
|
+
require_relative './paypal/core/version'
|
7
|
+
require_relative './v1/billing_agreements/agreement_bill_balance_request'
|
8
|
+
require_relative './v1/billing_agreements/agreement_cancel_request'
|
9
|
+
require_relative './v1/billing_agreements/agreement_create_request'
|
10
|
+
require_relative './v1/billing_agreements/agreement_execute_request'
|
11
|
+
require_relative './v1/billing_agreements/agreement_get_request'
|
12
|
+
require_relative './v1/billing_agreements/agreement_re_activate_request'
|
13
|
+
require_relative './v1/billing_agreements/agreement_set_balance_request'
|
14
|
+
require_relative './v1/billing_agreements/agreement_suspend_request'
|
15
|
+
require_relative './v1/billing_agreements/agreement_transactions_request'
|
16
|
+
require_relative './v1/billing_agreements/agreement_update_request'
|
17
|
+
require_relative './v1/billing_plans/plan_create_request'
|
18
|
+
require_relative './v1/billing_plans/plan_get_request'
|
19
|
+
require_relative './v1/billing_plans/plan_list_request'
|
20
|
+
require_relative './v1/billing_plans/plan_update_request'
|
21
|
+
require_relative './v1/identity/userinfo_get_request'
|
22
|
+
require_relative './v1/identity/user_consent'
|
23
|
+
require_relative './v1/invoices/invoice_cancel_request'
|
24
|
+
require_relative './v1/invoices/invoice_create_request'
|
25
|
+
require_relative './v1/invoices/invoice_delete_external_payment_request'
|
26
|
+
require_relative './v1/invoices/invoice_delete_external_refund_request'
|
27
|
+
require_relative './v1/invoices/invoice_delete_request'
|
28
|
+
require_relative './v1/invoices/invoice_get_request'
|
29
|
+
require_relative './v1/invoices/invoice_list_request'
|
30
|
+
require_relative './v1/invoices/invoice_next_invoice_number_request'
|
31
|
+
require_relative './v1/invoices/invoice_qr_code_request'
|
32
|
+
require_relative './v1/invoices/invoice_record_payment_request'
|
33
|
+
require_relative './v1/invoices/invoice_record_refund_request'
|
34
|
+
require_relative './v1/invoices/invoice_remind_request'
|
35
|
+
require_relative './v1/invoices/invoice_search_request'
|
36
|
+
require_relative './v1/invoices/invoice_send_request'
|
37
|
+
require_relative './v1/invoices/invoice_update_request'
|
38
|
+
require_relative './v1/invoices/template_create_request'
|
39
|
+
require_relative './v1/invoices/template_delete_request'
|
40
|
+
require_relative './v1/invoices/template_get_request'
|
41
|
+
require_relative './v1/invoices/template_list_request'
|
42
|
+
require_relative './v1/invoices/template_update_request'
|
43
|
+
require_relative './v1/orders/orders_cancel_request'
|
44
|
+
require_relative './v1/orders/orders_create_request'
|
45
|
+
require_relative './v1/orders/orders_get_request'
|
46
|
+
require_relative './v1/orders/orders_pay_request'
|
47
|
+
require_relative './v1/payment_experience/web_profile_create_request'
|
48
|
+
require_relative './v1/payment_experience/web_profile_delete_request'
|
49
|
+
require_relative './v1/payment_experience/web_profile_get_request'
|
50
|
+
require_relative './v1/payment_experience/web_profile_list_request'
|
51
|
+
require_relative './v1/payment_experience/web_profile_partial_update_request'
|
52
|
+
require_relative './v1/payment_experience/web_profile_update_request'
|
53
|
+
require_relative './v1/payments/authorization_capture_request'
|
54
|
+
require_relative './v1/payments/authorization_get_request'
|
55
|
+
require_relative './v1/payments/authorization_reauthorize_request'
|
56
|
+
require_relative './v1/payments/authorization_void_request'
|
57
|
+
require_relative './v1/payments/capture_get_request'
|
58
|
+
require_relative './v1/payments/capture_refund_request'
|
59
|
+
require_relative './v1/payments/order_authorize_request'
|
60
|
+
require_relative './v1/payments/order_capture_request'
|
61
|
+
require_relative './v1/payments/order_get_request'
|
62
|
+
require_relative './v1/payments/order_void_request'
|
63
|
+
require_relative './v1/payments/payment_create_request'
|
64
|
+
require_relative './v1/payments/payment_execute_request'
|
65
|
+
require_relative './v1/payments/payment_get_request'
|
66
|
+
require_relative './v1/payments/payment_list_request'
|
67
|
+
require_relative './v1/payments/payment_update_request'
|
68
|
+
require_relative './v1/payments/refund_get_request'
|
69
|
+
require_relative './v1/payments/sale_get_request'
|
70
|
+
require_relative './v1/payments/sale_refund_request'
|
71
|
+
require_relative './v1/sync/search_get_request'
|
72
|
+
require_relative './v1/vault/credit_card_create_request'
|
73
|
+
require_relative './v1/vault/credit_card_delete_request'
|
74
|
+
require_relative './v1/vault/credit_card_get_request'
|
75
|
+
require_relative './v1/vault/credit_card_list_request'
|
76
|
+
require_relative './v1/vault/credit_card_update_request'
|
77
|
+
require_relative './v1/webhooks/available_event_type_list_request'
|
78
|
+
require_relative './v1/webhooks/event_get_request'
|
79
|
+
require_relative './v1/webhooks/event_list_request'
|
80
|
+
require_relative './v1/webhooks/event_resend_request'
|
81
|
+
require_relative './v1/webhooks/simulate_event_request'
|
82
|
+
require_relative './v1/webhooks/webhook_create_request'
|
83
|
+
require_relative './v1/webhooks/webhook_delete_request'
|
84
|
+
require_relative './v1/webhooks/webhook_get_request'
|
85
|
+
require_relative './v1/webhooks/webhook_list_event_subscriptions_request'
|
86
|
+
require_relative './v1/webhooks/webhook_list_request'
|
87
|
+
require_relative './v1/webhooks/webhook_update_request'
|
88
|
+
require_relative './v1/webhooks/webhook_verify_signature_request'
|
@@ -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 * 1000
|
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 "braintreehttp"
|
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 < BraintreeHttp::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,51 @@
|
|
1
|
+
require "braintreehttp"
|
2
|
+
require_relative './version'
|
3
|
+
|
4
|
+
module PayPal
|
5
|
+
class PayPalHttpClient < BraintreeHttp::HttpClient
|
6
|
+
attr_accessor :refresh_token
|
7
|
+
|
8
|
+
def initialize(environment, refresh_token = nil)
|
9
|
+
super(environment)
|
10
|
+
@refresh_token = refresh_token
|
11
|
+
|
12
|
+
add_injector(&method(:_sign_request))
|
13
|
+
add_injector(&method(:_add_headers))
|
14
|
+
end
|
15
|
+
|
16
|
+
def user_agent
|
17
|
+
library_details ||= "paypal-sdk-core #{VERSION}; ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}-#{RUBY_PLATFORM}"
|
18
|
+
begin
|
19
|
+
library_details << ";#{OpenSSL::OPENSSL_LIBRARY_VERSION}"
|
20
|
+
rescue NameError
|
21
|
+
library_details << ";OpenSSL #{OpenSSL::OPENSSL_VERSION}"
|
22
|
+
end
|
23
|
+
|
24
|
+
"PayPalSDK/rest-sdk-ruby #{VERSION} (#{library_details})"
|
25
|
+
end
|
26
|
+
|
27
|
+
def _sign_request(request)
|
28
|
+
if (!_has_auth_header(request) && !_is_auth_request(request))
|
29
|
+
if (!@access_token || @access_token.isExpired)
|
30
|
+
accessTokenRequest = PayPal::AccessTokenRequest.new(@environment, @refresh_token)
|
31
|
+
tokenResponse = execute(accessTokenRequest)
|
32
|
+
@access_token = PayPal::AccessToken.new(tokenResponse.result)
|
33
|
+
end
|
34
|
+
request.headers["Authorization"] = @access_token.authorizationString()
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def _add_headers(request)
|
39
|
+
request.headers["Accept-Encoding"] = "gzip"
|
40
|
+
end
|
41
|
+
|
42
|
+
def _is_auth_request(request)
|
43
|
+
request.path == '/v1/oauth2/token' ||
|
44
|
+
request.path == '/v1/identity/openidconnect/tokenservice'
|
45
|
+
end
|
46
|
+
|
47
|
+
def _has_auth_header(request)
|
48
|
+
request.headers.key?("Authorization")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
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,35 @@
|
|
1
|
+
# This class was generated on Thu, 01 Feb 2018 12:44:43 PST by version 0.1.0-dev+3a517e of Braintree SDK Generator
|
2
|
+
# agreement_bill_balance_request.rb
|
3
|
+
# @version 0.1.0-dev+3a517e
|
4
|
+
# @type request
|
5
|
+
# @data H4sIAAAAAAAC/6RUTW/TQBC98ytGc97WBXHyLTSgBkQTSMQFVdXYO4kXbXbd3TFgRfnvaG03H45UhDhFeX4z896bsXd4T1vGHGkTmLfs5Low1l4VZMmVjAqnHMtgajHeYY7vjLURpGIYGLD2AcjBoV5B0cJseg0z1/E+Luf3EPip4ShQeN0qMK60jeZU5rvGZMF5YZCKBHQ3sOB+TGCK3nVTuqnGWuM2QGWqA3K6gw/Tgba+ST9OQ9mEwK5sr1Hhl4ZDu6BAWxYOEfPvDwrvmDSHMfrBh+0YW5BUZ9gOV22dcosSjNugwm8UDBWWx3k+Go0KP3E7PLiIdFUxzKbg1yMnyfKvypQViO98n8aePE1CoLaXcaPwK5OeO9tiviYbOQFPjQmsMZfQsMJF8DUHMRwxd421+4eew1H6JgdPk4OGpZAwPOv14SWfMXEf9Sn36PpF2nkeE9DH/8+x9LsU6KovsvqnNAbgNI6/rzOd55mhAbhc5ehgj/vspZcVuQ3/r+B+f/vEirV3kfs+CVZ4652wG5aKVNfWlJQUZj+id6jwTqT+zFJ5jTku5ssV9heOOWY/X2c1tUlwzIaX7ergIWa707veZ6NvxfvfNZfCOp1NE2+9Zszf3Lzdv/oDAAD//w==
|
6
|
+
# DO NOT EDIT
|
7
|
+
require 'cgi'
|
8
|
+
|
9
|
+
module PayPal
|
10
|
+
module V1
|
11
|
+
module BillingAgreements
|
12
|
+
|
13
|
+
#
|
14
|
+
# Bills the balance for an agreement, by ID. In the JSON request body, include an optional note that describes the reason for the billing action and the agreement amount and currency.
|
15
|
+
#
|
16
|
+
class AgreementBillBalanceRequest
|
17
|
+
attr_accessor :path, :body, :headers, :verb
|
18
|
+
|
19
|
+
def initialize(agreement_id)
|
20
|
+
@headers = {}
|
21
|
+
@body = nil
|
22
|
+
@verb = "POST"
|
23
|
+
@path = "/v1/payments/billing-agreements/{agreement_id}/bill-balance?"
|
24
|
+
|
25
|
+
@path = @path.gsub("{agreement_id}", CGI::escape(agreement_id.to_s))
|
26
|
+
@headers["Content-Type"] = "application/json"
|
27
|
+
end
|
28
|
+
|
29
|
+
def request_body(agreementStateDescriptor)
|
30
|
+
@body = agreementStateDescriptor
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|