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.
Files changed (235) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -14
  3. data/README.md +45 -251
  4. data/lib/lib.rb +88 -0
  5. data/lib/paypal/core/access_token.rb +20 -0
  6. data/lib/paypal/core/paypal_environment.rb +38 -0
  7. data/lib/paypal/core/paypal_http_client.rb +51 -0
  8. data/lib/paypal/core/token_requests.rb +40 -0
  9. data/lib/paypal/core/version.rb +3 -0
  10. data/lib/v1/billing_agreements/agreement_bill_balance_request.rb +35 -0
  11. data/lib/v1/billing_agreements/agreement_cancel_request.rb +35 -0
  12. data/lib/v1/billing_agreements/agreement_create_request.rb +33 -0
  13. data/lib/v1/billing_agreements/agreement_execute_request.rb +31 -0
  14. data/lib/v1/billing_agreements/agreement_get_request.rb +31 -0
  15. data/lib/v1/billing_agreements/agreement_re_activate_request.rb +35 -0
  16. data/lib/v1/billing_agreements/agreement_set_balance_request.rb +35 -0
  17. data/lib/v1/billing_agreements/agreement_suspend_request.rb +35 -0
  18. data/lib/v1/billing_agreements/agreement_transactions_request.rb +41 -0
  19. data/lib/v1/billing_agreements/agreement_update_request.rb +35 -0
  20. data/lib/v1/billing_plans/plan_create_request.rb +33 -0
  21. data/lib/v1/billing_plans/plan_get_request.rb +31 -0
  22. data/lib/v1/billing_plans/plan_list_request.rb +49 -0
  23. data/lib/v1/billing_plans/plan_update_request.rb +35 -0
  24. data/lib/v1/identity/user_consent.rb +45 -0
  25. data/lib/v1/identity/userinfo_get_request.rb +33 -0
  26. data/lib/v1/invoices/invoice_cancel_request.rb +35 -0
  27. data/lib/v1/invoices/invoice_create_request.rb +33 -0
  28. data/lib/v1/invoices/invoice_delete_external_payment_request.rb +33 -0
  29. data/lib/v1/invoices/invoice_delete_external_refund_request.rb +33 -0
  30. data/lib/v1/invoices/invoice_delete_request.rb +31 -0
  31. data/lib/v1/invoices/invoice_get_request.rb +31 -0
  32. data/lib/v1/invoices/invoice_list_request.rb +44 -0
  33. data/lib/v1/invoices/invoice_next_invoice_number_request.rb +29 -0
  34. data/lib/v1/invoices/invoice_qr_code_request.rb +46 -0
  35. data/lib/v1/invoices/invoice_record_payment_request.rb +35 -0
  36. data/lib/v1/invoices/invoice_record_refund_request.rb +35 -0
  37. data/lib/v1/invoices/invoice_remind_request.rb +35 -0
  38. data/lib/v1/invoices/invoice_search_request.rb +33 -0
  39. data/lib/v1/invoices/invoice_send_request.rb +36 -0
  40. data/lib/v1/invoices/invoice_update_request.rb +40 -0
  41. data/lib/v1/invoices/template_create_request.rb +33 -0
  42. data/lib/v1/invoices/template_delete_request.rb +31 -0
  43. data/lib/v1/invoices/template_get_request.rb +31 -0
  44. data/lib/v1/invoices/template_list_request.rb +34 -0
  45. data/lib/v1/invoices/template_update_request.rb +35 -0
  46. data/lib/v1/orders/orders_cancel_request.rb +31 -0
  47. data/lib/v1/orders/orders_create_request.rb +33 -0
  48. data/lib/v1/orders/orders_get_request.rb +31 -0
  49. data/lib/v1/orders/orders_pay_request.rb +35 -0
  50. data/lib/v1/payment_experience/web_profile_create_request.rb +33 -0
  51. data/lib/v1/payment_experience/web_profile_delete_request.rb +31 -0
  52. data/lib/v1/payment_experience/web_profile_get_request.rb +31 -0
  53. data/lib/v1/payment_experience/web_profile_list_request.rb +29 -0
  54. data/lib/v1/payment_experience/web_profile_partial_update_request.rb +35 -0
  55. data/lib/v1/payment_experience/web_profile_update_request.rb +35 -0
  56. data/lib/v1/payments/authorization_capture_request.rb +35 -0
  57. data/lib/v1/payments/authorization_get_request.rb +31 -0
  58. data/lib/v1/payments/authorization_reauthorize_request.rb +35 -0
  59. data/lib/v1/payments/authorization_void_request.rb +31 -0
  60. data/lib/v1/payments/capture_get_request.rb +31 -0
  61. data/lib/v1/payments/capture_refund_request.rb +35 -0
  62. data/lib/v1/payments/order_authorize_request.rb +35 -0
  63. data/lib/v1/payments/order_capture_request.rb +35 -0
  64. data/lib/v1/payments/order_get_request.rb +31 -0
  65. data/lib/v1/payments/order_void_request.rb +31 -0
  66. data/lib/v1/payments/payment_create_request.rb +33 -0
  67. data/lib/v1/payments/payment_execute_request.rb +35 -0
  68. data/lib/v1/payments/payment_get_request.rb +31 -0
  69. data/lib/v1/payments/payment_list_request.rb +69 -0
  70. data/lib/v1/payments/payment_update_request.rb +35 -0
  71. data/lib/v1/payments/refund_get_request.rb +31 -0
  72. data/lib/v1/payments/sale_get_request.rb +31 -0
  73. data/lib/v1/payments/sale_refund_request.rb +35 -0
  74. data/lib/v1/sync/search_get_request.rb +99 -0
  75. data/lib/v1/vault/credit_card_create_request.rb +33 -0
  76. data/lib/v1/vault/credit_card_delete_request.rb +31 -0
  77. data/lib/v1/vault/credit_card_get_request.rb +31 -0
  78. data/lib/v1/vault/credit_card_list_request.rb +79 -0
  79. data/lib/v1/vault/credit_card_update_request.rb +35 -0
  80. data/lib/v1/webhooks/available_event_type_list_request.rb +29 -0
  81. data/lib/v1/webhooks/event_get_request.rb +31 -0
  82. data/lib/v1/webhooks/event_list_request.rb +54 -0
  83. data/lib/v1/webhooks/event_resend_request.rb +35 -0
  84. data/lib/v1/webhooks/simulate_event_request.rb +33 -0
  85. data/lib/v1/webhooks/webhook_create_request.rb +33 -0
  86. data/lib/v1/webhooks/webhook_delete_request.rb +31 -0
  87. data/lib/v1/webhooks/webhook_get_request.rb +31 -0
  88. data/lib/v1/webhooks/webhook_list_event_subscriptions_request.rb +31 -0
  89. data/lib/v1/webhooks/webhook_list_request.rb +34 -0
  90. data/lib/v1/webhooks/webhook_update_request.rb +35 -0
  91. data/lib/v1/webhooks/webhook_verify_signature_request.rb +33 -0
  92. data/spec/integration/test_harness.rb +25 -0
  93. data/spec/integration/v1/billing_agreements/agreement_create_spec.rb +63 -0
  94. data/spec/integration/v1/billing_plans/plan_create_spec.rb +12 -0
  95. data/spec/integration/v1/billing_plans/plan_get_spec.rb +16 -0
  96. data/spec/integration/v1/billing_plans/plan_helper.rb +71 -0
  97. data/spec/integration/v1/billing_plans/plan_list_spec.rb +16 -0
  98. data/spec/integration/v1/billing_plans/plan_update_spec.rb +19 -0
  99. data/spec/integration/v1/identity/userinfo_get_spec.rb +65 -0
  100. data/spec/integration/v1/invoices/invoice_cancel_spec.rb +23 -0
  101. data/spec/integration/v1/invoices/invoice_create_spec.rb +15 -0
  102. data/spec/integration/v1/invoices/invoice_delete_external_payment_spec.rb +23 -0
  103. data/spec/integration/v1/invoices/invoice_delete_external_refund_spec.rb +21 -0
  104. data/spec/integration/v1/invoices/invoice_delete_spec.rb +16 -0
  105. data/spec/integration/v1/invoices/invoice_get_spec.rb +18 -0
  106. data/spec/integration/v1/invoices/invoice_helper.rb +171 -0
  107. data/spec/integration/v1/invoices/invoice_list_spec.rb +20 -0
  108. data/spec/integration/v1/invoices/invoice_next_invoice_number_spec.rb +14 -0
  109. data/spec/integration/v1/invoices/invoice_qr_code_spec.rb +18 -0
  110. data/spec/integration/v1/invoices/invoice_record_payment_spec.rb +14 -0
  111. data/spec/integration/v1/invoices/invoice_record_refund_spec.rb +14 -0
  112. data/spec/integration/v1/invoices/invoice_remind_spec.rb +22 -0
  113. data/spec/integration/v1/invoices/invoice_search_spec.rb +20 -0
  114. data/spec/integration/v1/invoices/invoice_send_spec.rb +15 -0
  115. data/spec/integration/v1/invoices/invoice_update_spec.rb +26 -0
  116. data/spec/integration/v1/invoices/template_create_spec.rb +14 -0
  117. data/spec/integration/v1/invoices/template_delete_spec.rb +15 -0
  118. data/spec/integration/v1/invoices/template_get_spec.rb +18 -0
  119. data/spec/integration/v1/invoices/template_list_spec.rb +15 -0
  120. data/spec/integration/v1/invoices/template_update_spec.rb +62 -0
  121. data/spec/integration/v1/orders/orders_cancel_spec.rb +15 -0
  122. data/spec/integration/v1/orders/orders_create_spec.rb +17 -0
  123. data/spec/integration/v1/orders/orders_get_spec.rb +18 -0
  124. data/spec/integration/v1/orders/orders_helper.rb +36 -0
  125. data/spec/integration/v1/orders/orders_pay_spec.rb +19 -0
  126. data/spec/integration/v1/payment_experience/pe_helper.rb +35 -0
  127. data/spec/integration/v1/payment_experience/web_profile_create_spec.rb +20 -0
  128. data/spec/integration/v1/payment_experience/web_profile_delete_spec.rb +15 -0
  129. data/spec/integration/v1/payment_experience/web_profile_get_spec.rb +17 -0
  130. data/spec/integration/v1/payment_experience/web_profile_list_spec.rb +18 -0
  131. data/spec/integration/v1/payment_experience/web_profile_partial_update_spec.rb +32 -0
  132. data/spec/integration/v1/payment_experience/web_profile_update_spec.rb +44 -0
  133. data/spec/integration/v1/payments/authorization_capture_spec.rb +17 -0
  134. data/spec/integration/v1/payments/authorization_get_spec.rb +18 -0
  135. data/spec/integration/v1/payments/authorization_reauthorize_spec.rb +26 -0
  136. data/spec/integration/v1/payments/authorization_void_spec.rb +19 -0
  137. data/spec/integration/v1/payments/capture_get_spec.rb +20 -0
  138. data/spec/integration/v1/payments/capture_refund_spec.rb +27 -0
  139. data/spec/integration/v1/payments/order_authorize_spec.rb +20 -0
  140. data/spec/integration/v1/payments/order_capture_spec.rb +21 -0
  141. data/spec/integration/v1/payments/order_get_spec.rb +14 -0
  142. data/spec/integration/v1/payments/order_void_spec.rb +14 -0
  143. data/spec/integration/v1/payments/payment_create_spec.rb +13 -0
  144. data/spec/integration/v1/payments/payment_execute_spec.rb +19 -0
  145. data/spec/integration/v1/payments/payment_get_spec.rb +17 -0
  146. data/spec/integration/v1/payments/payment_list_spec.rb +16 -0
  147. data/spec/integration/v1/payments/payment_update_spec.rb +28 -0
  148. data/spec/integration/v1/payments/payments_helper.rb +72 -0
  149. data/spec/integration/v1/payments/refund_get_spec.rb +19 -0
  150. data/spec/integration/v1/payments/sale_get_spec.rb +18 -0
  151. data/spec/integration/v1/payments/sale_refund_spec.rb +18 -0
  152. data/spec/integration/v1/sync/search_get_spec.rb +34 -0
  153. data/spec/integration/v1/vault/credit_card_create_spec.rb +16 -0
  154. data/spec/integration/v1/vault/credit_card_delete_spec.rb +16 -0
  155. data/spec/integration/v1/vault/credit_card_get_spec.rb +17 -0
  156. data/spec/integration/v1/vault/credit_card_list_spec.rb +18 -0
  157. data/spec/integration/v1/vault/credit_card_update_spec.rb +26 -0
  158. data/spec/integration/v1/vault/vault_helper.rb +28 -0
  159. data/spec/integration/v1/webhooks/available_event_type_list_spec.rb +16 -0
  160. data/spec/integration/v1/webhooks/webhook_create_spec.rb +12 -0
  161. data/spec/integration/v1/webhooks/webhook_delete_spec.rb +13 -0
  162. data/spec/integration/v1/webhooks/webhook_get_spec.rb +16 -0
  163. data/spec/integration/v1/webhooks/webhook_helper.rb +43 -0
  164. data/spec/integration/v1/webhooks/webhook_list_event_subscriptions_spec.rb +16 -0
  165. data/spec/integration/v1/webhooks/webhook_list_spec.rb +15 -0
  166. data/spec/integration/v1/webhooks/webhook_update_spec.rb +29 -0
  167. data/spec/integration/v1/webhooks/webhook_verify_signature_spec.rb +20 -0
  168. data/spec/spec_helper.rb +97 -28
  169. data/spec/unit/paypal_http_client_spec.rb +264 -0
  170. metadata +250 -120
  171. data/Rakefile +0 -15
  172. data/data/DigiCertHighAssuranceEVRootCA.pem +0 -23
  173. data/data/DigiCertSHA2ExtendedValidationServerCA.pem +0 -28
  174. data/data/paypal.crt +0 -171
  175. data/lib/generators/paypal/sdk/USAGE +0 -3
  176. data/lib/generators/paypal/sdk/install_generator.rb +0 -17
  177. data/lib/generators/paypal/sdk/templates/paypal.rb +0 -2
  178. data/lib/generators/paypal/sdk/templates/paypal.yml +0 -29
  179. data/lib/paypal-sdk-core.rb +0 -38
  180. data/lib/paypal-sdk-rest.rb +0 -2
  181. data/lib/paypal-sdk/core/api.rb +0 -20
  182. data/lib/paypal-sdk/core/api/base.rb +0 -169
  183. data/lib/paypal-sdk/core/api/data_types/array_with_block.rb +0 -44
  184. data/lib/paypal-sdk/core/api/data_types/base.rb +0 -225
  185. data/lib/paypal-sdk/core/api/data_types/enum.rb +0 -26
  186. data/lib/paypal-sdk/core/api/data_types/simple_types.rb +0 -52
  187. data/lib/paypal-sdk/core/api/ipn.rb +0 -66
  188. data/lib/paypal-sdk/core/api/rest.rb +0 -177
  189. data/lib/paypal-sdk/core/authentication.rb +0 -66
  190. data/lib/paypal-sdk/core/config.rb +0 -253
  191. data/lib/paypal-sdk/core/credential.rb +0 -16
  192. data/lib/paypal-sdk/core/credential/base.rb +0 -27
  193. data/lib/paypal-sdk/core/credential/certificate.rb +0 -32
  194. data/lib/paypal-sdk/core/credential/signature.rb +0 -22
  195. data/lib/paypal-sdk/core/credential/third_party/subject.rb +0 -25
  196. data/lib/paypal-sdk/core/credential/third_party/token.rb +0 -39
  197. data/lib/paypal-sdk/core/exceptions.rb +0 -112
  198. data/lib/paypal-sdk/core/logging.rb +0 -50
  199. data/lib/paypal-sdk/core/openid_connect.rb +0 -140
  200. data/lib/paypal-sdk/core/openid_connect/api.rb +0 -50
  201. data/lib/paypal-sdk/core/openid_connect/data_types.rb +0 -73
  202. data/lib/paypal-sdk/core/openid_connect/get_api.rb +0 -28
  203. data/lib/paypal-sdk/core/openid_connect/request_data_type.rb +0 -52
  204. data/lib/paypal-sdk/core/openid_connect/set_api.rb +0 -36
  205. data/lib/paypal-sdk/core/util.rb +0 -11
  206. data/lib/paypal-sdk/core/util/http_helper.rb +0 -171
  207. data/lib/paypal-sdk/core/util/oauth_signature.rb +0 -64
  208. data/lib/paypal-sdk/core/util/ordered_hash.rb +0 -165
  209. data/lib/paypal-sdk/rest.rb +0 -39
  210. data/lib/paypal-sdk/rest/api.rb +0 -23
  211. data/lib/paypal-sdk/rest/data_types.rb +0 -2597
  212. data/lib/paypal-sdk/rest/error_hash.rb +0 -39
  213. data/lib/paypal-sdk/rest/get_api.rb +0 -20
  214. data/lib/paypal-sdk/rest/request_data_type.rb +0 -53
  215. data/lib/paypal-sdk/rest/set_api.rb +0 -42
  216. data/lib/paypal-sdk/rest/version.rb +0 -7
  217. data/spec/README.md +0 -22
  218. data/spec/config/cacert.pem +0 -171
  219. data/spec/config/cert_key.pem +0 -33
  220. data/spec/config/paypal.yml +0 -35
  221. data/spec/config/sample_data.yml +0 -3
  222. data/spec/core/api/data_type_spec.rb +0 -289
  223. data/spec/core/api/rest_spec.rb +0 -211
  224. data/spec/core/config_spec.rb +0 -192
  225. data/spec/core/logging_spec.rb +0 -28
  226. data/spec/core/openid_connect_spec.rb +0 -153
  227. data/spec/invoice_examples_spec.rb +0 -38
  228. data/spec/payments_examples_spec.rb +0 -437
  229. data/spec/payouts_examples_spec.rb +0 -74
  230. data/spec/rest/data_types_spec.rb +0 -62
  231. data/spec/rest/error_hash_spec.rb +0 -83
  232. data/spec/subscription_examples_spec.rb +0 -227
  233. data/spec/support/sample_data.rb +0 -5
  234. data/spec/web_profile_examples_spec.rb +0 -106
  235. data/spec/webhooks_examples_spec.rb +0 -93
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9e80fb1f052a2fc5cbca599b00aec68263f24d8
4
- data.tar.gz: '046494835138859f2c9db9217e25781de5321028'
3
+ metadata.gz: 45787495ebb89e16774f4eec5eb3927a445e7f7a
4
+ data.tar.gz: 54d9b9db9a19ee483c1918894ca2d0ce34a3e0dc
5
5
  SHA512:
6
- metadata.gz: 34bcc8c9be7743b4bbf37a0d973cda853740e58996accea09be690e03902de30859d5a2b86a48f3c235951dc37b92da2c05b19b4b6e3d44d6b2f1981e5fd517d
7
- data.tar.gz: 5ee63c4d2ecdde4280916ab637a4a8d05d47da69ffc38faf91cc5d1734f00890c1a0e1dbf4cb64880a551ba45c8fa8a9f0bcd2bdf356ba194591225bb12765c3
6
+ metadata.gz: d82a1c5976df45733b87b2deb887db6f91d4fc390db57464c9c748b1874420051785e0c15e69083b9571e7bbf715472de8d9aeb93ed1d418df296afa80345262
7
+ data.tar.gz: 826180fe0c068f828a73d2cf5863631b1158c15cd5c0e9d5d875881781b6c12a54d5585aad1560a5176c8839a49b868c26b3cfefb1daa90026ccc9d32417fa96
data/Gemfile CHANGED
@@ -1,15 +1,5 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- gemspec
4
-
5
- #gem 'paypal-sdk-core', :git => "https://github.com/paypal/sdk-core-ruby.git"
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
- ## PayPal REST API Ruby SDK [![Build Status](https://travis-ci.org/paypal/PayPal-Ruby-SDK.svg?branch=master)](https://travis-ci.org/paypal/PayPal-Ruby-SDK) [![Coverage Status](https://coveralls.io/repos/github/paypal/PayPal-Ruby-SDK/badge.svg?branch=master)](https://coveralls.io/github/paypal/PayPal-Ruby-SDK?branch=master)
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
- The PayPal REST SDK provides Ruby APIs to create, process and manage payment.
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
- # Update client_id, client_secret and redirect_uri
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
- ```ruby
136
- require 'paypal-sdk-rest'
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
- # Build Payment object
145
- @payment = Payment.new({
146
- :intent => "sale",
147
- :payer => {
148
- :payment_method => "paypal" },
15
+ payment = {
16
+ :intent => "sale",
17
+ :transactions => [
18
+ :amount => {
19
+ :currency => "USD",
20
+ :amount => "10"
21
+ }
22
+ ],
149
23
  :redirect_urls => {
150
- :return_url => "http://localhost:3000/payment/execute",
151
- :cancel_url => "http://localhost:3000/" },
152
- :transactions => [{
153
- :item_list => {
154
- :items => [{
155
- :name => "item",
156
- :sku => "item",
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
- ```ruby
186
- payment = Payment.find("PAY-57363176S1057143SKE2HO3A")
33
+ request = PaymentCreateRequest.new
34
+ request.request_body(payment);
187
35
 
188
- if payment.execute( :payer_id => "DUFRQ8GWYMJXC" )
189
- # Success Message
190
- # Note that you'll need to `Payment.find` the payment again to access user info like shipping address
191
- else
192
- 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
193
43
  end
194
44
  ```
195
45
 
196
- ## Create Future Payment
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
- # Refresh tokeninfo object
220
- tokeninfo.refresh
48
+ ## Building
221
49
 
222
- # Create tokeninfo by using refresh token
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
- # Get Userinfo
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
- # Get Userinfo by using access token
229
- userinfo = Userinfo.get("Replace with access_token")
54
+ ## Running tests
230
55
 
231
- # Get logout url
232
- 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
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
- To make Payouts, you should enable this option in your account at http://developer.paypal.com.
62
+ *NOTE*: This API is still in beta, is subject to change, and should not be used in production.
240
63
 
241
- ```ruby
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
- ## Direct Credit Card Support
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
- Code released under [SDK LICENSE](LICENSE)
69
+ PayPal-Ruby-SDK is open source. See the [LICENSE](./LICENSE) file for more info.
276
70
 
277
- ## Contributions
278
- Pull requests and new issues are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
71
+ ## Contributions
72
+ Pull requests and new issues are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
@@ -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