abacatepay-ruby 0.1.0 → 1.0.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +125 -0
- data/CHANGELOG.md +121 -1
- data/README.md +408 -87
- data/Rakefile +1 -1
- data/abacatepay-ruby.gemspec +16 -10
- data/lib/abacate_pay/clients/billing_client.rb +80 -0
- data/lib/abacate_pay/clients/checkout_client.rb +70 -0
- data/lib/{abacatepay → abacate_pay}/clients/client.rb +20 -7
- data/lib/abacate_pay/clients/coupon_client.rb +57 -0
- data/lib/abacate_pay/clients/customer_client.rb +58 -0
- data/lib/abacate_pay/clients/payment_link_client.rb +71 -0
- data/lib/abacate_pay/clients/payout_client.rb +41 -0
- data/lib/abacate_pay/clients/pix_client.rb +47 -0
- data/lib/abacate_pay/clients/product_client.rb +54 -0
- data/lib/abacate_pay/clients/store_client.rb +40 -0
- data/lib/abacate_pay/clients/subscription_client.rb +55 -0
- data/lib/abacate_pay/clients/transparent_client.rb +73 -0
- data/lib/abacate_pay/clients/webhook_client.rb +82 -0
- data/lib/abacate_pay/clients.rb +24 -0
- data/lib/abacate_pay/configuration.rb +67 -0
- data/lib/{abacatepay/enums/billing → abacate_pay/enums/billings}/frequencies.rb +9 -3
- data/lib/{abacatepay/enums/billing → abacate_pay/enums/billings}/methods.rb +5 -3
- data/lib/{abacatepay/enums/billing → abacate_pay/enums/billings}/statuses.rb +3 -2
- data/lib/abacate_pay/enums/checkouts/statuses.rb +29 -0
- data/lib/abacate_pay/enums/coupons/discount_kinds.rb +26 -0
- data/lib/abacate_pay/enums/coupons/statuses.rb +27 -0
- data/lib/abacate_pay/enums/payouts/statuses.rb +29 -0
- data/lib/abacate_pay/enums/pix/key_types.rb +30 -0
- data/lib/abacate_pay/enums/products/cycles.rb +28 -0
- data/lib/abacate_pay/enums/transfers/statuses.rb +30 -0
- data/lib/abacate_pay/enums/webhooks/event_types.rb +43 -0
- data/lib/abacate_pay/enums.rb +20 -0
- data/lib/{abacatepay/resources/billing → abacate_pay/resources/billings}/metadata.rb +2 -8
- data/lib/{abacatepay/resources/billing → abacate_pay/resources/billings}/product.rb +2 -8
- data/lib/{abacatepay/resources/billing.rb → abacate_pay/resources/billings.rb} +16 -16
- data/lib/abacate_pay/resources/checkouts.rb +76 -0
- data/lib/abacate_pay/resources/coupons.rb +41 -0
- data/lib/{abacatepay/resources/customer → abacate_pay/resources/customers}/metadata.rb +2 -8
- data/lib/{abacatepay/resources/customer.rb → abacate_pay/resources/customers.rb} +5 -5
- data/lib/abacate_pay/resources/payouts.rb +40 -0
- data/lib/abacate_pay/resources/pix_transfers.rb +41 -0
- data/lib/abacate_pay/resources/products.rb +40 -0
- data/lib/{abacatepay → abacate_pay}/resources/resource.rb +33 -21
- data/lib/abacate_pay/resources/store/balance.rb +20 -0
- data/lib/abacate_pay/resources/store.rb +36 -0
- data/lib/abacate_pay/resources/subscriptions.rb +72 -0
- data/lib/abacate_pay/resources/transparents.rb +46 -0
- data/lib/abacate_pay/resources/webhook_endpoints.rb +49 -0
- data/lib/abacate_pay/resources.rb +27 -0
- data/lib/{abacatepay → abacate_pay}/version.rb +2 -2
- data/lib/abacate_pay/webhooks/event.rb +20 -0
- data/lib/abacate_pay/webhooks.rb +100 -0
- data/lib/abacate_pay.rb +111 -4
- metadata +69 -56
- data/lib/abacatepay/clients/billing_client.rb +0 -60
- data/lib/abacatepay/clients/customer_client.rb +0 -39
- data/lib/abacatepay/clients.rb +0 -12
- data/lib/abacatepay/configuration.rb +0 -56
- data/lib/abacatepay/enums.rb +0 -12
- data/lib/abacatepay/resources.rb +0 -15
- data/sig/abacatepay/rails.rbs +0 -6
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AbacatePay
|
|
4
|
+
module Resources
|
|
5
|
+
# Represents a registered webhook endpoint in the AbacatePay system.
|
|
6
|
+
#
|
|
7
|
+
# This is the endpoint *registration* — the URL AbacatePay delivers events
|
|
8
|
+
# to. For verifying and parsing an inbound delivery, see {AbacatePay::Webhooks}.
|
|
9
|
+
class WebhookEndpoints < Resource
|
|
10
|
+
# @return [String, nil] Webhook ID
|
|
11
|
+
attr_accessor :id
|
|
12
|
+
|
|
13
|
+
# @return [String, nil] Identifying name
|
|
14
|
+
attr_accessor :name
|
|
15
|
+
|
|
16
|
+
# @return [String, nil] HTTPS URL that receives the events
|
|
17
|
+
attr_accessor :endpoint
|
|
18
|
+
|
|
19
|
+
# @return [Array<String>, nil] Event types this endpoint subscribes to
|
|
20
|
+
attr_accessor :events
|
|
21
|
+
|
|
22
|
+
# @return [Boolean, nil] Whether the endpoint is active
|
|
23
|
+
attr_accessor :active
|
|
24
|
+
|
|
25
|
+
# @return [DateTime, nil] Creation timestamp
|
|
26
|
+
attr_accessor :created_at
|
|
27
|
+
|
|
28
|
+
# @return [DateTime, nil] Last update timestamp
|
|
29
|
+
attr_accessor :updated_at
|
|
30
|
+
|
|
31
|
+
# @param data [Hash] The webhook properties
|
|
32
|
+
def initialize(data)
|
|
33
|
+
fill(data)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
# @param property [String] The property name
|
|
39
|
+
# @param value [Object] The raw value
|
|
40
|
+
# @return [Object] The processed value
|
|
41
|
+
def process_value(property, value)
|
|
42
|
+
case property
|
|
43
|
+
when "created_at", "updated_at" then initialize_date_time(value)
|
|
44
|
+
else value
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Resource must load first — every other resource inherits from it.
|
|
4
|
+
require "abacate_pay/resources/resource"
|
|
5
|
+
|
|
6
|
+
require "abacate_pay/resources/billings"
|
|
7
|
+
require "abacate_pay/resources/billings/metadata"
|
|
8
|
+
require "abacate_pay/resources/billings/product"
|
|
9
|
+
require "abacate_pay/resources/checkouts"
|
|
10
|
+
require "abacate_pay/resources/coupons"
|
|
11
|
+
require "abacate_pay/resources/customers"
|
|
12
|
+
require "abacate_pay/resources/customers/metadata"
|
|
13
|
+
require "abacate_pay/resources/payouts"
|
|
14
|
+
require "abacate_pay/resources/pix_transfers"
|
|
15
|
+
require "abacate_pay/resources/products"
|
|
16
|
+
require "abacate_pay/resources/store"
|
|
17
|
+
require "abacate_pay/resources/store/balance"
|
|
18
|
+
require "abacate_pay/resources/subscriptions"
|
|
19
|
+
require "abacate_pay/resources/transparents"
|
|
20
|
+
require "abacate_pay/resources/webhook_endpoints"
|
|
21
|
+
|
|
22
|
+
module AbacatePay
|
|
23
|
+
# The Resources module contains all resource classes that
|
|
24
|
+
# represent the various entities in the AbacatePay system.
|
|
25
|
+
module Resources
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AbacatePay
|
|
4
|
+
module Webhooks
|
|
5
|
+
# A parsed webhook event.
|
|
6
|
+
#
|
|
7
|
+
# Accepts both the camelCase and snake_case spellings AbacatePay has used
|
|
8
|
+
# for the envelope fields, so older and newer webhook versions both parse.
|
|
9
|
+
class Event
|
|
10
|
+
attr_reader :type, :data, :created_at
|
|
11
|
+
|
|
12
|
+
# @param data [Hash] Parsed webhook payload
|
|
13
|
+
def initialize(data)
|
|
14
|
+
@type = data["event"] || data["type"]
|
|
15
|
+
@data = data["data"]
|
|
16
|
+
@created_at = data["createdAt"] || data["created_at"]
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "openssl"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module AbacatePay
|
|
7
|
+
# Verification and parsing of inbound AbacatePay webhooks.
|
|
8
|
+
#
|
|
9
|
+
# Webhook bodies are the least trusted input an integration handles: they
|
|
10
|
+
# arrive unauthenticated on a public endpoint. Every entry point here treats
|
|
11
|
+
# missing, malformed, and hostile input as an expected case and surfaces it
|
|
12
|
+
# as a typed SDK error, never as a raw parser or NoMethodError.
|
|
13
|
+
module Webhooks
|
|
14
|
+
# Raised when a webhook signature is missing, malformed, or does not match.
|
|
15
|
+
class SignatureError < AbacatePay::Error; end
|
|
16
|
+
|
|
17
|
+
# Raised when a webhook body is not a JSON object the SDK can interpret.
|
|
18
|
+
class PayloadError < AbacatePay::Error; end
|
|
19
|
+
|
|
20
|
+
# Verifies a webhook signature using HMAC-SHA256.
|
|
21
|
+
#
|
|
22
|
+
# @param payload [String] The raw request body
|
|
23
|
+
# @param signature [String] The X-Webhook-Signature header value
|
|
24
|
+
# @param secret [String] Your webhook secret/public key
|
|
25
|
+
# @return [true] if signature is valid
|
|
26
|
+
# @raise [SignatureError] if the signature is missing or invalid
|
|
27
|
+
def self.verify!(payload:, signature:, secret:)
|
|
28
|
+
raise SignatureError, "Missing webhook signature" if signature.nil? || signature.to_s.empty?
|
|
29
|
+
raise SignatureError, "Missing webhook secret" if secret.nil? || secret.to_s.empty?
|
|
30
|
+
|
|
31
|
+
expected = OpenSSL::HMAC.hexdigest("SHA256", secret.to_s, payload.to_s)
|
|
32
|
+
raise SignatureError, "Invalid webhook signature" unless secure_compare(expected, signature.to_s)
|
|
33
|
+
|
|
34
|
+
true
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Checks if a webhook signature is valid.
|
|
38
|
+
#
|
|
39
|
+
# Never raises for untrusted input — a missing header, an empty secret, or a
|
|
40
|
+
# forged signature all return false.
|
|
41
|
+
#
|
|
42
|
+
# @param payload [String] The raw request body
|
|
43
|
+
# @param signature [String] The X-Webhook-Signature header value
|
|
44
|
+
# @param secret [String] Your webhook secret/public key
|
|
45
|
+
# @return [Boolean]
|
|
46
|
+
def self.valid?(payload:, signature:, secret:)
|
|
47
|
+
verify!(payload: payload, signature: signature, secret: secret)
|
|
48
|
+
true
|
|
49
|
+
rescue SignatureError
|
|
50
|
+
false
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Parses a webhook payload into an Event object.
|
|
54
|
+
#
|
|
55
|
+
# Prefer {construct_event}, which refuses to parse a body it has not
|
|
56
|
+
# authenticated first.
|
|
57
|
+
#
|
|
58
|
+
# @param payload [String] The raw JSON request body
|
|
59
|
+
# @return [Event] The parsed event
|
|
60
|
+
# @raise [PayloadError] if the body is not a JSON object
|
|
61
|
+
def self.parse(payload)
|
|
62
|
+
data = JSON.parse(payload.to_s)
|
|
63
|
+
raise PayloadError, "Expected a JSON object, got #{data.class}" unless data.is_a?(Hash)
|
|
64
|
+
|
|
65
|
+
Event.new(data)
|
|
66
|
+
rescue JSON::ParserError => e
|
|
67
|
+
raise PayloadError, "Malformed webhook payload: #{e.message}"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Verifies a webhook signature and parses the body in one step.
|
|
71
|
+
#
|
|
72
|
+
# This is the only entry point that cannot be used to act on an
|
|
73
|
+
# unauthenticated payload, and is what integrations should call.
|
|
74
|
+
#
|
|
75
|
+
# @param payload [String] The raw request body
|
|
76
|
+
# @param signature [String] The X-Webhook-Signature header value
|
|
77
|
+
# @param secret [String] Your webhook secret/public key
|
|
78
|
+
# @return [Event] The verified, parsed event
|
|
79
|
+
# @raise [SignatureError] if the signature is missing or invalid
|
|
80
|
+
# @raise [PayloadError] if the body is not a JSON object
|
|
81
|
+
def self.construct_event(payload:, signature:, secret:)
|
|
82
|
+
verify!(payload: payload, signature: signature, secret: secret)
|
|
83
|
+
parse(payload)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Constant-time comparison to prevent timing attacks.
|
|
87
|
+
#
|
|
88
|
+
# @param expected [String] The signature computed from the payload
|
|
89
|
+
# @param actual [String] The signature supplied by the caller
|
|
90
|
+
# @return [Boolean]
|
|
91
|
+
def self.secure_compare(expected, actual)
|
|
92
|
+
return false unless expected.bytesize == actual.bytesize
|
|
93
|
+
|
|
94
|
+
OpenSSL.fixed_length_secure_compare(expected, actual)
|
|
95
|
+
end
|
|
96
|
+
private_class_method :secure_compare
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
require "abacate_pay/webhooks/event"
|
data/lib/abacate_pay.rb
CHANGED
|
@@ -10,12 +10,26 @@ module AbacatePay
|
|
|
10
10
|
class ApiError < Error; end
|
|
11
11
|
|
|
12
12
|
class << self
|
|
13
|
-
#
|
|
14
|
-
|
|
13
|
+
# @return [Configuration, nil] The global configuration
|
|
14
|
+
attr_reader :configuration
|
|
15
|
+
|
|
16
|
+
# Replacing the configuration invalidates every memoized client, so a
|
|
17
|
+
# client built against the previous credentials can never outlive them.
|
|
18
|
+
#
|
|
19
|
+
# @param value [Configuration, nil] The new configuration
|
|
20
|
+
# @return [void]
|
|
21
|
+
def configuration=(value)
|
|
22
|
+
@configuration = value
|
|
23
|
+
reset_clients!
|
|
24
|
+
end
|
|
15
25
|
end
|
|
16
26
|
|
|
17
27
|
# Configures the SDK
|
|
18
28
|
#
|
|
29
|
+
# Memoized clients are discarded so a token changed at runtime takes effect
|
|
30
|
+
# immediately. Without this, a client built before the change keeps sending
|
|
31
|
+
# the old bearer token.
|
|
32
|
+
#
|
|
19
33
|
# @example
|
|
20
34
|
# AbacatePay.configure do |config|
|
|
21
35
|
# config.api_token = "your-token-here"
|
|
@@ -28,6 +42,7 @@ module AbacatePay
|
|
|
28
42
|
self.configuration ||= Configuration.new
|
|
29
43
|
yield(configuration)
|
|
30
44
|
configuration.validate!
|
|
45
|
+
reset_clients!
|
|
31
46
|
end
|
|
32
47
|
|
|
33
48
|
# Resets the configuration to defaults
|
|
@@ -35,8 +50,100 @@ module AbacatePay
|
|
|
35
50
|
# @return [void]
|
|
36
51
|
def self.reset!
|
|
37
52
|
self.configuration = Configuration.new
|
|
53
|
+
reset_clients!
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Returns the configuration, refusing to proceed if the SDK was never set up.
|
|
57
|
+
#
|
|
58
|
+
# Forgetting to call {configure} is the most common first-run mistake; without
|
|
59
|
+
# this the failure surfaces as `NoMethodError: undefined method 'api_url' for
|
|
60
|
+
# nil` from deep inside the client.
|
|
61
|
+
#
|
|
62
|
+
# @return [Configuration] The active configuration
|
|
63
|
+
# @raise [ConfigurationError] if {configure} has not been called
|
|
64
|
+
def self.configuration!
|
|
65
|
+
configuration || raise(
|
|
66
|
+
ConfigurationError,
|
|
67
|
+
"AbacatePay is not configured. Call AbacatePay.configure { |c| c.api_token = ENV['ABACATEPAY_API_KEY'] } first."
|
|
68
|
+
)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Discards every memoized client so the next call rebuilds from current config
|
|
72
|
+
#
|
|
73
|
+
# @return [void]
|
|
74
|
+
def self.reset_clients!
|
|
75
|
+
@clients = {}
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# @return [Hash{Symbol => Clients::Client}] Memoized clients, keyed by name
|
|
79
|
+
def self.clients
|
|
80
|
+
@clients ||= {}
|
|
81
|
+
end
|
|
82
|
+
private_class_method :clients
|
|
83
|
+
|
|
84
|
+
# @return [Clients::CustomerClient] Customer API client
|
|
85
|
+
def self.customers
|
|
86
|
+
clients[:customers] ||= Clients::CustomerClient.new
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# @return [Clients::ProductClient] Product API client
|
|
90
|
+
def self.products
|
|
91
|
+
clients[:products] ||= Clients::ProductClient.new
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# @return [Clients::CouponClient] Coupon API client
|
|
95
|
+
def self.coupons
|
|
96
|
+
clients[:coupons] ||= Clients::CouponClient.new
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# @return [Clients::CheckoutClient] Checkout API client
|
|
100
|
+
def self.checkouts
|
|
101
|
+
clients[:checkouts] ||= Clients::CheckoutClient.new
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# @return [Clients::SubscriptionClient] Subscription API client
|
|
105
|
+
def self.subscriptions
|
|
106
|
+
clients[:subscriptions] ||= Clients::SubscriptionClient.new
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# @return [Clients::TransparentClient] PIX Transparent API client
|
|
110
|
+
def self.transparents
|
|
111
|
+
clients[:transparents] ||= Clients::TransparentClient.new
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# @return [Clients::PixClient] PIX Transfer API client
|
|
115
|
+
def self.pix
|
|
116
|
+
clients[:pix] ||= Clients::PixClient.new
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# @return [Clients::PayoutClient] Payout API client
|
|
120
|
+
def self.payouts
|
|
121
|
+
clients[:payouts] ||= Clients::PayoutClient.new
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# @return [Clients::StoreClient] Store API client
|
|
125
|
+
def self.store
|
|
126
|
+
clients[:store] ||= Clients::StoreClient.new
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# @return [Clients::PaymentLinkClient] Reusable payment link API client
|
|
130
|
+
def self.payment_links
|
|
131
|
+
clients[:payment_links] ||= Clients::PaymentLinkClient.new
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Webhook *endpoint registration*. To verify an inbound delivery, use
|
|
135
|
+
# {AbacatePay::Webhooks.construct_event}.
|
|
136
|
+
#
|
|
137
|
+
# @return [Clients::WebhookClient] Webhook management API client
|
|
138
|
+
def self.webhook_endpoints
|
|
139
|
+
clients[:webhook_endpoints] ||= Clients::WebhookClient.new
|
|
38
140
|
end
|
|
39
141
|
end
|
|
40
142
|
|
|
41
|
-
#
|
|
42
|
-
|
|
143
|
+
# Components are required explicitly, in dependency order. A glob would load
|
|
144
|
+
# clients/billing_client.rb before clients/client.rb and blow up on the
|
|
145
|
+
# superclass, and it silently swallows files that were never wired up.
|
|
146
|
+
require "abacate_pay/enums"
|
|
147
|
+
require "abacate_pay/resources"
|
|
148
|
+
require "abacate_pay/clients"
|
|
149
|
+
require "abacate_pay/webhooks"
|
metadata
CHANGED
|
@@ -1,63 +1,62 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: abacatepay-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matheus Cardoso
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
13
|
+
name: faraday
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
16
|
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
18
|
+
version: '2.14'
|
|
20
19
|
- - ">="
|
|
21
20
|
- !ruby/object:Gem::Version
|
|
22
|
-
version:
|
|
21
|
+
version: 2.14.3
|
|
23
22
|
type: :runtime
|
|
24
23
|
prerelease: false
|
|
25
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
25
|
requirements:
|
|
27
26
|
- - "~>"
|
|
28
27
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: '
|
|
28
|
+
version: '2.14'
|
|
30
29
|
- - ">="
|
|
31
30
|
- !ruby/object:Gem::Version
|
|
32
|
-
version:
|
|
31
|
+
version: 2.14.3
|
|
33
32
|
- !ruby/object:Gem::Dependency
|
|
34
|
-
name:
|
|
33
|
+
name: bundler-audit
|
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
|
36
35
|
requirements:
|
|
37
36
|
- - "~>"
|
|
38
37
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '
|
|
40
|
-
type: :
|
|
38
|
+
version: '0.9'
|
|
39
|
+
type: :development
|
|
41
40
|
prerelease: false
|
|
42
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
43
42
|
requirements:
|
|
44
43
|
- - "~>"
|
|
45
44
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '
|
|
45
|
+
version: '0.9'
|
|
47
46
|
- !ruby/object:Gem::Dependency
|
|
48
|
-
name: rspec
|
|
47
|
+
name: rspec
|
|
49
48
|
requirement: !ruby/object:Gem::Requirement
|
|
50
49
|
requirements:
|
|
51
50
|
- - "~>"
|
|
52
51
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '
|
|
52
|
+
version: '3.12'
|
|
54
53
|
type: :development
|
|
55
54
|
prerelease: false
|
|
56
55
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
56
|
requirements:
|
|
58
57
|
- - "~>"
|
|
59
58
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: '
|
|
59
|
+
version: '3.12'
|
|
61
60
|
- !ruby/object:Gem::Dependency
|
|
62
61
|
name: rubocop
|
|
63
62
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -72,34 +71,20 @@ dependencies:
|
|
|
72
71
|
- - "~>"
|
|
73
72
|
- !ruby/object:Gem::Version
|
|
74
73
|
version: '1.57'
|
|
75
|
-
- !ruby/object:Gem::Dependency
|
|
76
|
-
name: rubocop-rails
|
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
|
78
|
-
requirements:
|
|
79
|
-
- - "~>"
|
|
80
|
-
- !ruby/object:Gem::Version
|
|
81
|
-
version: '2.22'
|
|
82
|
-
type: :development
|
|
83
|
-
prerelease: false
|
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
85
|
-
requirements:
|
|
86
|
-
- - "~>"
|
|
87
|
-
- !ruby/object:Gem::Version
|
|
88
|
-
version: '2.22'
|
|
89
74
|
- !ruby/object:Gem::Dependency
|
|
90
75
|
name: rubocop-rspec
|
|
91
76
|
requirement: !ruby/object:Gem::Requirement
|
|
92
77
|
requirements:
|
|
93
78
|
- - "~>"
|
|
94
79
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: '
|
|
80
|
+
version: '3.0'
|
|
96
81
|
type: :development
|
|
97
82
|
prerelease: false
|
|
98
83
|
version_requirements: !ruby/object:Gem::Requirement
|
|
99
84
|
requirements:
|
|
100
85
|
- - "~>"
|
|
101
86
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: '
|
|
87
|
+
version: '3.0'
|
|
103
88
|
- !ruby/object:Gem::Dependency
|
|
104
89
|
name: simplecov
|
|
105
90
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -114,8 +99,8 @@ dependencies:
|
|
|
114
99
|
- - "~>"
|
|
115
100
|
- !ruby/object:Gem::Version
|
|
116
101
|
version: '0.22'
|
|
117
|
-
description: The easiest way to integrate your Ruby
|
|
118
|
-
|
|
102
|
+
description: The easiest way to integrate your Ruby application with AbacatePay Gateway
|
|
103
|
+
for payments, subscriptions, PIX transfers, and more.
|
|
119
104
|
email:
|
|
120
105
|
- mathuscardoso@gmail.com
|
|
121
106
|
executables: []
|
|
@@ -131,24 +116,53 @@ files:
|
|
|
131
116
|
- Rakefile
|
|
132
117
|
- abacatepay-ruby.gemspec
|
|
133
118
|
- lib/abacate_pay.rb
|
|
134
|
-
- lib/
|
|
135
|
-
- lib/
|
|
136
|
-
- lib/
|
|
137
|
-
- lib/
|
|
138
|
-
- lib/
|
|
139
|
-
- lib/
|
|
140
|
-
- lib/
|
|
141
|
-
- lib/
|
|
142
|
-
- lib/
|
|
143
|
-
- lib/
|
|
144
|
-
- lib/
|
|
145
|
-
- lib/
|
|
146
|
-
- lib/
|
|
147
|
-
- lib/
|
|
148
|
-
- lib/
|
|
149
|
-
- lib/
|
|
150
|
-
- lib/
|
|
151
|
-
-
|
|
119
|
+
- lib/abacate_pay/clients.rb
|
|
120
|
+
- lib/abacate_pay/clients/billing_client.rb
|
|
121
|
+
- lib/abacate_pay/clients/checkout_client.rb
|
|
122
|
+
- lib/abacate_pay/clients/client.rb
|
|
123
|
+
- lib/abacate_pay/clients/coupon_client.rb
|
|
124
|
+
- lib/abacate_pay/clients/customer_client.rb
|
|
125
|
+
- lib/abacate_pay/clients/payment_link_client.rb
|
|
126
|
+
- lib/abacate_pay/clients/payout_client.rb
|
|
127
|
+
- lib/abacate_pay/clients/pix_client.rb
|
|
128
|
+
- lib/abacate_pay/clients/product_client.rb
|
|
129
|
+
- lib/abacate_pay/clients/store_client.rb
|
|
130
|
+
- lib/abacate_pay/clients/subscription_client.rb
|
|
131
|
+
- lib/abacate_pay/clients/transparent_client.rb
|
|
132
|
+
- lib/abacate_pay/clients/webhook_client.rb
|
|
133
|
+
- lib/abacate_pay/configuration.rb
|
|
134
|
+
- lib/abacate_pay/enums.rb
|
|
135
|
+
- lib/abacate_pay/enums/billings/frequencies.rb
|
|
136
|
+
- lib/abacate_pay/enums/billings/methods.rb
|
|
137
|
+
- lib/abacate_pay/enums/billings/statuses.rb
|
|
138
|
+
- lib/abacate_pay/enums/checkouts/statuses.rb
|
|
139
|
+
- lib/abacate_pay/enums/coupons/discount_kinds.rb
|
|
140
|
+
- lib/abacate_pay/enums/coupons/statuses.rb
|
|
141
|
+
- lib/abacate_pay/enums/payouts/statuses.rb
|
|
142
|
+
- lib/abacate_pay/enums/pix/key_types.rb
|
|
143
|
+
- lib/abacate_pay/enums/products/cycles.rb
|
|
144
|
+
- lib/abacate_pay/enums/transfers/statuses.rb
|
|
145
|
+
- lib/abacate_pay/enums/webhooks/event_types.rb
|
|
146
|
+
- lib/abacate_pay/resources.rb
|
|
147
|
+
- lib/abacate_pay/resources/billings.rb
|
|
148
|
+
- lib/abacate_pay/resources/billings/metadata.rb
|
|
149
|
+
- lib/abacate_pay/resources/billings/product.rb
|
|
150
|
+
- lib/abacate_pay/resources/checkouts.rb
|
|
151
|
+
- lib/abacate_pay/resources/coupons.rb
|
|
152
|
+
- lib/abacate_pay/resources/customers.rb
|
|
153
|
+
- lib/abacate_pay/resources/customers/metadata.rb
|
|
154
|
+
- lib/abacate_pay/resources/payouts.rb
|
|
155
|
+
- lib/abacate_pay/resources/pix_transfers.rb
|
|
156
|
+
- lib/abacate_pay/resources/products.rb
|
|
157
|
+
- lib/abacate_pay/resources/resource.rb
|
|
158
|
+
- lib/abacate_pay/resources/store.rb
|
|
159
|
+
- lib/abacate_pay/resources/store/balance.rb
|
|
160
|
+
- lib/abacate_pay/resources/subscriptions.rb
|
|
161
|
+
- lib/abacate_pay/resources/transparents.rb
|
|
162
|
+
- lib/abacate_pay/resources/webhook_endpoints.rb
|
|
163
|
+
- lib/abacate_pay/version.rb
|
|
164
|
+
- lib/abacate_pay/webhooks.rb
|
|
165
|
+
- lib/abacate_pay/webhooks/event.rb
|
|
152
166
|
homepage: https://www.abacatepay.com/
|
|
153
167
|
licenses:
|
|
154
168
|
- MIT
|
|
@@ -156,7 +170,7 @@ metadata:
|
|
|
156
170
|
homepage_uri: https://www.abacatepay.com/
|
|
157
171
|
source_code_uri: https://github.com/AbacatePay/abacatepay-ruby-sdk
|
|
158
172
|
changelog_uri: https://github.com/AbacatePay/abacatepay-ruby-sdk/blob/main/CHANGELOG.md
|
|
159
|
-
|
|
173
|
+
rubygems_mfa_required: 'true'
|
|
160
174
|
rdoc_options: []
|
|
161
175
|
require_paths:
|
|
162
176
|
- lib
|
|
@@ -164,15 +178,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
164
178
|
requirements:
|
|
165
179
|
- - ">="
|
|
166
180
|
- !ruby/object:Gem::Version
|
|
167
|
-
version: 2.
|
|
181
|
+
version: 3.2.0
|
|
168
182
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
183
|
requirements:
|
|
170
184
|
- - ">="
|
|
171
185
|
- !ruby/object:Gem::Version
|
|
172
186
|
version: '0'
|
|
173
187
|
requirements: []
|
|
174
|
-
rubygems_version: 3.
|
|
175
|
-
signing_key:
|
|
188
|
+
rubygems_version: 3.6.9
|
|
176
189
|
specification_version: 4
|
|
177
|
-
summary: AbacatePay Ruby
|
|
190
|
+
summary: AbacatePay Ruby SDK for you to start receiving payments in seconds
|
|
178
191
|
test_files: []
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module AbacatePay
|
|
4
|
-
module Clients
|
|
5
|
-
# Client class for managing billing-related operations in the AbacatePay API.
|
|
6
|
-
class BillingClient < Client
|
|
7
|
-
# API endpoint for billing-related operations
|
|
8
|
-
URI = "billing"
|
|
9
|
-
|
|
10
|
-
# @param client [Faraday::Connection, nil] Optional Faraday client for custom configurations
|
|
11
|
-
def initialize(client = nil)
|
|
12
|
-
super(URI, client)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# Retrieves a list of billings
|
|
16
|
-
#
|
|
17
|
-
# @return [Array<Resources::Billing>] Array of Billing objects
|
|
18
|
-
def list
|
|
19
|
-
response = request("GET", "list")
|
|
20
|
-
response.map { |data| Resources::Billing.new(data) }
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# Creates a new billing
|
|
24
|
-
#
|
|
25
|
-
# @param data [Resources::Billing] The billing data to be sent for creation
|
|
26
|
-
# @return [Resources::Billing] The created Billing object
|
|
27
|
-
def create(data)
|
|
28
|
-
request_data = {
|
|
29
|
-
frequency: data.frequency,
|
|
30
|
-
methods: data.methods,
|
|
31
|
-
returnUrl: data.metadata&.return_url,
|
|
32
|
-
completionUrl: data.metadata&.completion_url,
|
|
33
|
-
products: data.products&.map { |product|
|
|
34
|
-
{
|
|
35
|
-
externalId: product.external_id,
|
|
36
|
-
name: product.name,
|
|
37
|
-
description: product.description,
|
|
38
|
-
quantity: product.quantity,
|
|
39
|
-
price: product.price
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if data.customer&.id
|
|
45
|
-
request_data[:customerId] = data.customer.id
|
|
46
|
-
else
|
|
47
|
-
request_data[:customer] = {
|
|
48
|
-
name: data.customer&.metadata&.name,
|
|
49
|
-
email: data.customer&.metadata&.email,
|
|
50
|
-
cellphone: data.customer&.metadata&.cellphone,
|
|
51
|
-
taxId: data.customer&.metadata&.tax_id
|
|
52
|
-
}
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
response = request("POST", "create", json: request_data)
|
|
56
|
-
Resources::Billing.new(response)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module AbacatePay
|
|
4
|
-
module Clients
|
|
5
|
-
# Client class for managing customer-related operations in the AbacatePay API.
|
|
6
|
-
class CustomerClient < Client
|
|
7
|
-
# API endpoint for customer-related operations
|
|
8
|
-
URI = "customer"
|
|
9
|
-
|
|
10
|
-
# @param client [Faraday::Connection, nil] Optional Faraday client for custom configurations
|
|
11
|
-
def initialize(client = nil)
|
|
12
|
-
super(URI, client)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# Retrieves a list of customers
|
|
16
|
-
#
|
|
17
|
-
# @return [Array<Resources::Customer>] Array of Customer objects
|
|
18
|
-
def list
|
|
19
|
-
response = request("GET", "list")
|
|
20
|
-
response.map { |data| Resources::Customer.new(data) }
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# Creates a new customer
|
|
24
|
-
#
|
|
25
|
-
# @param data [Resources::Customer] The customer data to be sent for creation
|
|
26
|
-
# @return [Resources::Customer] The created Customer object
|
|
27
|
-
def create(data)
|
|
28
|
-
response = request("POST", "create", json: {
|
|
29
|
-
name: data.metadata&.name,
|
|
30
|
-
email: data.metadata&.email,
|
|
31
|
-
cellphone: data.metadata&.cellphone,
|
|
32
|
-
taxId: data.metadata&.tax_id
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
Resources::Customer.new(response)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
data/lib/abacatepay/clients.rb
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "abacate_pay/clients/client"
|
|
4
|
-
require "abacate_pay/clients/billing_client"
|
|
5
|
-
require "abacate_pay/clients/customer_client"
|
|
6
|
-
|
|
7
|
-
module AbacatePay
|
|
8
|
-
# The Clients module contains all API client implementations
|
|
9
|
-
# for interacting with the AbacatePay API endpoints.
|
|
10
|
-
module Clients
|
|
11
|
-
end
|
|
12
|
-
end
|