paypal-checkout-sdk 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,18 +0,0 @@
1
-
2
-
3
- require_relative '../test_harness'
4
- require_relative '../../lib/lib'
5
- require 'json'
6
-
7
- include PayPalCheckoutSdk::Orders
8
-
9
- describe OrdersAuthorizeRequest do
10
-
11
- it 'successfully makes a request', :skip => 'This test is an example, in production, orders require payer approval' do
12
- request = OrdersAuthorizeRequest.new("ORDER-ID")
13
-
14
- resp = TestHarness::client.execute(request)
15
- expect(resp.status_code).to eq(201)
16
- expect(resp.result).not_to be_nil
17
- end
18
- end
@@ -1,18 +0,0 @@
1
-
2
-
3
- require_relative '../test_harness'
4
- require_relative '../../lib/lib'
5
- require 'json'
6
-
7
- include PayPalCheckoutSdk::Orders
8
-
9
- describe OrdersCaptureRequest do
10
-
11
- it 'successfully makes a request' , :skip => 'This test is an example, in production, orders require payer approval' do
12
- request = OrdersCaptureRequest.new("ORDER-ID")
13
-
14
- resp = TestHarness::client.execute(request)
15
- expect(resp.status_code).to eq(201)
16
- expect(resp.result).not_to be_nil
17
- end
18
- end
@@ -1,36 +0,0 @@
1
-
2
-
3
- require_relative '../test_harness'
4
- require_relative './orders_helper'
5
- require 'json'
6
-
7
- include PayPalCheckoutSdk::Orders
8
-
9
- describe OrdersCreateRequest do
10
- it 'successfully makes a request' do
11
-
12
- resp = OrdersHelper::create_order
13
- expect(resp.status_code).to eq(201)
14
- expect(resp.result).not_to be_nil
15
- expect(resp.result.intent).to eq('CAPTURE')
16
- expect(resp.result.purchase_units.count).to eq(1)
17
- expect(resp.result.purchase_units[0].reference_id).to eq('test_ref_id1')
18
- expect(resp.result.purchase_units[0].amount.currency_code).to eq('USD')
19
- expect(resp.result.purchase_units[0].amount.value).to eq('100.00')
20
-
21
- expect(resp.result.create_time).not_to be_nil
22
- expect(resp.result.links).not_to be_nil
23
- found_approve = false
24
-
25
- for link in resp.result.links
26
- if "approve" === link.rel
27
- expect(link["href"]).not_to be_nil
28
- expect(link["method"]).to eq("GET")
29
- found_approve = true
30
- end
31
- end
32
-
33
- expect(found_approve).to be_truthy
34
- expect(resp.result.status).to eq('CREATED')
35
- end
36
- end
@@ -1,37 +0,0 @@
1
-
2
-
3
- require_relative '../test_harness'
4
- require_relative './orders_helper'
5
- require 'json'
6
-
7
- include PayPalCheckoutSdk::Orders
8
-
9
- describe OrdersGetRequest do
10
-
11
- it 'successfully makes a request' do
12
- create_resp = OrdersHelper::create_order
13
- request = OrdersGetRequest.new(create_resp.result.id)
14
- resp = TestHarness::client.execute(request)
15
- expect(resp.status_code).to eq(200)
16
- expect(resp.result).not_to be_nil
17
- expect(resp.result.intent).to eq('CAPTURE')
18
- expect(resp.result.purchase_units.count).to eq(1)
19
- expect(resp.result.purchase_units[0].reference_id).to eq('test_ref_id1')
20
- expect(resp.result.purchase_units[0].amount.currency_code).to eq('USD')
21
- expect(resp.result.purchase_units[0].amount.value).to eq('100.00')
22
-
23
- expect(resp.result.create_time).not_to be_nil
24
- expect(resp.result.links).not_to be_nil
25
- found_approve = false
26
-
27
- for link in resp.result.links
28
- if "approve" === link.rel
29
- expect(link["href"]).not_to be_nil
30
- expect(link["method"]).to eq("GET")
31
- found_approve = true
32
- end
33
- end
34
- expect(found_approve).to be_truthy
35
- expect(resp.result.status).to eq('CREATED')
36
- end
37
- end
@@ -1,33 +0,0 @@
1
- require_relative '../test_harness'
2
-
3
- include PayPalCheckoutSdk::Orders
4
-
5
- module OrdersHelper
6
- class << self
7
- def create_order
8
- body = {
9
- intent: 'CAPTURE',
10
- purchase_units: [{
11
- reference_id: 'test_ref_id1',
12
- amount: {
13
- value: '100.00',
14
- currency_code: 'USD'
15
- }
16
- }],
17
- redirect_urls: {
18
- cancel_url: 'https://example.com/cancel',
19
- return_url: 'https://example.com/return'
20
- }
21
- }
22
- request = OrdersCreateRequest.new()
23
- request.prefer("return=representation")
24
- request.request_body(body)
25
-
26
- return TestHarness::client.execute(request)
27
- end
28
-
29
- def get_order(id)
30
- return TestHarness::exec(OrdersGetRequest.new(id))
31
- end
32
- end
33
- end
@@ -1,60 +0,0 @@
1
-
2
-
3
- require_relative '../test_harness'
4
- require_relative './orders_helper'
5
- require 'json'
6
-
7
- include PayPalCheckoutSdk::Orders
8
-
9
- describe OrdersPatchRequest do
10
- def build_request_body
11
- return [
12
- {
13
- "op": "add",
14
- "path": "/purchase_units/@reference_id=='test_ref_id1'/description",
15
- "value": "added_description"
16
- },
17
- {
18
- "op": "replace",
19
- "path": "/purchase_units/@reference_id=='test_ref_id1'/amount",
20
- "value": {
21
- "currency_code": "USD",
22
- "value": "200.00"
23
- }
24
-
25
- }
26
- ]
27
- end
28
-
29
- it 'successfully makes a request' do
30
- create_resp = OrdersHelper::create_order
31
- request = OrdersPatchRequest.new(create_resp.result.id)
32
- request.request_body(build_request_body)
33
-
34
- resp = TestHarness::client.execute(request)
35
- expect(resp.status_code).to eq(204)
36
- resp = OrdersHelper::get_order create_resp.result.id
37
- expect(resp.status_code).to eq(200)
38
- expect(resp.result).not_to be_nil
39
- expect(resp.result.intent).to eq('CAPTURE')
40
- expect(resp.result.purchase_units.count).to eq(1)
41
- expect(resp.result.purchase_units[0].reference_id).to eq('test_ref_id1')
42
- expect(resp.result.purchase_units[0].amount.currency_code).to eq('USD')
43
- expect(resp.result.purchase_units[0].amount.value).to eq('200.00')
44
- expect(resp.result.purchase_units[0].description).to eq('added_description')
45
-
46
- expect(resp.result.create_time).not_to be_nil
47
- expect(resp.result.links).not_to be_nil
48
- found_approve = false
49
-
50
- for link in resp.result.links
51
- if "approve" === link.rel
52
- expect(link["href"]).not_to be_nil
53
- expect(link["method"]).to eq("GET")
54
- found_approve = true
55
- end
56
- end
57
- expect(found_approve).to be_truthy
58
- expect(resp.result.status).to eq('CREATED')
59
- end
60
- end
@@ -1,18 +0,0 @@
1
-
2
-
3
- require_relative '../test_harness'
4
- require_relative '../../lib/lib'
5
- require 'json'
6
-
7
- include PayPalCheckoutSdk::Orders
8
-
9
- describe OrdersValidateRequest do
10
-
11
- it 'successfully makes a request' , :skip => 'This test is an example, in production, orders require payer approval' do
12
- request = OrdersValidateRequest.new("ORDER-ID")
13
-
14
- resp = TestHarness::client.execute(request)
15
- expect(resp.status_code).to eq(200)
16
- expect(resp.result).not_to be_nil
17
- end
18
- end
@@ -1,18 +0,0 @@
1
-
2
-
3
- require_relative '../test_harness'
4
- require_relative '../../lib/lib'
5
- require 'json'
6
-
7
- include PayPalCheckoutSdk::Payments
8
-
9
- describe AuthorizationsCaptureRequest do
10
-
11
- it 'successfully makes a request', :skip => 'This test is an example, in production, orders require payer approval' do
12
- request = AuthorizationsCaptureRequest.new("AUTHORIZATION-ID")
13
-
14
- resp = TestHarness::client.execute(request)
15
- expect(resp.status_code).to eq(201)
16
- expect(resp.result).not_to be_nil
17
- end
18
- end
@@ -1,18 +0,0 @@
1
-
2
-
3
- require_relative '../test_harness'
4
- require_relative '../../lib/lib'
5
- require 'json'
6
-
7
- include PayPalCheckoutSdk::Payments
8
-
9
- describe AuthorizationsGetRequest do
10
-
11
- it 'successfully makes a request', :skip => 'This test is an example, in production, orders require payer approval' do
12
- request = AuthorizationsGetRequest.new("AUTHORIZATION-ID")
13
-
14
- resp = TestHarness::client.execute(request)
15
- expect(resp.status_code).to eq(200)
16
- expect(resp.result).not_to be_nil
17
- end
18
- end
@@ -1,17 +0,0 @@
1
-
2
-
3
- require_relative '../test_harness'
4
- require_relative '../../lib/lib'
5
- require 'json'
6
-
7
- include PayPalCheckoutSdk::Payments
8
-
9
- describe AuthorizationsReauthorizeRequest do
10
- it 'successfully makes a request', :skip => 'This test is an example, in production, orders require payer approval' do
11
- request = AuthorizationsReauthorizeRequest.new("xtIHGdKgdA25uQzr")
12
-
13
- resp = TestHarness::client.execute(request)
14
- expect(resp.status_code).to eq(201)
15
- expect(resp.result).not_to be_nil
16
- end
17
- end
@@ -1,17 +0,0 @@
1
-
2
-
3
- require_relative '../test_harness'
4
- require_relative '../../lib/lib'
5
- require 'json'
6
-
7
- include PayPalCheckoutSdk::Payments
8
-
9
- describe AuthorizationsVoidRequest do
10
-
11
- it 'successfully makes a request', :skip => 'This test is an example, in production, orders require payer approval' do
12
- request = AuthorizationsVoidRequest.new("AUTHORIZATION-ID")
13
-
14
- resp = TestHarness::client.execute(request)
15
- expect(resp.status_code).to eq(204)
16
- end
17
- end
@@ -1,18 +0,0 @@
1
-
2
-
3
- require_relative '../test_harness'
4
- require_relative '../../lib/lib'
5
- require 'json'
6
-
7
- include PayPalCheckoutSdk::Payments
8
-
9
- describe CapturesGetRequest do
10
-
11
- it 'successfully makes a request', :skip => 'This test is an example, in production, orders require payer approval' do
12
- request = CapturesGetRequest.new("CAPTURE-ID")
13
-
14
- resp = TestHarness::client.execute(request)
15
- expect(resp.status_code).to eq(200)
16
- expect(resp.result).not_to be_nil
17
- end
18
- end
@@ -1,18 +0,0 @@
1
-
2
-
3
- require_relative '../test_harness'
4
- require_relative '../../lib/lib'
5
- require 'json'
6
-
7
- include PayPalCheckoutSdk::Payments
8
-
9
- describe CapturesRefundRequest do
10
-
11
- it 'successfully makes a request', :skip => 'This test is an example, in production, orders require payer approval' do
12
- request = CapturesRefundRequest.new("CAPTURE-ID")
13
-
14
- resp = TestHarness::client.execute(request)
15
- expect(resp.status_code).to eq(201)
16
- expect(resp.result).not_to be_nil
17
- end
18
- end
@@ -1,18 +0,0 @@
1
-
2
-
3
- require_relative '../test_harness'
4
- require_relative '../../lib/lib'
5
- require 'json'
6
-
7
- include PayPalCheckoutSdk::Payments
8
-
9
- describe RefundsGetRequest do
10
-
11
- it 'successfully makes a request', :skip => 'This test is an example, in production, orders require payer approval' do
12
- request = RefundsGetRequest.new("REFUND-ID")
13
-
14
- resp = TestHarness::client.execute(request)
15
- expect(resp.status_code).to eq(200)
16
- expect(resp.result).not_to be_nil
17
- end
18
- end
data/spec/spec_helper.rb DELETED
@@ -1,109 +0,0 @@
1
- require_relative "../lib/lib.rb"
2
- require 'pp'
3
- require 'webmock/rspec'
4
-
5
- # This file was generated by the `rspec --init` command. Conventionally, all
6
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
7
- # The generated `.rspec` file contains `--require spec_helper` which will cause
8
- # this file to always be loaded, without a need to explicitly require it in any
9
- # files.
10
- #
11
- # Given that it is always loaded, you are encouraged to keep this file as
12
- # light-weight as possible. Requiring heavyweight dependencies from this file
13
- # will add to the boot time of your test suite on EVERY test run, even for an
14
- # individual file that may not need all of that loaded. Instead, consider making
15
- # a separate helper file that requires the additional dependencies and performs
16
- # the additional setup, and require it from the spec files that actually need
17
- # it.
18
- #
19
- # The `.rspec` file also contains a few flags that are not defaults but that
20
- # users commonly want.
21
- #
22
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
23
- RSpec.configure do |config|
24
- # rspec-expectations config goes here. You can use an alternate
25
- # assertion/expectation library such as wrong or the stdlib/minitest
26
- # assertions if you prefer.
27
- config.expect_with :rspec do |expectations|
28
- # This option will default to `true` in RSpec 4. It makes the `description`
29
- # and `failure_message` of custom matchers include text for helper methods
30
- # defined using `chain`, e.g.:
31
- # be_bigger_than(2).and_smaller_than(4).description
32
- # # => "be bigger than 2 and smaller than 4"
33
- # ...rather than:
34
- # # => "be bigger than 2"
35
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
36
- end
37
-
38
- # rspec-mocks config goes here. You can use an alternate test double
39
- # library (such as bogus or mocha) by changing the `mock_with` option here.
40
- config.mock_with :rspec do |mocks|
41
- # Prevents you from mocking or stubbing a method that does not exist on
42
- # a real object. This is generally recommended, and will default to
43
- # `true` in RSpec 4.
44
- mocks.verify_partial_doubles = true
45
- end
46
-
47
- # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
48
- # have no way to turn it off -- the option exists only for backwards
49
- # compatibility in RSpec 3). It causes shared context metadata to be
50
- # inherited by the metadata hash of host groups and examples, rather than
51
- # triggering implicit auto-inclusion in groups with matching metadata.
52
- config.shared_context_metadata_behavior = :apply_to_host_groups
53
-
54
- # The settings below are suggested to provide a good initial experience
55
- # with RSpec, but feel free to customize to your heart's content.
56
- =begin
57
- # This allows you to limit a spec run to individual examples or groups
58
- # you care about by tagging them with `:focus` metadata. When nothing
59
- # is tagged with `:focus`, all examples get run. RSpec also provides
60
- # aliases for `it`, `describe`, and `context` that include `:focus`
61
- # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
62
- config.filter_run_when_matching :focus
63
-
64
- # Allows RSpec to persist some state between runs in order to support
65
- # the `--only-failures` and `--next-failure` CLI options. We recommend
66
- # you configure your source control system to ignore this file.
67
- config.example_status_persistence_file_path = "spec/examples.txt"
68
-
69
- # Limits the available syntax to the non-monkey patched syntax that is
70
- # recommended. For more details, see:
71
- # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
72
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
73
- # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
74
- config.disable_monkey_patching!
75
-
76
- # This setting enables warnings. It's recommended, but in some cases may
77
- # be too noisy due to issues in dependencies.
78
- config.warnings = true
79
-
80
- # Many RSpec users commonly either run the entire suite or an individual
81
- # file, and it's useful to allow more verbose output when running an
82
- # individual spec file.
83
- if config.files_to_run.one?
84
- # Use the documentation formatter for detailed output,
85
- # unless a formatter has already been configured
86
- # (e.g. via a command-line flag).
87
- config.default_formatter = 'doc'
88
- end
89
-
90
- # Print the 10 slowest examples and example groups at the
91
- # end of the spec run, to help surface which specs are running
92
- # particularly slow.
93
- config.profile_examples = 10
94
-
95
- # Run specs in random order to surface order dependencies. If you find an
96
- # order dependency and want to debug it, you can fix the order by providing
97
- # the seed, which is printed after each run.
98
- # --seed 1234
99
- config.order = :random
100
-
101
- # Seed global randomization in this process using the `--seed` CLI option.
102
- # Setting this allows you to use `--seed` to deterministically reproduce
103
- # test failures related to randomization by passing the same `--seed` value
104
- # as the one that triggered the failure.
105
- Kernel.srand config.seed
106
- =end
107
- end
108
-
109
- WebMock.allow_net_connect!