Module: AbacatePay

Defined in:
lib/abacate_pay.rb,
lib/abacate_pay/enums.rb,
lib/abacate_pay/clients.rb,
lib/abacate_pay/version.rb,
lib/abacate_pay/webhooks.rb,
lib/abacate_pay/resources.rb,
lib/abacate_pay/configuration.rb,
lib/abacate_pay/clients/client.rb,
lib/abacate_pay/webhooks/event.rb,
lib/abacate_pay/resources/store.rb,
lib/abacate_pay/resources/coupons.rb,
lib/abacate_pay/resources/payouts.rb,
lib/abacate_pay/clients/pix_client.rb,
lib/abacate_pay/resources/billings.rb,
lib/abacate_pay/resources/products.rb,
lib/abacate_pay/resources/resource.rb,
lib/abacate_pay/enums/pix/key_types.rb,
lib/abacate_pay/resources/checkouts.rb,
lib/abacate_pay/resources/customers.rb,
lib/abacate_pay/clients/store_client.rb,
lib/abacate_pay/clients/coupon_client.rb,
lib/abacate_pay/clients/payout_client.rb,
lib/abacate_pay/enums/products/cycles.rb,
lib/abacate_pay/clients/billing_client.rb,
lib/abacate_pay/clients/product_client.rb,
lib/abacate_pay/clients/webhook_client.rb,
lib/abacate_pay/enums/billings/methods.rb,
lib/abacate_pay/enums/coupons/statuses.rb,
lib/abacate_pay/enums/payouts/statuses.rb,
lib/abacate_pay/resources/transparents.rb,
lib/abacate_pay/clients/checkout_client.rb,
lib/abacate_pay/clients/customer_client.rb,
lib/abacate_pay/enums/billings/statuses.rb,
lib/abacate_pay/resources/pix_transfers.rb,
lib/abacate_pay/resources/store/balance.rb,
lib/abacate_pay/resources/subscriptions.rb,
lib/abacate_pay/enums/checkouts/statuses.rb,
lib/abacate_pay/enums/transfers/statuses.rb,
lib/abacate_pay/clients/transparent_client.rb,
lib/abacate_pay/enums/billings/frequencies.rb,
lib/abacate_pay/enums/webhooks/event_types.rb,
lib/abacate_pay/resources/billings/product.rb,
lib/abacate_pay/clients/payment_link_client.rb,
lib/abacate_pay/clients/subscription_client.rb,
lib/abacate_pay/resources/billings/metadata.rb,
lib/abacate_pay/resources/webhook_endpoints.rb,
lib/abacate_pay/enums/coupons/discount_kinds.rb,
lib/abacate_pay/resources/customers/metadata.rb

Overview

Main module for AbacatePay SDK integration

Defined Under Namespace

Modules: Clients, Enums, Resources, Webhooks Classes: ApiError, Configuration, ConfigurationError, Error

Constant Summary collapse

VERSION =
"1.0.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationConfiguration?

Returns The global configuration.

Returns:



14
15
16
# File 'lib/abacate_pay.rb', line 14

def configuration
  @configuration
end

Class Method Details

.checkoutsClients::CheckoutClient

Returns Checkout API client.

Returns:



100
101
102
# File 'lib/abacate_pay.rb', line 100

def self.checkouts
  clients[:checkouts] ||= Clients::CheckoutClient.new
end

.configuration!Configuration

Returns the configuration, refusing to proceed if the SDK was never set up.

Forgetting to call configure is the most common first-run mistake; without this the failure surfaces as NoMethodError: undefined method 'api_url' for nil from deep inside the client.

Returns:

Raises:



64
65
66
67
68
69
# File 'lib/abacate_pay.rb', line 64

def self.configuration!
  configuration || raise(
    ConfigurationError,
    "AbacatePay is not configured. Call AbacatePay.configure { |c| c.api_token = ENV['ABACATEPAY_API_KEY'] } first."
  )
end

.configure {|config| ... } ⇒ void

This method returns an undefined value.

Configures the SDK

Memoized clients are discarded so a token changed at runtime takes effect immediately. Without this, a client built before the change keeps sending the old bearer token.

Examples:

AbacatePay.configure do |config|
  config.api_token = "your-token-here"
  config.environment = :sandbox
end

Yields:

  • (config)

    Configuration object



41
42
43
44
45
46
# File 'lib/abacate_pay.rb', line 41

def self.configure
  self.configuration ||= Configuration.new
  yield(configuration)
  configuration.validate!
  reset_clients!
end

.couponsClients::CouponClient

Returns Coupon API client.

Returns:



95
96
97
# File 'lib/abacate_pay.rb', line 95

def self.coupons
  clients[:coupons] ||= Clients::CouponClient.new
end

.customersClients::CustomerClient

Returns Customer API client.

Returns:



85
86
87
# File 'lib/abacate_pay.rb', line 85

def self.customers
  clients[:customers] ||= Clients::CustomerClient.new
end

Returns Reusable payment link API client.

Returns:



130
131
132
# File 'lib/abacate_pay.rb', line 130

def self.payment_links
  clients[:payment_links] ||= Clients::PaymentLinkClient.new
end

.payoutsClients::PayoutClient

Returns Payout API client.

Returns:



120
121
122
# File 'lib/abacate_pay.rb', line 120

def self.payouts
  clients[:payouts] ||= Clients::PayoutClient.new
end

.pixClients::PixClient

Returns PIX Transfer API client.

Returns:



115
116
117
# File 'lib/abacate_pay.rb', line 115

def self.pix
  clients[:pix] ||= Clients::PixClient.new
end

.productsClients::ProductClient

Returns Product API client.

Returns:



90
91
92
# File 'lib/abacate_pay.rb', line 90

def self.products
  clients[:products] ||= Clients::ProductClient.new
end

.reset!void

This method returns an undefined value.

Resets the configuration to defaults



51
52
53
54
# File 'lib/abacate_pay.rb', line 51

def self.reset!
  self.configuration = Configuration.new
  reset_clients!
end

.reset_clients!void

This method returns an undefined value.

Discards every memoized client so the next call rebuilds from current config



74
75
76
# File 'lib/abacate_pay.rb', line 74

def self.reset_clients!
  @clients = {}
end

.storeClients::StoreClient

Returns Store API client.

Returns:



125
126
127
# File 'lib/abacate_pay.rb', line 125

def self.store
  clients[:store] ||= Clients::StoreClient.new
end

.subscriptionsClients::SubscriptionClient

Returns Subscription API client.

Returns:



105
106
107
# File 'lib/abacate_pay.rb', line 105

def self.subscriptions
  clients[:subscriptions] ||= Clients::SubscriptionClient.new
end

.transparentsClients::TransparentClient

Returns PIX Transparent API client.

Returns:



110
111
112
# File 'lib/abacate_pay.rb', line 110

def self.transparents
  clients[:transparents] ||= Clients::TransparentClient.new
end

.webhook_endpointsClients::WebhookClient

Webhook endpoint registration. To verify an inbound delivery, use AbacatePay::Webhooks.construct_event.

Returns:



138
139
140
# File 'lib/abacate_pay.rb', line 138

def self.webhook_endpoints
  clients[:webhook_endpoints] ||= Clients::WebhookClient.new
end