paypal-sdk-rest 1.7.4 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -14
- data/README.md +45 -251
- 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 +250 -120
- 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.rb +0 -38
- data/lib/paypal-sdk-rest.rb +0 -2
- data/lib/paypal-sdk/core/api.rb +0 -20
- 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/authentication.rb +0 -66
- data/lib/paypal-sdk/core/config.rb +0 -253
- data/lib/paypal-sdk/core/credential.rb +0 -16
- 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/exceptions.rb +0 -112
- data/lib/paypal-sdk/core/logging.rb +0 -50
- data/lib/paypal-sdk/core/openid_connect.rb +0 -140
- 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/util.rb +0 -11
- 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/rest.rb +0 -39
- 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/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
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
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,278 +1,72 @@
|
|
1
|
-
|
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)
|
2
2
|
|
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.
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
## PayPal Checkout v2
|
7
|
-
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.
|
8
|
-
|
9
|
-
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.
|
10
|
-
|
11
|
-
|
12
|
-
## 2.0 Release Candidate!
|
13
|
-
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!
|
14
|
-
|
15
|
-
## Prerequisites
|
16
|
-
- Ruby 2.0.0 or above
|
17
|
-
- Bundler
|
18
|
-
|
19
|
-
## Installation
|
20
|
-
|
21
|
-
Add this line to your application's Gemfile:
|
22
|
-
|
23
|
-
```ruby
|
24
|
-
gem 'paypal-sdk-rest'
|
25
|
-
```
|
26
|
-
|
27
|
-
And then execute:
|
28
|
-
|
29
|
-
```sh
|
30
|
-
$ bundle
|
31
|
-
```
|
32
|
-
|
33
|
-
Or install it yourself as:
|
34
|
-
|
35
|
-
```sh
|
36
|
-
$ gem install paypal-sdk-rest
|
37
|
-
```
|
38
|
-
|
39
|
-
## Configuration
|
40
|
-
|
41
|
-
For Rails application:
|
42
|
-
|
43
|
-
```sh
|
44
|
-
rails g paypal:sdk:install
|
45
|
-
```
|
46
|
-
|
47
|
-
For other ruby application, create a configuration file(`config/paypal.yml`):
|
48
|
-
|
49
|
-
```yaml
|
50
|
-
development: &default
|
51
|
-
mode: sandbox
|
52
|
-
client_id: EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM
|
53
|
-
client_secret: EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM
|
54
|
-
# # with Proxy
|
55
|
-
# http_proxy: http://proxy-ipaddress:3129/
|
56
|
-
# # with CA File
|
57
|
-
# ssl_options:
|
58
|
-
# ca_file: config/cacert.pem
|
59
|
-
# # Override Endpoint
|
60
|
-
# rest_endpoint: https://api.sandbox.paypal.com
|
61
|
-
test:
|
62
|
-
<<: *default
|
63
|
-
production:
|
64
|
-
mode: live
|
65
|
-
client_id: CLIENT_ID
|
66
|
-
client_secret: CLIENT_SECRET
|
67
|
-
```
|
68
|
-
|
69
|
-
|
70
|
-
Load Configurations from specified file:
|
71
|
-
|
72
|
-
```ruby
|
73
|
-
PayPal::SDK::Core::Config.load('spec/config/paypal.yml', ENV['RACK_ENV'] || 'development')
|
74
|
-
```
|
75
|
-
|
76
|
-
Without configuration file:
|
77
|
-
|
78
|
-
```ruby
|
79
|
-
PayPal::SDK.configure(
|
80
|
-
:mode => "sandbox", # "sandbox" or "live"
|
81
|
-
:client_id => "EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM",
|
82
|
-
:client_secret => "EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM",
|
83
|
-
:ssl_options => { } )
|
84
|
-
```
|
85
|
-
|
86
|
-
Logger configuration:
|
87
|
-
|
88
|
-
```ruby
|
89
|
-
PayPal::SDK.logger = Logger.new(STDERR)
|
90
|
-
|
91
|
-
# change log level to INFO
|
92
|
-
PayPal::SDK.logger.level = Logger::INFO
|
93
|
-
```
|
94
|
-
**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.
|
95
|
-
|
96
|
-
|
97
|
-
### OpenIDConnect Samples
|
5
|
+
### Creating a Payment
|
98
6
|
|
99
7
|
```ruby
|
100
8
|
require 'paypal-sdk-rest'
|
101
9
|
|
102
|
-
|
103
|
-
PayPal::SDK.configure({
|
104
|
-
:openid_client_id => "client_id",
|
105
|
-
:openid_client_secret => "client_secret",
|
106
|
-
:openid_redirect_uri => "http://google.com"
|
107
|
-
})
|
108
|
-
include PayPal::SDK::OpenIDConnect
|
109
|
-
|
110
|
-
# Generate URL to Get Authorize code
|
111
|
-
puts Tokeninfo.authorize_url( :scope => "openid profile" )
|
112
|
-
|
113
|
-
# Create tokeninfo by using AuthorizeCode from redirect_uri
|
114
|
-
tokeninfo = Tokeninfo.create("Replace with Authorize Code received on redirect_uri")
|
115
|
-
puts tokeninfo.to_hash
|
116
|
-
|
117
|
-
# Refresh tokeninfo object
|
118
|
-
tokeninfo = tokeninfo.refresh
|
119
|
-
puts tokeninfo.to_hash
|
120
|
-
|
121
|
-
# Create tokeninfo by using refresh token
|
122
|
-
tokeninfo = Tokeninfo.refresh("Replace with refresh_token")
|
123
|
-
puts tokeninfo.to_hash
|
124
|
-
|
125
|
-
# Get Userinfo
|
126
|
-
userinfo = tokeninfo.userinfo
|
127
|
-
puts userinfo.to_hash
|
128
|
-
|
129
|
-
# Get logout url
|
130
|
-
put tokeninfo.logout_url
|
131
|
-
```
|
132
|
-
|
133
|
-
## Create Payment
|
10
|
+
include PayPal::V1::Payments
|
134
11
|
|
135
|
-
|
136
|
-
|
137
|
-
include PayPal::SDK::REST
|
138
|
-
|
139
|
-
PayPal::SDK::REST.set_config(
|
140
|
-
:mode => "sandbox", # "sandbox" or "live"
|
141
|
-
:client_id => "EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM",
|
142
|
-
:client_secret => "EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM")
|
12
|
+
environment = PayPal::SandboxEnvironment.new('AdV4d6nLHabWLyemrw4BKdO9LjcnioNIOgoz7vD611ObbDUL0kJQfzrdhXEBwnH8QmV-7XZjvjRWn0kg', 'EPKoPC_haZMTq5uM9WXuzoxUVdgzVqHyD5avCyVC1NCIUJeVaNNUZMnzduYIqrdw-carG9LBAizFGMyK')
|
13
|
+
client = PayPal::PayPalHttpClient.new(environment)
|
143
14
|
|
144
|
-
|
145
|
-
|
146
|
-
:
|
147
|
-
|
148
|
-
|
15
|
+
payment = {
|
16
|
+
:intent => "sale",
|
17
|
+
:transactions => [
|
18
|
+
:amount => {
|
19
|
+
:currency => "USD",
|
20
|
+
:amount => "10"
|
21
|
+
}
|
22
|
+
],
|
149
23
|
:redirect_urls => {
|
150
|
-
:
|
151
|
-
:
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
:price => "5",
|
158
|
-
:currency => "USD",
|
159
|
-
:quantity => 1 }]},
|
160
|
-
:amount => {
|
161
|
-
:total => "5",
|
162
|
-
:currency => "USD" },
|
163
|
-
:description => "This is the payment transaction description." }]})
|
164
|
-
|
165
|
-
if @payment.create
|
166
|
-
@payment.id # Payment Id
|
167
|
-
else
|
168
|
-
@payment.error # Error Hash
|
169
|
-
end
|
170
|
-
```
|
171
|
-
|
172
|
-
## Get Payment details
|
173
|
-
|
174
|
-
```ruby
|
175
|
-
# Fetch Payment
|
176
|
-
payment = Payment.find("PAY-57363176S1057143SKE2HO3A")
|
177
|
-
|
178
|
-
# Get List of Payments
|
179
|
-
payment_history = Payment.all( :count => 10 )
|
180
|
-
payment_history.payments
|
181
|
-
```
|
24
|
+
:cancel_url => "http://example.com/cancel",
|
25
|
+
:return_url => "http://example.com/return"
|
26
|
+
},
|
27
|
+
:payer => {
|
28
|
+
:payment_method" => "paypal"
|
29
|
+
}
|
30
|
+
}
|
182
31
|
|
183
|
-
## Execute Payment
|
184
32
|
|
185
|
-
|
186
|
-
|
33
|
+
request = PaymentCreateRequest.new
|
34
|
+
request.request_body(payment);
|
187
35
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
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
|
193
43
|
end
|
194
44
|
```
|
195
45
|
|
196
|
-
|
197
|
-
[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)
|
198
|
-
|
199
|
-
## Webhook event validation
|
200
|
-
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)
|
201
|
-
|
202
|
-
## OpenID Connect
|
203
|
-
|
204
|
-
```ruby
|
205
|
-
# Update client_id, client_secret and redirect_uri
|
206
|
-
PayPal::SDK.configure({
|
207
|
-
:openid_client_id => "client_id",
|
208
|
-
:openid_client_secret => "client_secret",
|
209
|
-
:openid_redirect_uri => "http://google.com"
|
210
|
-
})
|
211
|
-
include PayPal::SDK::OpenIDConnect
|
212
|
-
|
213
|
-
# Generate authorize URL to Get Authorize code
|
214
|
-
puts Tokeninfo.authorize_url( :scope => "openid profile" )
|
215
|
-
|
216
|
-
# Create tokeninfo by using Authorize Code from redirect_uri
|
217
|
-
tokeninfo = Tokeninfo.create("Replace with Authorize Code received on redirect_uri")
|
46
|
+
If you're migrating from v1, check out our [Migration Guide](./docs/Migrating.md) or our [Frequently Asked Questions](./docs/FAQ.md).
|
218
47
|
|
219
|
-
|
220
|
-
tokeninfo.refresh
|
48
|
+
## Building
|
221
49
|
|
222
|
-
|
223
|
-
tokeninfo = Tokeninfo.refresh("Replace with refresh_token")
|
50
|
+
To try this out, update the version of `paypalrestsdk` in your `Gemfile` to `2.0.0.rc1`.
|
224
51
|
|
225
|
-
|
226
|
-
userinfo = tokeninfo.userinfo
|
52
|
+
Please feel free to create an issue in this repo with any feedback, questions, or concerns you have.
|
227
53
|
|
228
|
-
|
229
|
-
userinfo = Userinfo.get("Replace with access_token")
|
54
|
+
## Running tests
|
230
55
|
|
231
|
-
|
232
|
-
|
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
|
233
60
|
```
|
234
|
-
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/paypal/rest-api-sdk-ruby/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
235
|
-
|
236
|
-
|
237
|
-
## Payouts
|
238
61
|
|
239
|
-
|
62
|
+
*NOTE*: This API is still in beta, is subject to change, and should not be used in production.
|
240
63
|
|
241
|
-
|
242
|
-
@payout = Payout.new(
|
243
|
-
{
|
244
|
-
:sender_batch_header => {
|
245
|
-
:sender_batch_id => SecureRandom.hex(8),
|
246
|
-
:email_subject => 'You have a Payout!',
|
247
|
-
},
|
248
|
-
:items => [
|
249
|
-
{
|
250
|
-
:recipient_type => 'EMAIL',
|
251
|
-
:amount => {
|
252
|
-
:value => '1.0',
|
253
|
-
:currency => 'USD'
|
254
|
-
},
|
255
|
-
:note => 'Thanks for your patronage!',
|
256
|
-
:receiver => 'shirt-supplier-one@mail.com',
|
257
|
-
:sender_item_id => "2014031400023",
|
258
|
-
}
|
259
|
-
]
|
260
|
-
}
|
261
|
-
)
|
262
|
-
|
263
|
-
begin
|
264
|
-
@payout_batch = @payout.create
|
265
|
-
logger.info "Created Payout with [#{@payout_batch.batch_header.payout_batch_id}]"
|
266
|
-
rescue ResourceNotFound => err
|
267
|
-
logger.error @payout.error.inspect
|
268
|
-
end
|
269
|
-
```
|
64
|
+
## Feedback
|
270
65
|
|
271
|
-
|
272
|
-
[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.
|
273
67
|
|
274
68
|
## License
|
275
|
-
|
69
|
+
PayPal-Ruby-SDK is open source. See the [LICENSE](./LICENSE) file for more info.
|
276
70
|
|
277
|
-
## Contributions
|
278
|
-
|
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
|