solidus_paypal_commerce_platform 0.4.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +23 -4
- data/.github/stale.yml +1 -17
- data/.rubocop.yml +2 -1
- data/CHANGELOG.md +194 -147
- data/Gemfile +14 -1
- data/README.md +2 -2
- data/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/button_actions.js +7 -4
- data/app/controllers/solidus_paypal_commerce_platform/orders_controller.rb +3 -2
- data/app/controllers/solidus_paypal_commerce_platform/paypal_orders_controller.rb +1 -1
- data/app/models/solidus_paypal_commerce_platform/gateway.rb +0 -2
- data/app/models/solidus_paypal_commerce_platform/payment_method.rb +7 -6
- data/app/models/solidus_paypal_commerce_platform/payment_source.rb +1 -1
- data/app/models/solidus_paypal_commerce_platform/paypal_address.rb +6 -2
- data/app/models/solidus_paypal_commerce_platform/paypal_order.rb +26 -34
- data/bin/sandbox +3 -24
- data/lib/generators/solidus_paypal_commerce_platform/install/install_generator.rb +46 -21
- data/lib/paypal/access_token.rb +22 -0
- data/lib/paypal/lib.rb +19 -0
- data/lib/paypal/paypal_checkout_sdk/orders/orders_authorize_request.rb +42 -0
- data/lib/paypal/paypal_checkout_sdk/orders/orders_capture_request.rb +40 -0
- data/lib/paypal/paypal_checkout_sdk/orders/orders_create_request.rb +34 -0
- data/lib/paypal/paypal_checkout_sdk/orders/orders_get_request.rb +24 -0
- data/lib/paypal/paypal_checkout_sdk/orders/orders_patch_request.rb +25 -0
- data/lib/paypal/paypal_checkout_sdk/orders/orders_validate_request.rb +32 -0
- data/lib/paypal/paypal_checkout_sdk/payments/authorizations_capture_request.rb +36 -0
- data/lib/paypal/paypal_checkout_sdk/payments/authorizations_get_request.rb +24 -0
- data/lib/paypal/paypal_checkout_sdk/payments/authorizations_reauthorize_request.rb +43 -0
- data/lib/paypal/paypal_checkout_sdk/payments/authorizations_void_request.rb +25 -0
- data/lib/paypal/paypal_checkout_sdk/payments/captures_get_request.rb +24 -0
- data/lib/paypal/paypal_checkout_sdk/payments/captures_refund_request.rb +38 -0
- data/lib/paypal/paypal_checkout_sdk/payments/refunds_get_request.rb +24 -0
- data/lib/paypal/paypal_environment.rb +39 -0
- data/lib/paypal/paypal_http_client.rb +56 -0
- data/lib/paypal/token_requests.rb +42 -0
- data/lib/solidus_paypal_commerce_platform/access_token_authorization_request.rb +1 -1
- data/lib/solidus_paypal_commerce_platform/client.rb +7 -4
- data/lib/solidus_paypal_commerce_platform/configuration.rb +1 -1
- data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/orders/orders_authorize_request.rb +48 -0
- data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/orders/orders_capture_request.rb +46 -0
- data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/orders/orders_patch_request.rb +27 -0
- data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/orders/orders_validate_request.rb +36 -0
- data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/payments/authorizations_reauthorize_request.rb +50 -0
- data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/payments/captures_refund_request.rb +43 -0
- data/lib/solidus_paypal_commerce_platform/version.rb +1 -1
- data/lib/solidus_paypal_commerce_platform.rb +1 -0
- data/solidus_paypal_commerce_platform.gemspec +8 -7
- metadata +54 -28
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module PayPalCheckoutSdk
|
6
|
+
module Payments
|
7
|
+
#
|
8
|
+
# Captures an authorized payment, by ID.
|
9
|
+
#
|
10
|
+
class AuthorizationsCaptureRequest
|
11
|
+
attr_accessor :path, :body, :headers, :verb
|
12
|
+
|
13
|
+
def initialize(authorization_id)
|
14
|
+
@headers = {}
|
15
|
+
@body = nil
|
16
|
+
@verb = "POST"
|
17
|
+
@path = "/v2/payments/authorizations/{authorization_id}/capture?"
|
18
|
+
|
19
|
+
@path = @path.gsub("{authorization_id}", CGI.escape(authorization_id.to_s))
|
20
|
+
@headers["Content-Type"] = "application/json"
|
21
|
+
end
|
22
|
+
|
23
|
+
def pay_pal_request_id(pay_pal_request_id)
|
24
|
+
@headers["PayPal-Request-Id"] = pay_pal_request_id
|
25
|
+
end
|
26
|
+
|
27
|
+
def prefer(prefer)
|
28
|
+
@headers["Prefer"] = prefer
|
29
|
+
end
|
30
|
+
|
31
|
+
def request_body(capture)
|
32
|
+
@body = capture
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module PayPalCheckoutSdk
|
6
|
+
module Payments
|
7
|
+
#
|
8
|
+
# Shows details for an authorized payment, by ID.
|
9
|
+
#
|
10
|
+
class AuthorizationsGetRequest
|
11
|
+
attr_accessor :path, :body, :headers, :verb
|
12
|
+
|
13
|
+
def initialize(authorization_id)
|
14
|
+
@headers = {}
|
15
|
+
@body = nil
|
16
|
+
@verb = "GET"
|
17
|
+
@path = "/v2/payments/authorizations/{authorization_id}?"
|
18
|
+
|
19
|
+
@path = @path.gsub("{authorization_id}", CGI.escape(authorization_id.to_s))
|
20
|
+
@headers["Content-Type"] = "application/json"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module PayPalCheckoutSdk
|
6
|
+
module Payments
|
7
|
+
#
|
8
|
+
# Reauthorizes an authorized PayPal account payment, by ID. To ensure that funds are still available,
|
9
|
+
# reauthorize a payment after its initial three-day honor period expires. You can reauthorize a
|
10
|
+
# payment only once from days four to 29.<br/><br/> If 30 days have transpired since the date of the
|
11
|
+
# original authorization, you must create an authorized payment instead of reauthorizing the original
|
12
|
+
# authorized payment.<br/><br/>A reauthorized payment itself has a new honor period of three
|
13
|
+
# days.<br/><br/>You can reauthorize an authorized payment once for up to 115% of the original
|
14
|
+
# authorized amount, not to exceed an increase of $75 USD.<br/><br/>Supports only the `amount` request
|
15
|
+
# parameter.
|
16
|
+
#
|
17
|
+
class AuthorizationsReauthorizeRequest
|
18
|
+
attr_accessor :path, :body, :headers, :verb
|
19
|
+
|
20
|
+
def initialize(authorization_id)
|
21
|
+
@headers = {}
|
22
|
+
@body = nil
|
23
|
+
@verb = "POST"
|
24
|
+
@path = "/v2/payments/authorizations/{authorization_id}/reauthorize?"
|
25
|
+
|
26
|
+
@path = @path.gsub("{authorization_id}", CGI.escape(authorization_id.to_s))
|
27
|
+
@headers["Content-Type"] = "application/json"
|
28
|
+
end
|
29
|
+
|
30
|
+
def pay_pal_request_id(pay_pal_request_id)
|
31
|
+
@headers["PayPal-Request-Id"] = pay_pal_request_id
|
32
|
+
end
|
33
|
+
|
34
|
+
def prefer(prefer)
|
35
|
+
@headers["Prefer"] = prefer
|
36
|
+
end
|
37
|
+
|
38
|
+
def request_body(reauthorize_request)
|
39
|
+
@body = reauthorize_request
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module PayPalCheckoutSdk
|
6
|
+
module Payments
|
7
|
+
#
|
8
|
+
# Voids, or cancels, an authorized payment, by ID. You cannot
|
9
|
+
# void an authorized payment that has been fully captured.
|
10
|
+
#
|
11
|
+
class AuthorizationsVoidRequest
|
12
|
+
attr_accessor :path, :body, :headers, :verb
|
13
|
+
|
14
|
+
def initialize(authorization_id)
|
15
|
+
@headers = {}
|
16
|
+
@body = nil
|
17
|
+
@verb = "POST"
|
18
|
+
@path = "/v2/payments/authorizations/{authorization_id}/void?"
|
19
|
+
|
20
|
+
@path = @path.gsub("{authorization_id}", CGI.escape(authorization_id.to_s))
|
21
|
+
@headers["Content-Type"] = "application/json"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module PayPalCheckoutSdk
|
6
|
+
module Payments
|
7
|
+
#
|
8
|
+
# Shows details for a captured payment, by ID.
|
9
|
+
#
|
10
|
+
class CapturesGetRequest
|
11
|
+
attr_accessor :path, :body, :headers, :verb
|
12
|
+
|
13
|
+
def initialize(capture_id)
|
14
|
+
@headers = {}
|
15
|
+
@body = nil
|
16
|
+
@verb = "GET"
|
17
|
+
@path = "/v2/payments/captures/{capture_id}?"
|
18
|
+
|
19
|
+
@path = @path.gsub("{capture_id}", CGI.escape(capture_id.to_s))
|
20
|
+
@headers["Content-Type"] = "application/json"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module PayPalCheckoutSdk
|
6
|
+
module Payments
|
7
|
+
#
|
8
|
+
# Refunds a captured payment, by ID. For a full refund, include
|
9
|
+
# an empty payload in the JSON request body. For a partial refund,
|
10
|
+
# include an <code>amount</code> object in the JSON request body.
|
11
|
+
#
|
12
|
+
class CapturesRefundRequest
|
13
|
+
attr_accessor :path, :body, :headers, :verb
|
14
|
+
|
15
|
+
def initialize(capture_id)
|
16
|
+
@headers = {}
|
17
|
+
@body = nil
|
18
|
+
@verb = "POST"
|
19
|
+
@path = "/v2/payments/captures/{capture_id}/refund?"
|
20
|
+
|
21
|
+
@path = @path.gsub("{capture_id}", CGI.escape(capture_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(refund_request)
|
34
|
+
@body = refund_request
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module PayPalCheckoutSdk
|
6
|
+
module Payments
|
7
|
+
#
|
8
|
+
# Shows details for a refund, by ID.
|
9
|
+
#
|
10
|
+
class RefundsGetRequest
|
11
|
+
attr_accessor :path, :body, :headers, :verb
|
12
|
+
|
13
|
+
def initialize(refund_id)
|
14
|
+
@headers = {}
|
15
|
+
@body = nil
|
16
|
+
@verb = "GET"
|
17
|
+
@path = "/v2/payments/refunds/{refund_id}?"
|
18
|
+
|
19
|
+
@path = @path.gsub("{refund_id}", CGI.escape(refund_id.to_s))
|
20
|
+
@headers["Content-Type"] = "application/json"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
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
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
3
|
+
require 'paypalhttp'
|
4
|
+
require 'openssl'
|
5
|
+
|
6
|
+
module PayPal
|
7
|
+
class PayPalHttpClient < PayPalHttp::HttpClient
|
8
|
+
attr_accessor :refresh_token
|
9
|
+
|
10
|
+
def initialize(environment, refresh_token = nil)
|
11
|
+
super(environment)
|
12
|
+
@refresh_token = refresh_token
|
13
|
+
|
14
|
+
add_injector { |r| _sign_request(r) }
|
15
|
+
add_injector { |r| _add_headers(r) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def user_agent
|
19
|
+
library_details ||= "ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}-#{RUBY_PLATFORM}"
|
20
|
+
begin
|
21
|
+
library_details << ";#{OpenSSL::OPENSSL_LIBRARY_VERSION}"
|
22
|
+
rescue NameError
|
23
|
+
library_details << ";OpenSSL #{OpenSSL::OPENSSL_VERSION}"
|
24
|
+
end
|
25
|
+
|
26
|
+
"PayPalSDK-FORK/rest-sdk-ruby (#{library_details})"
|
27
|
+
end
|
28
|
+
|
29
|
+
def _sign_request(request)
|
30
|
+
return if _has_auth_header(request) || _is_auth_request(request)
|
31
|
+
|
32
|
+
if !@access_token || @access_token.expired?
|
33
|
+
access_token_request = PayPal::AccessTokenRequest.new(@environment, @refresh_token)
|
34
|
+
token_response = execute(access_token_request)
|
35
|
+
@access_token = PayPal::AccessToken.new(token_response.result)
|
36
|
+
end
|
37
|
+
request.headers["Authorization"] = @access_token.authorization_string
|
38
|
+
end
|
39
|
+
|
40
|
+
def _add_headers(request)
|
41
|
+
request.headers["Accept-Encoding"] = "gzip"
|
42
|
+
request.headers["sdk_name"] = "Checkout SDK"
|
43
|
+
request.headers["sdk_tech_stack"] = "Ruby#{RUBY_VERSION}"
|
44
|
+
request.headers["api_integration_type"] = "PAYPALSDK"
|
45
|
+
end
|
46
|
+
|
47
|
+
def _is_auth_request(request)
|
48
|
+
request.path == '/v1/oauth2/token' ||
|
49
|
+
request.path == '/v1/identity/openidconnect/tokenservice'
|
50
|
+
end
|
51
|
+
|
52
|
+
def _has_auth_header(request)
|
53
|
+
request.headers.key?("Authorization")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
3
|
+
module PayPal
|
4
|
+
class AccessTokenRequest
|
5
|
+
attr_accessor :path, :body, :headers, :verb
|
6
|
+
|
7
|
+
def initialize(environment, refresh_token = nil)
|
8
|
+
@path = "/v1/oauth2/token"
|
9
|
+
@body = {
|
10
|
+
grant_type: "client_credentials",
|
11
|
+
}
|
12
|
+
|
13
|
+
if refresh_token
|
14
|
+
@body[:grant_type] = "refresh_token"
|
15
|
+
@body[:refresh_token] = refresh_token
|
16
|
+
end
|
17
|
+
|
18
|
+
@headers = {
|
19
|
+
"Content-Type" => "application/x-www-form-urlencoded",
|
20
|
+
"Authorization" => environment.authorization_string,
|
21
|
+
}
|
22
|
+
@verb = "POST"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class RefreshTokenRequest
|
27
|
+
attr_accessor :path, :body, :headers, :verb
|
28
|
+
|
29
|
+
def initialize(environment, authorization_code)
|
30
|
+
@path = "/v1/identity/openidconnect/tokenservice"
|
31
|
+
@body = {
|
32
|
+
grant_type: "authorization_code",
|
33
|
+
code: authorization_code,
|
34
|
+
}
|
35
|
+
@headers = {
|
36
|
+
"Content-Type" => "application/x-www-form-urlencoded",
|
37
|
+
"Authorization" => environment.authorization_string,
|
38
|
+
}
|
39
|
+
@verb = "POST"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -9,7 +9,7 @@ module SolidusPaypalCommercePlatform
|
|
9
9
|
@path = "/v1/oauth2/token"
|
10
10
|
@headers = {
|
11
11
|
"Content-Type" => "application/x-www-form-urlencoded",
|
12
|
-
"Authorization" => environment.
|
12
|
+
"Authorization" => environment.authorization_string,
|
13
13
|
}
|
14
14
|
@body = {
|
15
15
|
grant_type: "authorization_code",
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'solidus_paypal_commerce_platform/access_token_authorization_request'
|
4
4
|
require 'solidus_paypal_commerce_platform/fetch_merchant_credentials_request'
|
5
5
|
|
6
|
-
require '
|
6
|
+
require 'paypalhttp'
|
7
7
|
|
8
8
|
module SolidusPaypalCommercePlatform
|
9
9
|
class Client
|
@@ -13,7 +13,7 @@ module SolidusPaypalCommercePlatform
|
|
13
13
|
request.headers["PayPal-Partner-Attribution-Id"] = SolidusPaypalCommercePlatform.config.partner_code
|
14
14
|
}.freeze
|
15
15
|
|
16
|
-
Response = Struct.new(:status_code, :error)
|
16
|
+
Response = Struct.new(:status_code, :error, keyword_init: true)
|
17
17
|
|
18
18
|
attr_reader :environment
|
19
19
|
|
@@ -28,9 +28,12 @@ module SolidusPaypalCommercePlatform
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def execute(request)
|
31
|
-
|
31
|
+
Rails.logger.info "[SolidusPaypalCommercePlatform::Client#execute] #{request.inspect}"
|
32
|
+
@paypal_client.execute(request).tap do |response|
|
33
|
+
Rails.logger.info "[SolidusPaypalCommercePlatform::Client#execute] #{response.inspect}"
|
34
|
+
end
|
32
35
|
rescue PayPalHttp::HttpError => e
|
33
|
-
Rails.logger.error e.result
|
36
|
+
Rails.logger.error "[SolidusPaypalCommercePlatform::Client#execute] #{e.result.inspect}"
|
34
37
|
Response.new(status_code: 422, error: e.result)
|
35
38
|
end
|
36
39
|
|
data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/orders/orders_authorize_request.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# frozen_string_literal :true
|
4
|
+
|
5
|
+
# This module was automatically generated from paypal_checkout_sdk 1.0.1
|
6
|
+
|
7
|
+
require 'cgi'
|
8
|
+
|
9
|
+
module SolidusPaypalCommercePlatform
|
10
|
+
module PayPalCheckoutSdk
|
11
|
+
module Orders
|
12
|
+
#
|
13
|
+
# Authorizes payment for an order. The response shows details of authorizations.
|
14
|
+
# You can make this call only if you specified `intent=AUTHORIZE` in the
|
15
|
+
# create order call.
|
16
|
+
#
|
17
|
+
class OrdersAuthorizeRequest
|
18
|
+
attr_accessor :path, :body, :headers, :verb
|
19
|
+
|
20
|
+
def initialize(order_id)
|
21
|
+
@headers = {}
|
22
|
+
@body = nil
|
23
|
+
@verb = "POST"
|
24
|
+
@path = "/v2/checkout/orders/{order_id}/authorize?"
|
25
|
+
|
26
|
+
@path = @path.gsub("{order_id}", CGI.escape(order_id.to_s))
|
27
|
+
@headers["Content-Type"] = "application/json"
|
28
|
+
end
|
29
|
+
|
30
|
+
def pay_pal_client_metadata_id(pay_pal_client_metadata_id)
|
31
|
+
@headers["PayPal-Client-Metadata-Id"] = pay_pal_client_metadata_id
|
32
|
+
end
|
33
|
+
|
34
|
+
def pay_pal_request_id(pay_pal_request_id)
|
35
|
+
@headers["PayPal-Request-Id"] = pay_pal_request_id
|
36
|
+
end
|
37
|
+
|
38
|
+
def prefer(prefer)
|
39
|
+
@headers["Prefer"] = prefer
|
40
|
+
end
|
41
|
+
|
42
|
+
def request_body(order_action_request)
|
43
|
+
@body = order_action_request
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/orders/orders_capture_request.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# frozen_string_literal :true
|
4
|
+
|
5
|
+
# This module was automatically generated from paypal_checkout_sdk 1.0.1
|
6
|
+
|
7
|
+
require 'cgi'
|
8
|
+
|
9
|
+
module SolidusPaypalCommercePlatform
|
10
|
+
module PayPalCheckoutSdk
|
11
|
+
module Orders
|
12
|
+
#
|
13
|
+
# Captures a payment for an order.
|
14
|
+
#
|
15
|
+
class OrdersCaptureRequest
|
16
|
+
attr_accessor :path, :body, :headers, :verb
|
17
|
+
|
18
|
+
def initialize(order_id)
|
19
|
+
@headers = {}
|
20
|
+
@body = nil
|
21
|
+
@verb = "POST"
|
22
|
+
@path = "/v2/checkout/orders/{order_id}/capture?"
|
23
|
+
|
24
|
+
@path = @path.gsub("{order_id}", CGI.escape(order_id.to_s))
|
25
|
+
@headers["Content-Type"] = "application/json"
|
26
|
+
end
|
27
|
+
|
28
|
+
def pay_pal_client_metadata_id(pay_pal_client_metadata_id)
|
29
|
+
@headers["PayPal-Client-Metadata-Id"] = pay_pal_client_metadata_id
|
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(order_action_request)
|
41
|
+
@body = order_action_request
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module SolidusPaypalCommercePlatform
|
6
|
+
module PayPalCheckoutSdk
|
7
|
+
module Orders
|
8
|
+
class OrdersPatchRequest
|
9
|
+
attr_accessor :path, :body, :headers, :verb
|
10
|
+
|
11
|
+
def initialize(order_id)
|
12
|
+
@headers = {}
|
13
|
+
@body = nil
|
14
|
+
@verb = "PATCH"
|
15
|
+
@path = "/v2/checkout/orders/{order_id}?"
|
16
|
+
|
17
|
+
@path = @path.gsub("{order_id}", CGI.escape(order_id.to_s))
|
18
|
+
@headers["Content-Type"] = "application/json"
|
19
|
+
end
|
20
|
+
|
21
|
+
def request_body(patch_request)
|
22
|
+
@body = patch_request
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/orders/orders_validate_request.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# frozen_string_literal :true
|
4
|
+
|
5
|
+
# This module was automatically generated from paypal_checkout_sdk 1.0.1
|
6
|
+
require 'cgi'
|
7
|
+
module SolidusPaypalCommercePlatform
|
8
|
+
module PayPalCheckoutSdk
|
9
|
+
module Orders
|
10
|
+
#
|
11
|
+
# Validates a payment method and checks it for contingencies.
|
12
|
+
#
|
13
|
+
class OrdersValidateRequest
|
14
|
+
attr_accessor :path, :body, :headers, :verb
|
15
|
+
|
16
|
+
def initialize(order_id)
|
17
|
+
@headers = {}
|
18
|
+
@body = nil
|
19
|
+
@verb = "POST"
|
20
|
+
@path = "/v2/checkout/orders/{order_id}/validate-payment-method?"
|
21
|
+
|
22
|
+
@path = @path.gsub("{order_id}", CGI.escape(order_id.to_s))
|
23
|
+
@headers["Content-Type"] = "application/json"
|
24
|
+
end
|
25
|
+
|
26
|
+
def pay_pal_client_metadata_id(pay_pal_client_metadata_id)
|
27
|
+
@headers["PayPal-Client-Metadata-Id"] = pay_pal_client_metadata_id
|
28
|
+
end
|
29
|
+
|
30
|
+
def request_body(order_action_request)
|
31
|
+
@body = order_action_request
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# frozen_string_literal :true
|
4
|
+
|
5
|
+
# This module was automatically generated from paypal_checkout_sdk 1.0.1
|
6
|
+
require 'cgi'
|
7
|
+
|
8
|
+
module SolidusPaypalCommercePlatform
|
9
|
+
module PayPalCheckoutSdk
|
10
|
+
module Payments
|
11
|
+
#
|
12
|
+
# Reauthorizes an authorized PayPal account payment, by ID. To ensure
|
13
|
+
# that funds are still available, reauthorize a payment after its
|
14
|
+
# initial three-day honor period expires. You can reauthorize a payment
|
15
|
+
# only once from days four to 29.<br/><br/>If 30 days have transpired since
|
16
|
+
# the date of the original authorization, you must create an authorized
|
17
|
+
# payment instead of reauthorizing the original authorized payment.<br/><br/>
|
18
|
+
# A reauthorized payment itself has a new honor period of three days.
|
19
|
+
# <br/><br/>You can reauthorize an authorized payment once for up to 115%
|
20
|
+
# of the original authorized amount, not to exceed an increase of
|
21
|
+
# $75 USD.<br/><br/>Supports only the `amount` request parameter.
|
22
|
+
#
|
23
|
+
class AuthorizationsReauthorizeRequest
|
24
|
+
attr_accessor :path, :body, :headers, :verb
|
25
|
+
|
26
|
+
def initialize(authorization_id)
|
27
|
+
@headers = {}
|
28
|
+
@body = nil
|
29
|
+
@verb = "POST"
|
30
|
+
@path = "/v2/payments/authorizations/{authorization_id}/reauthorize?"
|
31
|
+
|
32
|
+
@path = @path.gsub("{authorization_id}", CGI.escape(authorization_id.to_s))
|
33
|
+
@headers["Content-Type"] = "application/json"
|
34
|
+
end
|
35
|
+
|
36
|
+
def pay_pal_request_id(pay_pal_request_id)
|
37
|
+
@headers["PayPal-Request-Id"] = pay_pal_request_id
|
38
|
+
end
|
39
|
+
|
40
|
+
def prefer(prefer)
|
41
|
+
@headers["Prefer"] = prefer
|
42
|
+
end
|
43
|
+
|
44
|
+
def request_body(reauthorize_request)
|
45
|
+
@body = reauthorize_request
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/payments/captures_refund_request.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# frozen_string_literal :true
|
4
|
+
|
5
|
+
# This module was automatically generated from paypal_checkout_sdk 1.0.1
|
6
|
+
require 'cgi'
|
7
|
+
|
8
|
+
module SolidusPaypalCommercePlatform
|
9
|
+
module PayPalCheckoutSdk
|
10
|
+
module Payments
|
11
|
+
#
|
12
|
+
# Refunds a captured payment, by ID. For a full refund, include an
|
13
|
+
# empty payload in the JSON request body. For a partial refund,
|
14
|
+
# include an <code>amount</code> object in the JSON request body.
|
15
|
+
#
|
16
|
+
class CapturesRefundRequest
|
17
|
+
attr_accessor :path, :body, :headers, :verb
|
18
|
+
|
19
|
+
def initialize(capture_id)
|
20
|
+
@headers = {}
|
21
|
+
@body = nil
|
22
|
+
@verb = "POST"
|
23
|
+
@path = "/v2/payments/captures/{capture_id}/refund?"
|
24
|
+
|
25
|
+
@path = @path.gsub("{capture_id}", CGI.escape(capture_id.to_s))
|
26
|
+
@headers["Content-Type"] = "application/json"
|
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(refund_request)
|
38
|
+
@body = refund_request
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|