paypal-checkout-sdk 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +139 -0
  3. data/Gemfile +3 -0
  4. data/Gemfile.lock +48 -0
  5. data/LICENSE +86 -0
  6. data/README.md +142 -0
  7. data/Rakefile +6 -0
  8. data/gen.yml +6 -0
  9. data/homepage.jpg +0 -0
  10. data/init +0 -0
  11. data/lib/core/version.rb +1 -1
  12. data/paypal-checkout-sdk.gemspec +26 -12
  13. data/samples/authorize_intent_examples/authorize_order.rb +52 -0
  14. data/samples/authorize_intent_examples/capture_order.rb +44 -0
  15. data/samples/authorize_intent_examples/create_order.rb +191 -0
  16. data/samples/authorize_intent_examples/run_all.rb +57 -0
  17. data/samples/capture_intent_examples/capture_order.rb +50 -0
  18. data/samples/capture_intent_examples/create_order.rb +138 -0
  19. data/samples/capture_intent_examples/run_all.rb +58 -0
  20. data/samples/get_order.rb +43 -0
  21. data/samples/patch_order.rb +53 -0
  22. data/samples/paypal_client.rb +40 -0
  23. data/samples/refund_capture.rb +46 -0
  24. metadata +82 -22
  25. data/spec/orders/orders_authorize_spec.rb +0 -18
  26. data/spec/orders/orders_capture_spec.rb +0 -18
  27. data/spec/orders/orders_create_spec.rb +0 -36
  28. data/spec/orders/orders_get_spec.rb +0 -37
  29. data/spec/orders/orders_helper.rb +0 -33
  30. data/spec/orders/orders_patch_spec.rb +0 -60
  31. data/spec/orders/orders_validate_spec.rb +0 -18
  32. data/spec/payments/authorizations_capture_spec.rb +0 -18
  33. data/spec/payments/authorizations_get_spec.rb +0 -18
  34. data/spec/payments/authorizations_reauthorize_spec.rb +0 -17
  35. data/spec/payments/authorizations_void_spec.rb +0 -17
  36. data/spec/payments/captures_get_spec.rb +0 -18
  37. data/spec/payments/captures_refund_spec.rb +0 -18
  38. data/spec/payments/refunds_get_spec.rb +0 -18
  39. data/spec/spec_helper.rb +0 -109
  40. data/spec/test_harness.rb +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: ee716ace7840674afcd0477b2ee4ffbde1c8b4629d7a9db46d71326e8689a1ae
4
- data.tar.gz: 327dfa22b4ab4835c58f94be87a4302c3fafff90bff56d4b66170f9e5ed7972a
2
+ SHA1:
3
+ metadata.gz: 38e281fa12bbbb378d86b9ae0d71a13d56e5a9f8
4
+ data.tar.gz: aa923060847b3cfec201bd8ee54c61e92839a660
5
5
  SHA512:
6
- metadata.gz: 27cced12caeb404bbc21f6dde4d11c578b86687e66a79643a7c710059e4aeaac1150bb5371eb09661910304f851e96b8453c34cab2c015f6e8ce7dbe5b38ae02
7
- data.tar.gz: de3ed48cbc4c40f98ffa1863f2e6a297abb6ee8ab619e650ea23e0c5ade4c5c4eff117af9b98496940c58b7a8d66d81f300235cbdb6d3c380473699708d43bba
6
+ metadata.gz: 951fa80875cc60e3d108356e87dba686e4f28082c99e90fb79511b34336f14602066046f3d8b2180cc4398fc3a384c18857cf0bae02eecda0d8f2437ff3b745d
7
+ data.tar.gz: 7efdcd17f89d40c7bd7906be72ff3769a74961f48ffb9a5804fd18a6e1f097cac8b83d61fe4f1e4c754a4d060ffa37557bc21d632f613cb2f6937ca94082220f
data/.gitignore ADDED
@@ -0,0 +1,139 @@
1
+
2
+ # Created by https://www.gitignore.io/api/ruby,rubymine+all
3
+
4
+ ### Ruby ###
5
+ *.gem
6
+ *.rbc
7
+ /.config
8
+ /coverage/
9
+ /InstalledFiles
10
+ /pkg/
11
+ /spec/reports/
12
+ /spec/examples.txt
13
+ /test/tmp/
14
+ /test/version_tmp/
15
+ /tmp/
16
+
17
+ # Used by dotenv library to load environment variables.
18
+ # .env
19
+
20
+ ## Specific to RubyMotion:
21
+ .dat*
22
+ .repl_history
23
+ build/
24
+ *.bridgesupport
25
+ build-iPhoneOS/
26
+ build-iPhoneSimulator/
27
+
28
+ ## Specific to RubyMotion (use of CocoaPods):
29
+ #
30
+ # We recommend against adding the Pods directory to your .gitignore. However
31
+ # you should judge for yourself, the pros and cons are mentioned at:
32
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
33
+ #
34
+ # vendor/Pods/
35
+
36
+ ## Documentation cache and generated files:
37
+ /.yardoc/
38
+ /_yardoc/
39
+ /doc/
40
+ /rdoc/
41
+
42
+ ## Environment normalization:
43
+ /.bundle/
44
+ /vendor/bundle
45
+ /lib/bundler/man/
46
+
47
+ # for a library or gem, you might want to ignore these files since the code is
48
+ # intended to run in multiple environments; otherwise, check them in:
49
+ # Gemfile.lock
50
+ # .ruby-version
51
+ # .ruby-gemset
52
+
53
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
54
+ .rvmrc
55
+
56
+ ### RubyMine+all ###
57
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
58
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
59
+
60
+ # User-specific stuff
61
+ .idea/**/workspace.xml
62
+ .idea/**/tasks.xml
63
+ .idea/**/usage.statistics.xml
64
+ .idea/**/dictionaries
65
+ .idea/**/shelf
66
+
67
+ # Sensitive or high-churn files
68
+ .idea/**/dataSources/
69
+ .idea/**/dataSources.ids
70
+ .idea/**/dataSources.local.xml
71
+ .idea/**/sqlDataSources.xml
72
+ .idea/**/dynamic.xml
73
+ .idea/**/uiDesigner.xml
74
+ .idea/**/dbnavigator.xml
75
+
76
+ # Gradle
77
+ .idea/**/gradle.xml
78
+ .idea/**/libraries
79
+
80
+ # Gradle and Maven with auto-import
81
+ # When using Gradle or Maven with auto-import, you should exclude module files,
82
+ # since they will be recreated, and may cause churn. Uncomment if using
83
+ # auto-import.
84
+ # .idea/modules.xml
85
+ # .idea/*.iml
86
+ # .idea/modules
87
+
88
+ # CMake
89
+ cmake-build-*/
90
+
91
+ # Mongo Explorer plugin
92
+ .idea/**/mongoSettings.xml
93
+
94
+ # File-based project format
95
+ *.iws
96
+
97
+ # IntelliJ
98
+ out/
99
+
100
+ #Visual Studio Code Files
101
+ .vscode/
102
+
103
+ #Eclipse Files
104
+ .project
105
+
106
+ # mpeltonen/sbt-idea plugin
107
+ .idea_modules/
108
+
109
+ # JIRA plugin
110
+ atlassian-ide-plugin.xml
111
+
112
+ # Cursive Clojure plugin
113
+ .idea/replstate.xml
114
+
115
+ # Crashlytics plugin (for Android Studio and IntelliJ)
116
+ com_crashlytics_export_strings.xml
117
+ crashlytics.properties
118
+ crashlytics-build.properties
119
+ fabric.properties
120
+
121
+ # Editor-based Rest Client
122
+ .idea/httpRequests
123
+
124
+ ### RubyMine+all Patch ###
125
+ # Ignores the whole .idea folder and all .iml files
126
+ # See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
127
+
128
+ .idea/
129
+
130
+ # Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
131
+
132
+ *.iml
133
+ modules.xml
134
+ .idea/misc.xml
135
+ *.ipr
136
+
137
+
138
+ # End of https://www.gitignore.io/api/ruby,rubymine+all
139
+
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,48 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ paypal-checkout-sdk (1.0.2)
5
+ braintreehttp (~> 0.5)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.5.2)
11
+ public_suffix (>= 2.0.2, < 4.0)
12
+ braintreehttp (0.5.0)
13
+ crack (0.4.3)
14
+ safe_yaml (~> 1.0.0)
15
+ diff-lcs (1.3)
16
+ hashdiff (0.3.7)
17
+ public_suffix (3.0.3)
18
+ rake (10.5.0)
19
+ rspec (3.8.0)
20
+ rspec-core (~> 3.8.0)
21
+ rspec-expectations (~> 3.8.0)
22
+ rspec-mocks (~> 3.8.0)
23
+ rspec-core (3.8.0)
24
+ rspec-support (~> 3.8.0)
25
+ rspec-expectations (3.8.1)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.8.0)
28
+ rspec-mocks (3.8.0)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.8.0)
31
+ rspec-support (3.8.0)
32
+ safe_yaml (1.0.4)
33
+ webmock (3.4.2)
34
+ addressable (>= 2.3.6)
35
+ crack (>= 0.3.2)
36
+ hashdiff
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ paypal-checkout-sdk!
43
+ rake (~> 10.0)
44
+ rspec (~> 3.0)
45
+ webmock
46
+
47
+ BUNDLED WITH
48
+ 1.17.3
data/LICENSE ADDED
@@ -0,0 +1,86 @@
1
+ The PayPal Node SDK is released under the following license:
2
+
3
+ Copyright (c) 2013-2019 PAYPAL, INC.
4
+
5
+ SDK LICENSE
6
+
7
+ NOTICE TO USER: PayPal, Inc. is providing the Software and Documentation for use under the terms of
8
+ this Agreement. Any use, reproduction, modification or distribution of the Software or Documentation,
9
+ or any derivatives or portions hereof, constitutes your acceptance of this Agreement.
10
+
11
+ As used in this Agreement, "PayPal" means PayPal, Inc. "Software" means the software code accompanying
12
+ this agreement. "Documentation" means the documents, specifications and all other items accompanying
13
+ this Agreement other than the Software.
14
+
15
+ 1. LICENSE GRANT Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive,
16
+ worldwide, royalty free license to use, reproduce, prepare derivative works from, publicly display,
17
+ publicly perform, distribute and sublicense the Software for any purpose, provided the copyright notice
18
+ below appears in a conspicuous location within the source code of the distributed Software and this
19
+ license is distributed in the supporting documentation of the Software you distribute. Furthermore,
20
+ you must comply with all third party licenses in order to use the third party software contained in the
21
+ Software.
22
+
23
+ Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive, worldwide, royalty free
24
+ license to use, reproduce, publicly display, publicly perform, distribute and sublicense the Documentation
25
+ for any purpose. You may not modify the Documentation.
26
+
27
+ No title to the intellectual property in the Software or Documentation is transferred to you under the
28
+ terms of this Agreement. You do not acquire any rights to the Software or the Documentation except as
29
+ expressly set forth in this Agreement.
30
+
31
+ If you choose to distribute the Software in a commercial product, you do so with the understanding that
32
+ you agree to defend, indemnify and hold harmless PayPal and its suppliers against any losses, damages and
33
+ costs arising from the claims, lawsuits or other legal actions arising out of such distribution. You may
34
+ distribute the Software in object code form under your own license, provided that your license agreement:
35
+
36
+ (a) complies with the terms and conditions of this license agreement;
37
+
38
+ (b) effectively disclaims all warranties and conditions, express or implied, on behalf of PayPal;
39
+
40
+ (c) effectively excludes all liability for damages on behalf of PayPal;
41
+
42
+ (d) states that any provisions that differ from this Agreement are offered by you alone and not PayPal; and
43
+
44
+ (e) states that the Software is available from you or PayPal and informs licensees how to obtain it in a
45
+ reasonable manner on or through a medium customarily used for software exchange.
46
+
47
+ 2. DISCLAIMER OF WARRANTY
48
+ PAYPAL LICENSES THE SOFTWARE AND DOCUMENTATION TO YOU ONLY ON AN "AS IS" BASIS WITHOUT WARRANTIES OR CONDITIONS
49
+ OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY WARRANTIES OR CONDITIONS OF TITLE,
50
+ NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. PAYPAL MAKES NO WARRANTY THAT THE
51
+ SOFTWARE OR DOCUMENTATION WILL BE ERROR-FREE. Each user of the Software or Documentation is solely responsible
52
+ for determining the appropriateness of using and distributing the Software and Documentation and assumes all
53
+ risks associated with its exercise of rights under this Agreement, including but not limited to the risks and
54
+ costs of program errors, compliance with applicable laws, damage to or loss of data, programs, or equipment,
55
+ and unavailability or interruption of operations. Use of the Software and Documentation is made with the
56
+ understanding that PayPal will not provide you with any technical or customer support or maintenance. Some
57
+ states or jurisdictions do not allow the exclusion of implied warranties or limitations on how long an implied
58
+ warranty may last, so the above limitations may not apply to you. To the extent permissible, any implied
59
+ warranties are limited to ninety (90) days.
60
+
61
+
62
+ 3. LIMITATION OF LIABILITY
63
+ PAYPAL AND ITS SUPPLIERS SHALL NOT BE LIABLE FOR LOSS OR DAMAGE ARISING OUT OF THIS AGREEMENT OR FROM THE USE
64
+ OF THE SOFTWARE OR DOCUMENTATION. IN NO EVENT WILL PAYPAL OR ITS SUPPLIERS BE LIABLE TO YOU OR ANY THIRD PARTY
65
+ FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, INCIDENTAL, OR SPECIAL DAMAGES INCLUDING LOST PROFITS, LOST SAVINGS,
66
+ COSTS, FEES, OR EXPENSES OF ANY KIND ARISING OUT OF ANY PROVISION OF THIS AGREEMENT OR THE USE OR THE INABILITY
67
+ TO USE THE SOFTWARE OR DOCUMENTATION, HOWEVER CAUSED AND UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
68
+ STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
69
+ PAYPAL'S AGGREGATE LIABILITY AND THAT OF ITS SUPPLIERS UNDER OR IN CONNECTION WITH THIS AGREEMENT SHALL BE
70
+ LIMITED TO THE AMOUNT PAID BY YOU FOR THE SOFTWARE AND DOCUMENTATION.
71
+
72
+ 4. TRADEMARK USAGE
73
+ PayPal is a trademark PayPal, Inc. in the United States and other countries. Such trademarks may not be used
74
+ to endorse or promote any product unless expressly permitted under separate agreement with PayPal.
75
+
76
+ 5. TERM
77
+ Your rights under this Agreement shall terminate if you fail to comply with any of the material terms or
78
+ conditions of this Agreement and do not cure such failure in a reasonable period of time after becoming
79
+ aware of such noncompliance. If all your rights under this Agreement terminate, you agree to cease use
80
+ and distribution of the Software and Documentation as soon as reasonably practicable.
81
+
82
+ 6. GOVERNING LAW AND JURISDICTION. This Agreement is governed by the statutes and laws of the State of
83
+ California, without regard to the conflicts of law principles thereof. If any part of this Agreement is
84
+ found void and unenforceable, it will not affect the validity of the balance of the Agreement, which shall
85
+ remain valid and enforceable according to its terms. Any dispute arising out of or related to this Agreement
86
+ shall be brought in the courts of Santa Clara County, California, USA.
data/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # REST API SDK for Ruby V2
2
+
3
+ ![Home Image](homepage.jpg)
4
+
5
+ __Welcome to PayPal Ruby SDK__. This repository contains PayPal's Ruby SDK and samples for [v2/checkout/orders](https://developer.paypal.com/docs/api/orders/v2/) and [v2/payments](https://developer.paypal.com/docs/api/payments/v2/) APIs.
6
+
7
+ This is a part of the next major PayPal SDK. It includes a simplified interface to only provide simple model objects and blueprints for HTTP calls. This repo currently contains functionality for PayPal Checkout APIs which includes [Orders V2](https://developer.paypal.com/docs/api/orders/v2/) and [Payments V2](https://developer.paypal.com/docs/api/payments/v2/).
8
+
9
+ Please refer to the [PayPal Checkout Integration Guide](https://developer.paypal.com/docs/checkout/) for more information. Also refer to [Setup your SDK](https://developer.paypal.com/docs/checkout/reference/server-integration/setup-sdk/) for additional information about setting up the SDK's.
10
+
11
+
12
+ ## Prerequisites
13
+
14
+ - Ruby 2.0.0 or above
15
+ - Bundler
16
+
17
+ ## Usage
18
+ ### Binaries
19
+
20
+ It is not mandatory to fork this repository for using the PayPal SDK. You can refer [PayPal Checkout Server SDK](https://developer.paypal.com/docs/checkout/reference/server-integration) for configuring and working with SDK without forking this code.
21
+
22
+ For contirbuting or referrring the samples, You can fork/refer this repository.
23
+
24
+ ### Setting up credentials
25
+ Get client ID and client secret by going to https://developer.paypal.com/developer/applications and generating a REST API app. Get <b>Client ID</b> and <b>Secret</b> from there.
26
+
27
+ ```ruby
28
+ require 'paypal-checkout-sdk'
29
+
30
+
31
+ # Creating Access Token for Sandbox
32
+ client_id = "PAYPAL-CLIENT-ID"
33
+ client_secret = "PAYPAL-CLIENT-SECRET"
34
+ # Creating an environment
35
+ environment = PayPal::SandboxEnvironment.new(client_id, client_secret)
36
+ client = PayPal::PayPalHttpClient.new(environment)
37
+ ```
38
+
39
+ ## Examples
40
+
41
+ ### Creating an Order
42
+
43
+ #### Code:
44
+ ```ruby
45
+
46
+ # Construct a request object and set desired parameters
47
+ # Here, OrdersCreateRequest::new creates a POST request to /v2/checkout/orders
48
+ request = PayPalCheckoutSdk::Orders::OrdersCreateRequest::new
49
+ request.request_body({
50
+ intent: "CAPTURE",
51
+ purchase_units: [
52
+ {
53
+ amount: {
54
+ currency_code: "USD",
55
+ value: "100.00"
56
+ }
57
+ }
58
+ ]
59
+ })
60
+
61
+ begin
62
+ # Call API with your client and get a response for your call
63
+ response = client.execute(request)
64
+
65
+ # If call returns body in response, you can get the deserialized version from the result attribute of the response
66
+ order = response.result
67
+ puts order
68
+ rescue BraintreeHttp::HttpError => ioe
69
+ # Something went wrong server-side
70
+ puts ioe.status_code
71
+ puts ioe.headers["debug_id"]
72
+ end
73
+ ```
74
+
75
+ #### Example Output:
76
+ ```
77
+ Status Code: 201
78
+ Status: CREATED
79
+ Order ID: 7F845507FB875171H
80
+ Intent: CAPTURE
81
+ Links:
82
+ self: https://api.sandbox.paypal.com/v2/checkout/orders/7F845507FB875171H Call Type: GET
83
+ approve: https://www.sandbox.paypal.com/checkoutnow?token=7F845507FB875171H Call Type: GET
84
+ authorize: https://api.sandbox.paypal.com/v2/checkout/orders/7F845507FB875171H/authorize Call Type: POST
85
+ Gross Amount: USD 230.00
86
+ ```
87
+
88
+ ### Capturing an Order
89
+ After approving order above using `approve` link
90
+
91
+ #### Code:
92
+ ```ruby
93
+ # Here, OrdersCaptureRequest::new() creates a POST request to /v2/checkout/orders
94
+ # order.id gives the orderId of the order created above
95
+ request = PayPalCheckoutSdk::Orders::OrdersCaptureRequest::new("APPROVED-ORDER-ID")
96
+
97
+ begin
98
+ # Call API with your client and get a response for your call
99
+ response = client.execute(request)
100
+
101
+ # If call returns body in response, you can get the deserialized version from the result attribute of the response
102
+ order = response.result
103
+ puts order
104
+ rescue BraintreeHttp::HttpError => ioe
105
+ # Something went wrong server-side
106
+ puts ioe.status_code
107
+ puts ioe.headers["debug_id"]
108
+ end
109
+ ```
110
+
111
+ #### Example Output:
112
+ ```
113
+ Status Code: 201
114
+ Status: COMPLETED
115
+ Order ID: 7F845507FB875171H
116
+ Links:
117
+ self: https://api.sandbox.paypal.com/v2/checkout/orders/70779998U8897342J Call Type: GET
118
+ Buyer:
119
+ Email Address: ganeshramc-buyer@live.com
120
+ Name: test buyer
121
+ Phone Number: 408-411-2134
122
+ ```
123
+
124
+ ## Running tests
125
+
126
+ To run integration tests using your client id and secret, clone this repository and run the following command:
127
+ ```sh
128
+ $ bundle install
129
+ $ PAYPAL_CLIENT_ID=YOUR_SANDBOX_CLIENT_ID PAYPAL_CLIENT_SECRET=YOUR_SANDBOX_CLIENT_SECRET rspec spec
130
+ ```
131
+
132
+ ## Samples
133
+
134
+ You can start off by trying out [creating and capturing an order](/samples/capture_intent_examples/run_all.rb)
135
+
136
+ To try out different samples for both create and authorize intent check [this link](/samples)
137
+
138
+ Note: Update the `paypal_client.rb` with your sandbox client credentials or pass your client credentials as environment variable whie executing the samples.
139
+
140
+
141
+ ## License
142
+ Code released under [SDK LICENSE](LICENSE)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/gen.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ projectName: PayPalCheckoutSdk
3
+ language: ruby
4
+ sourcePath: lib
5
+ testPath: spec
6
+ apiVersioning: false