solidus_paypal_commerce_platform 0.4.0 → 0.5.0

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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +23 -4
  3. data/.rubocop.yml +2 -1
  4. data/CHANGELOG.md +159 -145
  5. data/Gemfile +14 -1
  6. data/README.md +2 -2
  7. data/app/controllers/solidus_paypal_commerce_platform/orders_controller.rb +1 -1
  8. data/app/models/solidus_paypal_commerce_platform/gateway.rb +0 -2
  9. data/app/models/solidus_paypal_commerce_platform/payment_method.rb +1 -1
  10. data/app/models/solidus_paypal_commerce_platform/payment_source.rb +1 -1
  11. data/app/models/solidus_paypal_commerce_platform/paypal_order.rb +6 -21
  12. data/lib/paypal/access_token.rb +22 -0
  13. data/lib/paypal/lib.rb +19 -0
  14. data/lib/paypal/paypal_checkout_sdk/orders/orders_authorize_request.rb +44 -0
  15. data/lib/paypal/paypal_checkout_sdk/orders/orders_capture_request.rb +42 -0
  16. data/lib/paypal/paypal_checkout_sdk/orders/orders_create_request.rb +36 -0
  17. data/lib/paypal/paypal_checkout_sdk/orders/orders_get_request.rb +26 -0
  18. data/lib/paypal/paypal_checkout_sdk/orders/orders_patch_request.rb +77 -0
  19. data/lib/paypal/paypal_checkout_sdk/orders/orders_validate_request.rb +34 -0
  20. data/lib/paypal/paypal_checkout_sdk/payments/authorizations_capture_request.rb +38 -0
  21. data/lib/paypal/paypal_checkout_sdk/payments/authorizations_get_request.rb +26 -0
  22. data/lib/paypal/paypal_checkout_sdk/payments/authorizations_reauthorize_request.rb +45 -0
  23. data/lib/paypal/paypal_checkout_sdk/payments/authorizations_void_request.rb +27 -0
  24. data/lib/paypal/paypal_checkout_sdk/payments/captures_get_request.rb +26 -0
  25. data/lib/paypal/paypal_checkout_sdk/payments/captures_refund_request.rb +40 -0
  26. data/lib/paypal/paypal_checkout_sdk/payments/refunds_get_request.rb +26 -0
  27. data/lib/paypal/paypal_environment.rb +39 -0
  28. data/lib/paypal/paypal_http_client.rb +56 -0
  29. data/lib/paypal/token_requests.rb +42 -0
  30. data/lib/solidus_paypal_commerce_platform/access_token_authorization_request.rb +1 -1
  31. data/lib/solidus_paypal_commerce_platform/client.rb +1 -1
  32. data/lib/solidus_paypal_commerce_platform/configuration.rb +1 -1
  33. data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/orders/orders_authorize_request.rb +48 -0
  34. data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/orders/orders_capture_request.rb +46 -0
  35. data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/orders/orders_patch_request.rb +80 -0
  36. data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/orders/orders_validate_request.rb +36 -0
  37. data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/payments/authorizations_reauthorize_request.rb +50 -0
  38. data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/payments/captures_refund_request.rb +43 -0
  39. data/lib/solidus_paypal_commerce_platform/version.rb +1 -1
  40. data/lib/solidus_paypal_commerce_platform.rb +1 -0
  41. data/solidus_paypal_commerce_platform.gemspec +8 -7
  42. metadata +54 -28
@@ -44,19 +44,12 @@ module SolidusPaypalCommercePlatform
44
44
  end
45
45
 
46
46
  def name(address)
47
- if greater_than_2_10?
48
- name = ::Spree::Address::Name.new @order.ship_address.name
47
+ name = ::Spree::Address::Name.new address.name
49
48
 
50
- {
51
- given_name: name.first_name,
52
- surname: name.last_name
53
- }
54
- else
55
- {
56
- given_name: address.firstname,
57
- surname: address.lastname
58
- }
59
- end
49
+ {
50
+ given_name: name.first_name,
51
+ surname: name.last_name
52
+ }
60
53
  end
61
54
 
62
55
  def purchase_units(include_shipping_address: true)
@@ -80,11 +73,7 @@ module SolidusPaypalCommercePlatform
80
73
  end
81
74
 
82
75
  def full_name
83
- if greater_than_2_10?
84
- @order.ship_address.name
85
- else
86
- @order.ship_address.full_name
87
- end
76
+ @order.ship_address.name
88
77
  end
89
78
 
90
79
  def line_items
@@ -120,9 +109,5 @@ module SolidusPaypalCommercePlatform
120
109
  value: amount
121
110
  }
122
111
  end
123
-
124
- def greater_than_2_10?
125
- ::Spree.solidus_gem_version >= Gem::Version.new('2.11')
126
- end
127
112
  end
128
113
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: false
2
+
3
+ module PayPal
4
+ class AccessToken
5
+ attr_accessor :access_token, :token_type, :expires_in, :date_created
6
+
7
+ def initialize(options)
8
+ @access_token = options.access_token
9
+ @token_type = options.token_type
10
+ @expires_in = options.expires_in
11
+ @date_created = Time.zone.now
12
+ end
13
+
14
+ def expired?
15
+ Time.zone.now > @date_created + @expires_in
16
+ end
17
+
18
+ def authorization_string
19
+ "#{@token_type} #{@access_token}"
20
+ end
21
+ end
22
+ end
data/lib/paypal/lib.rb ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: false
2
+
3
+ require 'paypal/paypal_environment'
4
+ require 'paypal/paypal_http_client'
5
+ require 'paypal/token_requests'
6
+ require 'paypal/access_token'
7
+ require 'paypal/paypal_checkout_sdk/orders/orders_authorize_request'
8
+ require 'paypal/paypal_checkout_sdk/orders/orders_capture_request'
9
+ require 'paypal/paypal_checkout_sdk/orders/orders_create_request'
10
+ require 'paypal/paypal_checkout_sdk/orders/orders_get_request'
11
+ require 'paypal/paypal_checkout_sdk/orders/orders_patch_request'
12
+ require 'paypal/paypal_checkout_sdk/orders/orders_validate_request'
13
+ require 'paypal/paypal_checkout_sdk/payments/authorizations_capture_request'
14
+ require 'paypal/paypal_checkout_sdk/payments/authorizations_get_request'
15
+ require 'paypal/paypal_checkout_sdk/payments/authorizations_reauthorize_request'
16
+ require 'paypal/paypal_checkout_sdk/payments/authorizations_void_request'
17
+ require 'paypal/paypal_checkout_sdk/payments/captures_get_request'
18
+ require 'paypal/paypal_checkout_sdk/payments/refunds_get_request'
19
+ require 'paypal/paypal_checkout_sdk/payments/captures_refund_request'
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: false
2
+
3
+ # This class was generated on Mon, 27 Aug 2018 13:51:59 PDT by version 0.1.0-dev+904328-dirty of Braintree SDK Generator
4
+
5
+ require 'cgi'
6
+
7
+ module PayPalCheckoutSdk
8
+ module Orders
9
+ #
10
+ # Authorizes payment for an order. The response shows details
11
+ # of authorizations. You can make this call only if you specified
12
+ # `intent=AUTHORIZE` in the create order call.
13
+ #
14
+ class OrdersAuthorizeRequest
15
+ attr_accessor :path, :body, :headers, :verb
16
+
17
+ def initialize(order_id)
18
+ @headers = {}
19
+ @body = nil
20
+ @verb = "POST"
21
+ @path = "/v2/checkout/orders/{order_id}/authorize?"
22
+
23
+ @path = @path.gsub("{order_id}", CGI.escape(order_id.to_s))
24
+ @headers["Content-Type"] = "application/json"
25
+ end
26
+
27
+ def pay_pal_client_metadata_id(pay_pal_client_metadata_id)
28
+ @headers["PayPal-Client-Metadata-Id"] = pay_pal_client_metadata_id
29
+ end
30
+
31
+ def pay_pal_request_id(pay_pal_request_id)
32
+ @headers["PayPal-Request-Id"] = pay_pal_request_id
33
+ end
34
+
35
+ def prefer(prefer)
36
+ @headers["Prefer"] = prefer
37
+ end
38
+
39
+ def request_body(order_action_request)
40
+ @body = order_action_request
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: false
2
+
3
+ # This class was generated on Mon, 27 Aug 2018 13:51:59 PDT by version 0.1.0-dev+904328-dirty of Braintree SDK Generator
4
+
5
+ require 'cgi'
6
+
7
+ module PayPalCheckoutSdk
8
+ module Orders
9
+ #
10
+ # Captures a payment for an order.
11
+ #
12
+ class OrdersCaptureRequest
13
+ attr_accessor :path, :body, :headers, :verb
14
+
15
+ def initialize(order_id)
16
+ @headers = {}
17
+ @body = nil
18
+ @verb = "POST"
19
+ @path = "/v2/checkout/orders/{order_id}/capture?"
20
+
21
+ @path = @path.gsub("{order_id}", CGI.escape(order_id.to_s))
22
+ @headers["Content-Type"] = "application/json"
23
+ end
24
+
25
+ def pay_pal_client_metadata_id(pay_pal_client_metadata_id)
26
+ @headers["PayPal-Client-Metadata-Id"] = pay_pal_client_metadata_id
27
+ end
28
+
29
+ def pay_pal_request_id(pay_pal_request_id)
30
+ @headers["PayPal-Request-Id"] = pay_pal_request_id
31
+ end
32
+
33
+ def prefer(prefer)
34
+ @headers["Prefer"] = prefer
35
+ end
36
+
37
+ def request_body(order_action_request)
38
+ @body = order_action_request
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: false
2
+
3
+ # This class was generated on Mon, 27 Aug 2018 13:51:59 PDT by version 0.1.0-dev+904328-dirty of Braintree SDK Generator
4
+
5
+ require 'cgi'
6
+
7
+ module PayPalCheckoutSdk
8
+ module Orders
9
+ #
10
+ # Creates an order. Supports only orders with one purchase unit.
11
+ #
12
+ class OrdersCreateRequest
13
+ attr_accessor :path, :body, :headers, :verb
14
+
15
+ def initialize
16
+ @headers = {}
17
+ @body = nil
18
+ @verb = "POST"
19
+ @path = "/v2/checkout/orders?"
20
+ @headers["Content-Type"] = "application/json"
21
+ end
22
+
23
+ def pay_pal_partner_attribution_id(pay_pal_partner_attribution_id)
24
+ @headers["PayPal-Partner-Attribution-Id"] = pay_pal_partner_attribution_id
25
+ end
26
+
27
+ def prefer(prefer)
28
+ @headers["Prefer"] = prefer
29
+ end
30
+
31
+ def request_body(order)
32
+ @body = order
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: false
2
+
3
+ # This class was generated on Mon, 27 Aug 2018 13:51:59 PDT by version 0.1.0-dev+904328-dirty of Braintree SDK Generator
4
+
5
+ require 'cgi'
6
+
7
+ module PayPalCheckoutSdk
8
+ module Orders
9
+ #
10
+ # Shows details for an order, by ID.
11
+ #
12
+ class OrdersGetRequest
13
+ attr_accessor :path, :body, :headers, :verb
14
+
15
+ def initialize(order_id)
16
+ @headers = {}
17
+ @body = nil
18
+ @verb = "GET"
19
+ @path = "/v2/checkout/orders/{order_id}?"
20
+
21
+ @path = @path.gsub("{order_id}", CGI.escape(order_id.to_s))
22
+ @headers["Content-Type"] = "application/json"
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: false
2
+
3
+ # This class was generated on Mon, 27 Aug 2018 13:51:59 PDT by version 0.1.0-dev+904328-dirty of Braintree SDK Generator
4
+
5
+ require 'cgi'
6
+
7
+ module PayPalCheckoutSdk
8
+ module Orders
9
+ #
10
+ # Updates an order that has the `CREATED` or `APPROVED` status. You cannot update an order with `COMPLETED` status.
11
+ # You can patch these attributes and objects:
12
+ # <table>
13
+ # <thead>
14
+ # <tr>
15
+ # <th align="left">Attribute or object</th>
16
+ # <th align="left">Operations</th>
17
+ # </tr>
18
+ # </thead>
19
+ # <tbody>
20
+ # <tr>
21
+ # <td><code>intent</code></td>
22
+ # <td align="left">Replace</td>
23
+ # </tr>
24
+ # <tr>
25
+ # <td><code>purchase_units</code></td>
26
+ # <td align="left">Replace, add</td>
27
+ # </tr>
28
+ # <tr>
29
+ # <td><code>purchase_units[].custom_id</code></td>
30
+ # <td align="left">Replace, add, remove</td>
31
+ # </tr>
32
+ # <tr>
33
+ # <td><code>purchase_units[].description</code></td>
34
+ # <td align="left">Replace, add, remove</td>
35
+ # </tr>
36
+ # <tr>
37
+ # <td><code>purchase_units[].payee.email</code></td>
38
+ # <td align="left">Replace, add</td>
39
+ # </tr>
40
+ # <tr>
41
+ # <td><code>purchase_units[].shipping</code></td>
42
+ # <td align="left">Replace, add, remove</td>
43
+ # </tr>
44
+ # <tr>
45
+ # <td><code>purchase_units[].soft_descriptor</code></td>
46
+ # <td align="left">Replace, add, remove</td>
47
+ # </tr>
48
+ # <tr>
49
+ # <td><code>purchase_units[].amount</code></td>
50
+ # <td align="left">Replace</td>
51
+ # </tr>
52
+ # <tr>
53
+ # <td><code>purchase_units[].invoice_id</code></td>
54
+ # <td align="left">Replace, add, remove</td>
55
+ # </tr>
56
+ # </tbody>
57
+ # </table>
58
+ #
59
+ class OrdersPatchRequest
60
+ attr_accessor :path, :body, :headers, :verb
61
+
62
+ def initialize(order_id)
63
+ @headers = {}
64
+ @body = nil
65
+ @verb = "PATCH"
66
+ @path = "/v2/checkout/orders/{order_id}?"
67
+
68
+ @path = @path.gsub("{order_id}", CGI.escape(order_id.to_s))
69
+ @headers["Content-Type"] = "application/json"
70
+ end
71
+
72
+ def request_body(patch_request)
73
+ @body = patch_request
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: false
2
+
3
+ # This class was generated on Mon, 27 Aug 2018 13:51:59 PDT by version 0.1.0-dev+904328-dirty of Braintree SDK Generator
4
+
5
+ require 'cgi'
6
+
7
+ module PayPalCheckoutSdk
8
+ module Orders
9
+ #
10
+ # Validates a payment method and checks it for contingencies.
11
+ #
12
+ class OrdersValidateRequest
13
+ attr_accessor :path, :body, :headers, :verb
14
+
15
+ def initialize(order_id)
16
+ @headers = {}
17
+ @body = nil
18
+ @verb = "POST"
19
+ @path = "/v2/checkout/orders/{order_id}/validate-payment-method?"
20
+
21
+ @path = @path.gsub("{order_id}", CGI.escape(order_id.to_s))
22
+ @headers["Content-Type"] = "application/json"
23
+ end
24
+
25
+ def pay_pal_client_metadata_id(pay_pal_client_metadata_id)
26
+ @headers["PayPal-Client-Metadata-Id"] = pay_pal_client_metadata_id
27
+ end
28
+
29
+ def request_body(order_action_request)
30
+ @body = order_action_request
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: false
2
+
3
+ # This class was generated on Mon, 27 Aug 2018 13:52:18 PDT by version 0.1.0-dev+904328-dirty of Braintree SDK Generator
4
+
5
+ require 'cgi'
6
+
7
+ module PayPalCheckoutSdk
8
+ module Payments
9
+ #
10
+ # Captures an authorized payment, by ID.
11
+ #
12
+ class AuthorizationsCaptureRequest
13
+ attr_accessor :path, :body, :headers, :verb
14
+
15
+ def initialize(authorization_id)
16
+ @headers = {}
17
+ @body = nil
18
+ @verb = "POST"
19
+ @path = "/v2/payments/authorizations/{authorization_id}/capture?"
20
+
21
+ @path = @path.gsub("{authorization_id}", CGI.escape(authorization_id.to_s))
22
+ @headers["Content-Type"] = "application/json"
23
+ end
24
+
25
+ def pay_pal_request_id(pay_pal_request_id)
26
+ @headers["PayPal-Request-Id"] = pay_pal_request_id
27
+ end
28
+
29
+ def prefer(prefer)
30
+ @headers["Prefer"] = prefer
31
+ end
32
+
33
+ def request_body(capture)
34
+ @body = capture
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: false
2
+
3
+ # This class was generated on Mon, 27 Aug 2018 13:52:18 PDT by version 0.1.0-dev+904328-dirty of Braintree SDK Generator
4
+
5
+ require 'cgi'
6
+
7
+ module PayPalCheckoutSdk
8
+ module Payments
9
+ #
10
+ # Shows details for an authorized payment, by ID.
11
+ #
12
+ class AuthorizationsGetRequest
13
+ attr_accessor :path, :body, :headers, :verb
14
+
15
+ def initialize(authorization_id)
16
+ @headers = {}
17
+ @body = nil
18
+ @verb = "GET"
19
+ @path = "/v2/payments/authorizations/{authorization_id}?"
20
+
21
+ @path = @path.gsub("{authorization_id}", CGI.escape(authorization_id.to_s))
22
+ @headers["Content-Type"] = "application/json"
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: false
2
+
3
+ # This class was generated on Mon, 27 Aug 2018 13:52:18 PDT by version 0.1.0-dev+904328-dirty of Braintree SDK Generator
4
+
5
+ require 'cgi'
6
+
7
+ module PayPalCheckoutSdk
8
+ module Payments
9
+ #
10
+ # Reauthorizes an authorized PayPal account payment, by ID. To ensure that funds are still available,
11
+ # reauthorize a payment after its initial three-day honor period expires. You can reauthorize a
12
+ # payment only once from days four to 29.<br/><br/> If 30 days have transpired since the date of the
13
+ # original authorization, you must create an authorized payment instead of reauthorizing the original
14
+ # authorized payment.<br/><br/>A reauthorized payment itself has a new honor period of three
15
+ # days.<br/><br/>You can reauthorize an authorized payment once for up to 115% of the original
16
+ # authorized amount, not to exceed an increase of $75 USD.<br/><br/>Supports only the `amount` request
17
+ # parameter.
18
+ #
19
+ class AuthorizationsReauthorizeRequest
20
+ attr_accessor :path, :body, :headers, :verb
21
+
22
+ def initialize(authorization_id)
23
+ @headers = {}
24
+ @body = nil
25
+ @verb = "POST"
26
+ @path = "/v2/payments/authorizations/{authorization_id}/reauthorize?"
27
+
28
+ @path = @path.gsub("{authorization_id}", CGI.escape(authorization_id.to_s))
29
+ @headers["Content-Type"] = "application/json"
30
+ end
31
+
32
+ def pay_pal_request_id(pay_pal_request_id)
33
+ @headers["PayPal-Request-Id"] = pay_pal_request_id
34
+ end
35
+
36
+ def prefer(prefer)
37
+ @headers["Prefer"] = prefer
38
+ end
39
+
40
+ def request_body(reauthorize_request)
41
+ @body = reauthorize_request
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: false
2
+
3
+ # This class was generated on Mon, 27 Aug 2018 13:52:18 PDT by version 0.1.0-dev+904328-dirty of Braintree SDK Generator
4
+
5
+ require 'cgi'
6
+
7
+ module PayPalCheckoutSdk
8
+ module Payments
9
+ #
10
+ # Voids, or cancels, an authorized payment, by ID. You cannot
11
+ # void an authorized payment that has been fully captured.
12
+ #
13
+ class AuthorizationsVoidRequest
14
+ attr_accessor :path, :body, :headers, :verb
15
+
16
+ def initialize(authorization_id)
17
+ @headers = {}
18
+ @body = nil
19
+ @verb = "POST"
20
+ @path = "/v2/payments/authorizations/{authorization_id}/void?"
21
+
22
+ @path = @path.gsub("{authorization_id}", CGI.escape(authorization_id.to_s))
23
+ @headers["Content-Type"] = "application/json"
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: false
2
+
3
+ # This class was generated on Mon, 27 Aug 2018 13:52:18 PDT by version 0.1.0-dev+904328-dirty of Braintree SDK Generator
4
+
5
+ require 'cgi'
6
+
7
+ module PayPalCheckoutSdk
8
+ module Payments
9
+ #
10
+ # Shows details for a captured payment, by ID.
11
+ #
12
+ class CapturesGetRequest
13
+ attr_accessor :path, :body, :headers, :verb
14
+
15
+ def initialize(capture_id)
16
+ @headers = {}
17
+ @body = nil
18
+ @verb = "GET"
19
+ @path = "/v2/payments/captures/{capture_id}?"
20
+
21
+ @path = @path.gsub("{capture_id}", CGI.escape(capture_id.to_s))
22
+ @headers["Content-Type"] = "application/json"
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: false
2
+
3
+ # This class was generated on Mon, 27 Aug 2018 13:52:18 PDT by version 0.1.0-dev+904328-dirty of Braintree SDK Generator
4
+
5
+ require 'cgi'
6
+
7
+ module PayPalCheckoutSdk
8
+ module Payments
9
+ #
10
+ # Refunds a captured payment, by ID. For a full refund, include
11
+ # an empty payload in the JSON request body. For a partial refund,
12
+ # include an <code>amount</code> object in the JSON request body.
13
+ #
14
+ class CapturesRefundRequest
15
+ attr_accessor :path, :body, :headers, :verb
16
+
17
+ def initialize(capture_id)
18
+ @headers = {}
19
+ @body = nil
20
+ @verb = "POST"
21
+ @path = "/v2/payments/captures/{capture_id}/refund?"
22
+
23
+ @path = @path.gsub("{capture_id}", CGI.escape(capture_id.to_s))
24
+ @headers["Content-Type"] = "application/json"
25
+ end
26
+
27
+ def pay_pal_request_id(pay_pal_request_id)
28
+ @headers["PayPal-Request-Id"] = pay_pal_request_id
29
+ end
30
+
31
+ def prefer(prefer)
32
+ @headers["Prefer"] = prefer
33
+ end
34
+
35
+ def request_body(refund_request)
36
+ @body = refund_request
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: false
2
+
3
+ # This class was generated on Mon, 27 Aug 2018 13:52:18 PDT by version 0.1.0-dev+904328-dirty of Braintree SDK Generator
4
+
5
+ require 'cgi'
6
+
7
+ module PayPalCheckoutSdk
8
+ module Payments
9
+ #
10
+ # Shows details for a refund, by ID.
11
+ #
12
+ class RefundsGetRequest
13
+ attr_accessor :path, :body, :headers, :verb
14
+
15
+ def initialize(refund_id)
16
+ @headers = {}
17
+ @body = nil
18
+ @verb = "GET"
19
+ @path = "/v2/payments/refunds/{refund_id}?"
20
+
21
+ @path = @path.gsub("{refund_id}", CGI.escape(refund_id.to_s))
22
+ @headers["Content-Type"] = "application/json"
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: false
2
+
3
+ require 'paypalhttp'
4
+ require "base64"
5
+
6
+ module PayPal
7
+ SANDBOXAPI = 'https://api.sandbox.paypal.com'.freeze
8
+ LIVEAPI = 'https://api.paypal.com'.freeze
9
+ SANDBOXWEB = 'https://sandbox.paypal.com'.freeze
10
+ LIVEWEB = 'https://paypal.com'.freeze
11
+
12
+ class PayPalEnvironment < PayPalHttp::Environment
13
+ attr_accessor :client_id, :client_secret, :web_url
14
+
15
+ def initialize(client_id, client_secret, base_url, web_url)
16
+ super(base_url)
17
+ @client_id = client_id
18
+ @client_secret = client_secret
19
+ @web_url = web_url
20
+ end
21
+
22
+ def authorization_string
23
+ encoded = Base64.strict_encode64("#{@client_id}:#{@client_secret}")
24
+ "Basic #{encoded}"
25
+ end
26
+ end
27
+
28
+ class SandboxEnvironment < PayPal::PayPalEnvironment
29
+ def initialize(client_id, client_secret)
30
+ super(client_id, client_secret, PayPal::SANDBOXAPI, PayPal::SANDBOXWEB)
31
+ end
32
+ end
33
+
34
+ class LiveEnvironment < PayPal::PayPalEnvironment
35
+ def initialize(client_id, client_secret)
36
+ super(client_id, client_secret, PayPal::LIVEAPI, PayPal::LIVEWEB)
37
+ end
38
+ end
39
+ end