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/collection.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, Collection, Configuration, ConfigurationError, Error

Constant Summary collapse

VERSION =
"1.1.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationConfiguration?

Returns The global configuration.

Returns:



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

def configuration
  @configuration
end

Class Method Details

.checkoutsClients::CheckoutClient

Returns Checkout API client.

Returns:



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

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:



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

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



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

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

.couponsClients::CouponClient

Returns Coupon API client.

Returns:



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

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

.customersClients::CustomerClient

Returns Customer API client.

Returns:



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

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

Returns Reusable payment link API client.

Returns:



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

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

.payoutsClients::PayoutClient

Returns Payout API client.

Returns:



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

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

.pixClients::PixClient

Returns PIX Transfer API client.

Returns:



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

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

.productsClients::ProductClient

Returns Product API client.

Returns:



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

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

.reset!void

This method returns an undefined value.

Resets the configuration to defaults



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

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



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

def self.reset_clients!
  @clients = {}
end

.storeClients::StoreClient

Returns Store API client.

Returns:



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

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

.subscriptionsClients::SubscriptionClient

Returns Subscription API client.

Returns:



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

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

.transparentsClients::TransparentClient

Returns PIX Transparent API client.

Returns:



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

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:



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

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