paypal-rest-api 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/README.md +21 -22
- data/VERSION +1 -1
- data/lib/paypal-api/{collection.rb → api_collection.rb} +2 -2
- data/lib/paypal-api/{collections → api_collections}/authentication.rb +1 -1
- data/lib/paypal-api/api_collections/authorized_payments.rb +70 -0
- data/lib/paypal-api/api_collections/captured_payments.rb +48 -0
- data/lib/paypal-api/api_collections/catalog_products.rb +70 -0
- data/lib/paypal-api/api_collections/orders.rb +120 -0
- data/lib/paypal-api/api_collections/refunds.rb +30 -0
- data/lib/paypal-api/api_collections/shipment_tracking.rb +59 -0
- data/lib/paypal-api/api_collections/subscriptions.rb +213 -0
- data/lib/paypal-api/api_collections/webhooks.rb +206 -0
- data/lib/paypal-api/client.rb +38 -30
- data/lib/paypal-api/error.rb +94 -67
- data/lib/paypal-api/failed_request_error_builder.rb +14 -14
- data/lib/paypal-api/network_error_builder.rb +2 -2
- data/lib/paypal-api/request.rb +21 -1
- data/lib/paypal-api/response.rb +5 -1
- data/lib/paypal-api.rb +47 -46
- metadata +12 -7
- data/lib/paypal-api/collections/orders.rb +0 -39
- data/lib/paypal-api/collections/payments.rb +0 -54
- data/lib/paypal-api/collections/webhooks.rb +0 -58
data/lib/paypal-api/error.rb
CHANGED
@@ -5,92 +5,119 @@ module PaypalAPI
|
|
5
5
|
# Common interface for all errors
|
6
6
|
#
|
7
7
|
class Error < StandardError
|
8
|
-
|
8
|
+
# @return [Response, nil] Returned response with non-200 status code
|
9
|
+
attr_reader :response
|
10
|
+
|
11
|
+
# @return [Request] Sent request
|
12
|
+
attr_reader :request
|
13
|
+
|
14
|
+
# @return [String] Error name provided by PayPal or Net::HTTP network error name
|
15
|
+
attr_reader :error_name
|
16
|
+
|
17
|
+
# @return [String] Error message provided by PayPal or Net::HTTP network error message
|
18
|
+
attr_reader :error_message
|
19
|
+
|
20
|
+
# @return [String, nil] Error debug_id returned by PayPal
|
21
|
+
attr_reader :error_debug_id
|
22
|
+
|
23
|
+
# @see https://developer.paypal.com/api/rest/responses/#link-examples
|
24
|
+
# @return [Array, nil] Error details returned by PayPal
|
25
|
+
attr_reader :error_details
|
26
|
+
|
27
|
+
# @return [String, nil] PayPal-Request-Id header assigned to request
|
28
|
+
attr_reader :paypal_request_id
|
9
29
|
end
|
10
30
|
|
11
31
|
#
|
12
|
-
#
|
32
|
+
# Namespace for specific PaypalAPI errors
|
13
33
|
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
34
|
+
module Errors
|
35
|
+
#
|
36
|
+
# Raised when PayPal responds with any status code except 200, 201, 202, 204
|
37
|
+
#
|
38
|
+
class FailedRequest < Error
|
39
|
+
def initialize(message = nil, request:, response:)
|
40
|
+
super(message)
|
41
|
+
@request = request
|
42
|
+
@response = response
|
43
|
+
|
44
|
+
body = response.body
|
45
|
+
data = body.is_a?(Hash) ? body : {}
|
46
|
+
@error_name = data[:name] || data[:error] || response.http_response.class.name
|
47
|
+
@error_message = data[:message] || data[:error_description] || response.http_body.to_s
|
48
|
+
@error_debug_id = data[:debug_id]
|
49
|
+
@error_details = data[:details]
|
50
|
+
@paypal_request_id = request.http_request["paypal-request-id"]
|
51
|
+
end
|
26
52
|
end
|
27
|
-
end
|
28
53
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
54
|
+
#
|
55
|
+
# Raised when a network raised when executing the request
|
56
|
+
# List of network errors can be found in errors/network_error_builder.rb
|
57
|
+
#
|
58
|
+
class NetworkError < Error
|
59
|
+
def initialize(message = nil, request:, error:)
|
60
|
+
super(message)
|
61
|
+
@request = request
|
62
|
+
@response = nil
|
63
|
+
@error_name = error.class.name
|
64
|
+
@error_message = error.message
|
65
|
+
@error_debug_id = nil
|
66
|
+
@error_details = nil
|
67
|
+
@paypal_request_id = request.http_request["paypal-request-id"]
|
68
|
+
end
|
42
69
|
end
|
43
|
-
end
|
44
70
|
|
45
|
-
|
46
|
-
|
47
|
-
|
71
|
+
# 400
|
72
|
+
class BadRequest < FailedRequest
|
73
|
+
end
|
48
74
|
|
49
|
-
|
50
|
-
|
51
|
-
|
75
|
+
# 401
|
76
|
+
class Unauthorized < FailedRequest
|
77
|
+
end
|
52
78
|
|
53
|
-
|
54
|
-
|
55
|
-
|
79
|
+
# 403
|
80
|
+
class Forbidden < FailedRequest
|
81
|
+
end
|
56
82
|
|
57
|
-
|
58
|
-
|
59
|
-
|
83
|
+
# 404
|
84
|
+
class NotFound < FailedRequest
|
85
|
+
end
|
60
86
|
|
61
|
-
|
62
|
-
|
63
|
-
|
87
|
+
# 405
|
88
|
+
class MethodNotAllowed < FailedRequest
|
89
|
+
end
|
64
90
|
|
65
|
-
|
66
|
-
|
67
|
-
|
91
|
+
# 406
|
92
|
+
class NotAcceptable < FailedRequest
|
93
|
+
end
|
68
94
|
|
69
|
-
|
70
|
-
|
71
|
-
|
95
|
+
# 409
|
96
|
+
class Conflict < FailedRequest
|
97
|
+
end
|
72
98
|
|
73
|
-
|
74
|
-
|
75
|
-
|
99
|
+
# 415
|
100
|
+
class UnsupportedMediaType < FailedRequest
|
101
|
+
end
|
76
102
|
|
77
|
-
|
78
|
-
|
79
|
-
|
103
|
+
# 422
|
104
|
+
class UnprocessableEntity < FailedRequest
|
105
|
+
end
|
80
106
|
|
81
|
-
|
82
|
-
|
83
|
-
|
107
|
+
# 429
|
108
|
+
class TooManyRequests < FailedRequest
|
109
|
+
end
|
84
110
|
|
85
|
-
|
86
|
-
|
87
|
-
|
111
|
+
# 5xx
|
112
|
+
class FatalError < FailedRequest
|
113
|
+
end
|
88
114
|
|
89
|
-
|
90
|
-
|
91
|
-
|
115
|
+
# 500
|
116
|
+
class InternalServerError < FatalError
|
117
|
+
end
|
92
118
|
|
93
|
-
|
94
|
-
|
119
|
+
# 503
|
120
|
+
class ServiceUnavailable < FatalError
|
121
|
+
end
|
95
122
|
end
|
96
123
|
end
|
@@ -9,18 +9,18 @@ module PaypalAPI
|
|
9
9
|
class FailedRequestErrorBuilder
|
10
10
|
# Matchings for Net::HTTP response class to PaypalAPI::Error class
|
11
11
|
RESPONSE_ERROR_MAP = {
|
12
|
-
Net::HTTPBadRequest =>
|
13
|
-
Net::HTTPUnauthorized =>
|
14
|
-
Net::HTTPForbidden =>
|
15
|
-
Net::HTTPNotFound =>
|
16
|
-
Net::HTTPMethodNotAllowed =>
|
17
|
-
Net::HTTPNotAcceptable =>
|
18
|
-
Net::HTTPConflict =>
|
19
|
-
Net::HTTPUnsupportedMediaType =>
|
20
|
-
Net::HTTPUnprocessableEntity =>
|
21
|
-
Net::HTTPTooManyRequests =>
|
22
|
-
Net::HTTPInternalServerError => InternalServerError,
|
23
|
-
Net::HTTPServiceUnavailable =>
|
12
|
+
Net::HTTPBadRequest => Errors::BadRequest, # 400
|
13
|
+
Net::HTTPUnauthorized => Errors::Unauthorized, # 401
|
14
|
+
Net::HTTPForbidden => Errors::Forbidden, # 403
|
15
|
+
Net::HTTPNotFound => Errors::NotFound, # 404
|
16
|
+
Net::HTTPMethodNotAllowed => Errors::MethodNotAllowed, # 405
|
17
|
+
Net::HTTPNotAcceptable => Errors::NotAcceptable, # 406
|
18
|
+
Net::HTTPConflict => Errors::Conflict, # 409
|
19
|
+
Net::HTTPUnsupportedMediaType => Errors::UnsupportedMediaType, # 415
|
20
|
+
Net::HTTPUnprocessableEntity => Errors::UnprocessableEntity, # 422
|
21
|
+
Net::HTTPTooManyRequests => Errors::TooManyRequests, # 429
|
22
|
+
Net::HTTPInternalServerError => Errors::InternalServerError, # 500
|
23
|
+
Net::HTTPServiceUnavailable => Errors::ServiceUnavailable # 503
|
24
24
|
}.freeze
|
25
25
|
|
26
26
|
class << self
|
@@ -29,12 +29,12 @@ module PaypalAPI
|
|
29
29
|
# @param request [Request] Original request
|
30
30
|
# @param response [Response] Original response
|
31
31
|
#
|
32
|
-
# @return [FailedRequestError]
|
32
|
+
# @return [Errors::FailedRequestError] error object
|
33
33
|
#
|
34
34
|
def call(request:, response:)
|
35
35
|
http_response = response.http_response
|
36
36
|
error_message = "#{http_response.code} #{http_response.message}"
|
37
|
-
error_class = RESPONSE_ERROR_MAP.fetch(http_response.class, FailedRequest)
|
37
|
+
error_class = RESPONSE_ERROR_MAP.fetch(http_response.class, Errors::FailedRequest)
|
38
38
|
error_class.new(error_message, response: response, request: request)
|
39
39
|
end
|
40
40
|
end
|
@@ -26,10 +26,10 @@ module PaypalAPI
|
|
26
26
|
# @param request [Request] Original request
|
27
27
|
# @param error [StandardError] Original error
|
28
28
|
#
|
29
|
-
# @return [NetworkError] Built NetworkError
|
29
|
+
# @return [Errors::NetworkError] Built NetworkError
|
30
30
|
#
|
31
31
|
def call(request:, error:)
|
32
|
-
NetworkError.new(error.message, request: request, error: error)
|
32
|
+
Errors::NetworkError.new(error.message, request: request, error: error)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/lib/paypal-api/request.rb
CHANGED
@@ -13,10 +13,30 @@ module PaypalAPI
|
|
13
13
|
# - assigns content-type header
|
14
14
|
#
|
15
15
|
class Request
|
16
|
-
|
16
|
+
# @return [Client] Current PaypalAPI Client
|
17
|
+
attr_reader :client
|
18
|
+
|
19
|
+
# @return [Net::HTTPRequest] Generated Net::HTTPRequest
|
20
|
+
attr_reader :http_request
|
21
|
+
|
22
|
+
# @return [Time, nil] Time when request was sent
|
17
23
|
attr_accessor :requested_at
|
18
24
|
|
19
25
|
# rubocop:disable Metrics/ParameterLists
|
26
|
+
|
27
|
+
# Initializes Request object
|
28
|
+
#
|
29
|
+
# @param client [Client] PaypalAPI client
|
30
|
+
# @param request_type [Class] One of: Net::HTTP::Post, Net::HTTP::Get,
|
31
|
+
# Net::HTTP::Put, Net::HTTP::Patch, Net::HTTP::Delete
|
32
|
+
# @param path [String] Request path
|
33
|
+
#
|
34
|
+
# @param query [Hash, nil] Request query
|
35
|
+
# @param body [Hash, nil] Request body
|
36
|
+
# @param headers [Hash, nil] Request headers
|
37
|
+
#
|
38
|
+
# @return [Request] Request object
|
39
|
+
#
|
20
40
|
def initialize(client, request_type, path, body: nil, query: nil, headers: nil)
|
21
41
|
@client = client
|
22
42
|
@http_request = build_http_request(request_type, path, body: body, query: query, headers: headers)
|
data/lib/paypal-api/response.rb
CHANGED
@@ -7,7 +7,11 @@ module PaypalAPI
|
|
7
7
|
# PaypalAPI::Response object
|
8
8
|
#
|
9
9
|
class Response
|
10
|
-
|
10
|
+
# @return [Net::HTTP::Response] Original Net::HTTP::Response object
|
11
|
+
attr_reader :http_response
|
12
|
+
|
13
|
+
# @return [Time] Time when request was sent
|
14
|
+
attr_reader :requested_at
|
11
15
|
|
12
16
|
#
|
13
17
|
# Initializes Response object
|
data/lib/paypal-api.rb
CHANGED
@@ -20,9 +20,7 @@ module PaypalAPI
|
|
20
20
|
# Sets client
|
21
21
|
attr_writer :client
|
22
22
|
|
23
|
-
# @!
|
24
|
-
#
|
25
|
-
# Executes POST http request
|
23
|
+
# @!macro [new] request
|
26
24
|
#
|
27
25
|
# @param path [String] Request path
|
28
26
|
# @param query [Hash, nil] Request query parameters
|
@@ -31,53 +29,31 @@ module PaypalAPI
|
|
31
29
|
#
|
32
30
|
# @return [Response] Response object
|
33
31
|
#
|
32
|
+
|
33
|
+
# @!method post(path, query: nil, body: nil, headers: nil)
|
34
34
|
#
|
35
|
-
#
|
35
|
+
# Executes POST http request
|
36
|
+
# @macro request
|
36
37
|
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
# @param path [String] Request path
|
40
|
-
# @param query [Hash, nil] Request query parameters
|
41
|
-
# @param body [Hash, nil] Request body parameters
|
42
|
-
# @param headers [Hash, nil] Request headers
|
43
|
-
#
|
44
|
-
# @return [Response] Response object
|
38
|
+
# @!method get(path, query: nil, body: nil, headers: nil)
|
45
39
|
#
|
40
|
+
# Executes GET http request
|
41
|
+
# @macro request
|
46
42
|
#
|
47
|
-
# @!method patch
|
43
|
+
# @!method patch(path, query: nil, body: nil, headers: nil)
|
48
44
|
#
|
49
45
|
# Executes PATCH http request
|
46
|
+
# @macro request
|
50
47
|
#
|
51
|
-
#
|
52
|
-
# @param query [Hash, nil] Request query parameters
|
53
|
-
# @param body [Hash, nil] Request body parameters
|
54
|
-
# @param headers [Hash, nil] Request headers
|
55
|
-
#
|
56
|
-
# @return [Response] Response object
|
57
|
-
#
|
58
|
-
#
|
59
|
-
# @!method put
|
48
|
+
# @!method put(path, query: nil, body: nil, headers: nil)
|
60
49
|
#
|
61
50
|
# Executes PUT http request
|
62
|
-
#
|
63
|
-
# @param path [String] Request path
|
64
|
-
# @param query [Hash, nil] Request query parameters
|
65
|
-
# @param body [Hash, nil] Request body parameters
|
66
|
-
# @param headers [Hash, nil] Request headers
|
67
|
-
#
|
68
|
-
# @return [Response] Response object
|
69
|
-
#
|
51
|
+
# @macro request
|
70
52
|
|
71
|
-
# @!method delete
|
53
|
+
# @!method delete(path, query: nil, body: nil, headers: nil)
|
72
54
|
#
|
73
55
|
# Executes DELETE http request
|
74
|
-
#
|
75
|
-
# @param path [String] Request path
|
76
|
-
# @param query [Hash, nil] Request query parameters
|
77
|
-
# @param body [Hash, nil] Request body parameters
|
78
|
-
# @param headers [Hash, nil] Request headers
|
79
|
-
#
|
80
|
-
# @return [Response] Response object
|
56
|
+
# @macro request
|
81
57
|
#
|
82
58
|
[:post, :get, :patch, :put, :delete].each do |method_name|
|
83
59
|
define_method(method_name) do |path, query: nil, body: nil, headers: nil|
|
@@ -89,19 +65,39 @@ module PaypalAPI
|
|
89
65
|
# @!method authentication
|
90
66
|
# @return [Authentication]
|
91
67
|
#
|
68
|
+
# @!method authorized_payments
|
69
|
+
# @return [AuthorizedPayments]
|
70
|
+
#
|
71
|
+
# @!method captured_payments
|
72
|
+
# @return [CapturedPayments]
|
73
|
+
#
|
74
|
+
# @!method catalog_products
|
75
|
+
# @return [CatalogProducts]
|
76
|
+
#
|
92
77
|
# @!method orders
|
93
78
|
# @return [Orders]
|
94
79
|
#
|
95
|
-
# @!method
|
96
|
-
# @return [
|
80
|
+
# @!method refunds
|
81
|
+
# @return [Refunds]
|
82
|
+
#
|
83
|
+
# @!method shipment_tracking
|
84
|
+
# @return [ShipmentTracking]
|
85
|
+
#
|
86
|
+
# @!method subscriptions
|
87
|
+
# @return [Subscriptions]
|
97
88
|
#
|
98
89
|
# @!method webhooks
|
99
90
|
# @return [Webhooks]
|
100
91
|
#
|
101
92
|
%i[
|
102
93
|
authentication
|
94
|
+
authorized_payments
|
95
|
+
captured_payments
|
96
|
+
catalog_products
|
103
97
|
orders
|
104
|
-
|
98
|
+
refunds
|
99
|
+
shipment_tracking
|
100
|
+
subscriptions
|
105
101
|
webhooks
|
106
102
|
].each do |method_name|
|
107
103
|
define_method(method_name) do
|
@@ -119,8 +115,8 @@ module PaypalAPI
|
|
119
115
|
end
|
120
116
|
|
121
117
|
require_relative "paypal-api/access_token"
|
118
|
+
require_relative "paypal-api/api_collection"
|
122
119
|
require_relative "paypal-api/client"
|
123
|
-
require_relative "paypal-api/collection"
|
124
120
|
require_relative "paypal-api/config"
|
125
121
|
require_relative "paypal-api/error"
|
126
122
|
require_relative "paypal-api/failed_request_error_builder"
|
@@ -128,7 +124,12 @@ require_relative "paypal-api/network_error_builder"
|
|
128
124
|
require_relative "paypal-api/request"
|
129
125
|
require_relative "paypal-api/request_executor"
|
130
126
|
require_relative "paypal-api/response"
|
131
|
-
require_relative "paypal-api/
|
132
|
-
require_relative "paypal-api/
|
133
|
-
require_relative "paypal-api/
|
134
|
-
require_relative "paypal-api/
|
127
|
+
require_relative "paypal-api/api_collections/authentication"
|
128
|
+
require_relative "paypal-api/api_collections/authorized_payments"
|
129
|
+
require_relative "paypal-api/api_collections/captured_payments"
|
130
|
+
require_relative "paypal-api/api_collections/catalog_products"
|
131
|
+
require_relative "paypal-api/api_collections/orders"
|
132
|
+
require_relative "paypal-api/api_collections/refunds"
|
133
|
+
require_relative "paypal-api/api_collections/shipment_tracking"
|
134
|
+
require_relative "paypal-api/api_collections/subscriptions"
|
135
|
+
require_relative "paypal-api/api_collections/webhooks"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paypal-rest-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Glushkov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: PayPal REST API with no dependencies.
|
14
14
|
email:
|
@@ -21,12 +21,17 @@ files:
|
|
21
21
|
- VERSION
|
22
22
|
- lib/paypal-api.rb
|
23
23
|
- lib/paypal-api/access_token.rb
|
24
|
+
- lib/paypal-api/api_collection.rb
|
25
|
+
- lib/paypal-api/api_collections/authentication.rb
|
26
|
+
- lib/paypal-api/api_collections/authorized_payments.rb
|
27
|
+
- lib/paypal-api/api_collections/captured_payments.rb
|
28
|
+
- lib/paypal-api/api_collections/catalog_products.rb
|
29
|
+
- lib/paypal-api/api_collections/orders.rb
|
30
|
+
- lib/paypal-api/api_collections/refunds.rb
|
31
|
+
- lib/paypal-api/api_collections/shipment_tracking.rb
|
32
|
+
- lib/paypal-api/api_collections/subscriptions.rb
|
33
|
+
- lib/paypal-api/api_collections/webhooks.rb
|
24
34
|
- lib/paypal-api/client.rb
|
25
|
-
- lib/paypal-api/collection.rb
|
26
|
-
- lib/paypal-api/collections/authentication.rb
|
27
|
-
- lib/paypal-api/collections/orders.rb
|
28
|
-
- lib/paypal-api/collections/payments.rb
|
29
|
-
- lib/paypal-api/collections/webhooks.rb
|
30
35
|
- lib/paypal-api/config.rb
|
31
36
|
- lib/paypal-api/error.rb
|
32
37
|
- lib/paypal-api/failed_request_error_builder.rb
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module PaypalAPI
|
4
|
-
#
|
5
|
-
# Create, update, retrieve, authorize, and capture orders.
|
6
|
-
#
|
7
|
-
# https://developer.paypal.com/docs/api/orders/v2/
|
8
|
-
#
|
9
|
-
class Orders < Collection
|
10
|
-
#
|
11
|
-
# Common class and instance methods
|
12
|
-
#
|
13
|
-
module APIs
|
14
|
-
#
|
15
|
-
# @see https://developer.paypal.com/docs/api/orders/v2/#orders_authorize
|
16
|
-
#
|
17
|
-
def authorize(id, query: nil, body: nil, headers: nil)
|
18
|
-
client.post("/v2/checkout/orders/#{id}/authorize", query: query, body: body, headers: headers)
|
19
|
-
end
|
20
|
-
|
21
|
-
#
|
22
|
-
# @see https://developer.paypal.com/docs/api/orders/v2/#orders_create
|
23
|
-
#
|
24
|
-
def create(query: nil, body: nil, headers: nil)
|
25
|
-
client.post("/v2/checkout/orders", query: query, body: body, headers: headers)
|
26
|
-
end
|
27
|
-
|
28
|
-
#
|
29
|
-
# @see https://developer.paypal.com/docs/api/orders/v2/#orders_get
|
30
|
-
#
|
31
|
-
def show(id, query: nil, body: nil, headers: nil)
|
32
|
-
client.get("/v2/checkout/orders/#{id}", query: query, body: body, headers: headers)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
include APIs
|
37
|
-
extend APIs
|
38
|
-
end
|
39
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module PaypalAPI
|
4
|
-
#
|
5
|
-
# Use in conjunction with the Orders API to authorize payments, capture authorized payments,
|
6
|
-
# refund payments that have already been captured, and show payment information.
|
7
|
-
#
|
8
|
-
# https://developer.paypal.com/docs/api/payments/v2
|
9
|
-
#
|
10
|
-
class Payments < Collection
|
11
|
-
#
|
12
|
-
# Common class and instance methods
|
13
|
-
#
|
14
|
-
module APIs
|
15
|
-
#
|
16
|
-
# @see https://developer.paypal.com/docs/api/payments/v2/#authorizations_capture
|
17
|
-
#
|
18
|
-
def capture(authorization_id, query: nil, body: nil, headers: nil)
|
19
|
-
client.post("/v2/payments/authorizations/#{authorization_id}/capture", query: query, body: body, headers: headers)
|
20
|
-
end
|
21
|
-
|
22
|
-
#
|
23
|
-
# @see https://developer.paypal.com/docs/api/payments/v2/#captures_refund
|
24
|
-
#
|
25
|
-
def refund(capture_id, query: nil, body: nil, headers: nil)
|
26
|
-
client.post("/v2/payments/captures/#{capture_id}/refund", query: query, body: body, headers: headers)
|
27
|
-
end
|
28
|
-
|
29
|
-
#
|
30
|
-
# @see https://developer.paypal.com/docs/api/payments/v2/#authorizations_get
|
31
|
-
#
|
32
|
-
def show_authorized(authorization_id, query: nil, body: nil, headers: nil)
|
33
|
-
client.get("/v2/payments/authorizations/#{authorization_id}", query: query, body: body, headers: headers)
|
34
|
-
end
|
35
|
-
|
36
|
-
#
|
37
|
-
# @see https://developer.paypal.com/docs/api/payments/v2/#captures_get
|
38
|
-
#
|
39
|
-
def show_captured(capture_id, query: nil, body: nil, headers: nil)
|
40
|
-
client.get("/v2/payments/captures/#{capture_id}", query: query, body: body, headers: headers)
|
41
|
-
end
|
42
|
-
|
43
|
-
#
|
44
|
-
# @see https://developer.paypal.com/docs/api/payments/v2/#authorizations_void
|
45
|
-
#
|
46
|
-
def void(authorization_id, query: nil, body: nil, headers: nil)
|
47
|
-
client.post("/v2/payments/authorizations/#{authorization_id}/void", query: query, body: body, headers: headers)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
include APIs
|
52
|
-
extend APIs
|
53
|
-
end
|
54
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module PaypalAPI
|
4
|
-
#
|
5
|
-
# https://developer.paypal.com/docs/api/webhooks/v1/
|
6
|
-
#
|
7
|
-
class Webhooks < Collection
|
8
|
-
#
|
9
|
-
# Common class and instance methods
|
10
|
-
#
|
11
|
-
module APIs
|
12
|
-
#
|
13
|
-
# @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks_post
|
14
|
-
#
|
15
|
-
def create(query: nil, body: nil, headers: nil)
|
16
|
-
client.post("/v1/notifications/webhooks", query: query, body: body, headers: headers)
|
17
|
-
end
|
18
|
-
|
19
|
-
#
|
20
|
-
# @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks_delete
|
21
|
-
#
|
22
|
-
def delete(webhook_id, query: nil, body: nil, headers: nil)
|
23
|
-
client.delete("/v1/notifications/webhooks/#{webhook_id}", query: query, body: body, headers: headers)
|
24
|
-
end
|
25
|
-
|
26
|
-
#
|
27
|
-
# @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks_list
|
28
|
-
#
|
29
|
-
def list(query: nil, body: nil, headers: nil)
|
30
|
-
client.get("/v1/notifications/webhooks", query: query, body: body, headers: headers)
|
31
|
-
end
|
32
|
-
|
33
|
-
#
|
34
|
-
# @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks_get
|
35
|
-
#
|
36
|
-
def show(webhook_id, query: nil, body: nil, headers: nil)
|
37
|
-
client.get("/v1/notifications/webhooks/#{webhook_id}", query: query, body: body, headers: headers)
|
38
|
-
end
|
39
|
-
|
40
|
-
#
|
41
|
-
# @see https://developer.paypal.com/docs/api/webhooks/v1/#webhooks_update
|
42
|
-
#
|
43
|
-
def update(webhook_id, query: nil, body: nil, headers: nil)
|
44
|
-
client.patch("/v1/notifications/webhooks/#{webhook_id}", query: query, body: body, headers: headers)
|
45
|
-
end
|
46
|
-
|
47
|
-
#
|
48
|
-
# @see https://developer.paypal.com/docs/api/webhooks/v1/#verify-webhook-signature_post
|
49
|
-
#
|
50
|
-
def verify(query: nil, body: nil, headers: nil)
|
51
|
-
client.post("/v1/notifications/verify-webhook-signature", query: query, body: body, headers: headers)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
include APIs
|
56
|
-
extend APIs
|
57
|
-
end
|
58
|
-
end
|