billingio 1.0.0 → 2.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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +226 -1
  3. data/billingio.gemspec +4 -3
  4. data/lib/billingio/client.rb +55 -0
  5. data/lib/billingio/http_client.rb +10 -0
  6. data/lib/billingio/models/accounting_report.rb +46 -0
  7. data/lib/billingio/models/adjustment.rb +46 -0
  8. data/lib/billingio/models/customer.rb +46 -0
  9. data/lib/billingio/models/entitlement.rb +46 -0
  10. data/lib/billingio/models/entitlement_check.rb +39 -0
  11. data/lib/billingio/models/payment_link.rb +47 -0
  12. data/lib/billingio/models/payment_method.rb +51 -0
  13. data/lib/billingio/models/payout_intent.rb +51 -0
  14. data/lib/billingio/models/revenue_event.rb +49 -0
  15. data/lib/billingio/models/settlement.rb +51 -0
  16. data/lib/billingio/models/subscription.rb +50 -0
  17. data/lib/billingio/models/subscription_plan.rb +51 -0
  18. data/lib/billingio/models/subscription_renewal.rb +49 -0
  19. data/lib/billingio/resources/adjustments.rb +52 -0
  20. data/lib/billingio/resources/customers.rb +75 -0
  21. data/lib/billingio/resources/entitlements.rb +95 -0
  22. data/lib/billingio/resources/payment_links.rb +47 -0
  23. data/lib/billingio/resources/payment_methods.rb +91 -0
  24. data/lib/billingio/resources/payout_intents.rb +78 -0
  25. data/lib/billingio/resources/revenue_events.rb +47 -0
  26. data/lib/billingio/resources/settlements.rb +30 -0
  27. data/lib/billingio/resources/subscription_plans.rb +71 -0
  28. data/lib/billingio/resources/subscription_renewals.rb +42 -0
  29. data/lib/billingio/resources/subscriptions.rb +67 -0
  30. data/lib/billingio/version.rb +1 -1
  31. data/lib/billingio.rb +24 -0
  32. metadata +30 -6
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BillingIO
4
+ # Provides access to payout intent endpoints.
5
+ #
6
+ # client.payout_intents.create(amount_usd: 500.00, chain: "tron", token: "USDT", destination: "T...")
7
+ # client.payout_intents.list
8
+ # client.payout_intents.update("po_abc123", metadata: { "ref" => "inv_001" })
9
+ # client.payout_intents.execute("po_abc123")
10
+ class PayoutIntents
11
+ # @api private
12
+ def initialize(http_client)
13
+ @http = http_client
14
+ end
15
+
16
+ # Create a new payout intent.
17
+ #
18
+ # @param amount_usd [Float] payout amount in USD
19
+ # @param chain [String] blockchain network
20
+ # @param token [String] stablecoin token
21
+ # @param destination [String] destination wallet address
22
+ # @param metadata [Hash, nil] arbitrary key-value pairs
23
+ # @return [BillingIO::PayoutIntent]
24
+ # @raise [BillingIO::Error]
25
+ def create(amount_usd:, chain:, token:, destination:, metadata: nil)
26
+ body = {
27
+ "amount_usd" => amount_usd,
28
+ "chain" => chain,
29
+ "token" => token,
30
+ "destination" => destination
31
+ }
32
+ body["metadata"] = metadata if metadata
33
+
34
+ data = @http.post("/payouts", body)
35
+ PayoutIntent.from_hash(data)
36
+ end
37
+
38
+ # List payout intents with cursor-based pagination.
39
+ #
40
+ # @param cursor [String, nil] opaque cursor for the next page
41
+ # @param limit [Integer] items per page (1..100, default 25)
42
+ # @param status [String, nil] filter by payout status
43
+ # @return [BillingIO::PaginatedList<BillingIO::PayoutIntent>]
44
+ # @raise [BillingIO::Error]
45
+ def list(cursor: nil, limit: 25, status: nil)
46
+ params = { limit: limit }
47
+ params[:cursor] = cursor if cursor
48
+ params[:status] = status if status
49
+
50
+ data = @http.get("/payouts", params)
51
+ PaginatedList.from_hash(data, PayoutIntent)
52
+ end
53
+
54
+ # Update an existing payout intent.
55
+ #
56
+ # @param payout_id [String] payout identifier (prefixed +po_+)
57
+ # @param metadata [Hash, nil] new metadata (replaces existing)
58
+ # @return [BillingIO::PayoutIntent]
59
+ # @raise [BillingIO::Error]
60
+ def update(payout_id, metadata: nil)
61
+ body = {}
62
+ body["metadata"] = metadata if metadata
63
+
64
+ data = @http.patch("/payouts/#{payout_id}", body)
65
+ PayoutIntent.from_hash(data)
66
+ end
67
+
68
+ # Execute a payout intent (trigger the on-chain transfer).
69
+ #
70
+ # @param payout_id [String] payout identifier (prefixed +po_+)
71
+ # @return [BillingIO::PayoutIntent]
72
+ # @raise [BillingIO::Error]
73
+ def execute(payout_id)
74
+ data = @http.post("/payouts/#{payout_id}/execute")
75
+ PayoutIntent.from_hash(data)
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BillingIO
4
+ # Provides access to revenue event and accounting endpoints.
5
+ #
6
+ # client.revenue_events.list(type: "payment")
7
+ # client.revenue_events.accounting(period_start: "2025-01-01", period_end: "2025-01-31")
8
+ class RevenueEvents
9
+ # @api private
10
+ def initialize(http_client)
11
+ @http = http_client
12
+ end
13
+
14
+ # List revenue events with cursor-based pagination.
15
+ #
16
+ # @param cursor [String, nil] opaque cursor for the next page
17
+ # @param limit [Integer] items per page (1..100, default 25)
18
+ # @param type [String, nil] filter by event type
19
+ # @param customer_id [String, nil] filter by customer
20
+ # @return [BillingIO::PaginatedList<BillingIO::RevenueEvent>]
21
+ # @raise [BillingIO::Error]
22
+ def list(cursor: nil, limit: 25, type: nil, customer_id: nil)
23
+ params = { limit: limit }
24
+ params[:cursor] = cursor if cursor
25
+ params[:type] = type if type
26
+ params[:customer_id] = customer_id if customer_id
27
+
28
+ data = @http.get("/revenue/events", params)
29
+ PaginatedList.from_hash(data, RevenueEvent)
30
+ end
31
+
32
+ # Retrieve an accounting summary report.
33
+ #
34
+ # @param period_start [String, nil] ISO-8601 period start date
35
+ # @param period_end [String, nil] ISO-8601 period end date
36
+ # @return [BillingIO::AccountingReport]
37
+ # @raise [BillingIO::Error]
38
+ def accounting(period_start: nil, period_end: nil)
39
+ params = {}
40
+ params[:period_start] = period_start if period_start
41
+ params[:period_end] = period_end if period_end
42
+
43
+ data = @http.get("/revenue/accounting", params)
44
+ AccountingReport.from_hash(data)
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BillingIO
4
+ # Provides access to payout settlement endpoints.
5
+ #
6
+ # client.settlements.list
7
+ # client.settlements.list(payout_id: "po_abc123")
8
+ class Settlements
9
+ # @api private
10
+ def initialize(http_client)
11
+ @http = http_client
12
+ end
13
+
14
+ # List settlements with cursor-based pagination.
15
+ #
16
+ # @param cursor [String, nil] opaque cursor for the next page
17
+ # @param limit [Integer] items per page (1..100, default 25)
18
+ # @param payout_id [String, nil] filter by payout intent
19
+ # @return [BillingIO::PaginatedList<BillingIO::Settlement>]
20
+ # @raise [BillingIO::Error]
21
+ def list(cursor: nil, limit: 25, payout_id: nil)
22
+ params = { limit: limit }
23
+ params[:cursor] = cursor if cursor
24
+ params[:payout_id] = payout_id if payout_id
25
+
26
+ data = @http.get("/payouts/settlements", params)
27
+ PaginatedList.from_hash(data, Settlement)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BillingIO
4
+ # Provides access to subscription plan management endpoints.
5
+ #
6
+ # client.subscription_plans.create(name: "Pro", amount_usd: 29.99, interval: "monthly")
7
+ # client.subscription_plans.list
8
+ # client.subscription_plans.update("plan_abc123", name: "Pro Plus")
9
+ class SubscriptionPlans
10
+ # @api private
11
+ def initialize(http_client)
12
+ @http = http_client
13
+ end
14
+
15
+ # Create a new subscription plan.
16
+ #
17
+ # @param name [String] human-readable plan name
18
+ # @param amount_usd [Float] recurring amount in USD
19
+ # @param interval [String] billing interval (e.g. "monthly", "yearly")
20
+ # @param interval_count [Integer] number of intervals between billings (default 1)
21
+ # @param chain [String, nil] blockchain network
22
+ # @param token [String, nil] stablecoin token
23
+ # @param metadata [Hash, nil] arbitrary key-value pairs
24
+ # @return [BillingIO::SubscriptionPlan]
25
+ # @raise [BillingIO::Error]
26
+ def create(name:, amount_usd:, interval:, interval_count: 1, chain: nil, token: nil, metadata: nil)
27
+ body = {
28
+ "name" => name,
29
+ "amount_usd" => amount_usd,
30
+ "interval" => interval,
31
+ "interval_count" => interval_count
32
+ }
33
+ body["chain"] = chain if chain
34
+ body["token"] = token if token
35
+ body["metadata"] = metadata if metadata
36
+
37
+ data = @http.post("/subscriptions/plans", body)
38
+ SubscriptionPlan.from_hash(data)
39
+ end
40
+
41
+ # List subscription plans with cursor-based pagination.
42
+ #
43
+ # @param cursor [String, nil] opaque cursor for the next page
44
+ # @param limit [Integer] items per page (1..100, default 25)
45
+ # @return [BillingIO::PaginatedList<BillingIO::SubscriptionPlan>]
46
+ # @raise [BillingIO::Error]
47
+ def list(cursor: nil, limit: 25)
48
+ params = { limit: limit }
49
+ params[:cursor] = cursor if cursor
50
+
51
+ data = @http.get("/subscriptions/plans", params)
52
+ PaginatedList.from_hash(data, SubscriptionPlan)
53
+ end
54
+
55
+ # Update an existing subscription plan.
56
+ #
57
+ # @param plan_id [String] plan identifier (prefixed +plan_+)
58
+ # @param name [String, nil] new plan name
59
+ # @param metadata [Hash, nil] new metadata (replaces existing)
60
+ # @return [BillingIO::SubscriptionPlan]
61
+ # @raise [BillingIO::Error]
62
+ def update(plan_id, name: nil, metadata: nil)
63
+ body = {}
64
+ body["name"] = name if name
65
+ body["metadata"] = metadata if metadata
66
+
67
+ data = @http.patch("/subscriptions/plans/#{plan_id}", body)
68
+ SubscriptionPlan.from_hash(data)
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BillingIO
4
+ # Provides access to subscription renewal endpoints.
5
+ #
6
+ # client.subscription_renewals.list(subscription_id: "sub_abc123")
7
+ # client.subscription_renewals.retry("ren_abc123")
8
+ class SubscriptionRenewals
9
+ # @api private
10
+ def initialize(http_client)
11
+ @http = http_client
12
+ end
13
+
14
+ # List subscription renewals with cursor-based pagination.
15
+ #
16
+ # @param cursor [String, nil] opaque cursor for the next page
17
+ # @param limit [Integer] items per page (1..100, default 25)
18
+ # @param subscription_id [String, nil] filter by subscription
19
+ # @param status [String, nil] filter by renewal status
20
+ # @return [BillingIO::PaginatedList<BillingIO::SubscriptionRenewal>]
21
+ # @raise [BillingIO::Error]
22
+ def list(cursor: nil, limit: 25, subscription_id: nil, status: nil)
23
+ params = { limit: limit }
24
+ params[:cursor] = cursor if cursor
25
+ params[:subscription_id] = subscription_id if subscription_id
26
+ params[:status] = status if status
27
+
28
+ data = @http.get("/subscriptions/renewals", params)
29
+ PaginatedList.from_hash(data, SubscriptionRenewal)
30
+ end
31
+
32
+ # Retry a failed renewal.
33
+ #
34
+ # @param renewal_id [String] renewal identifier (prefixed +ren_+)
35
+ # @return [BillingIO::SubscriptionRenewal]
36
+ # @raise [BillingIO::Error]
37
+ def retry(renewal_id)
38
+ data = @http.post("/subscriptions/renewals/#{renewal_id}/retry")
39
+ SubscriptionRenewal.from_hash(data)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BillingIO
4
+ # Provides access to subscription management endpoints.
5
+ #
6
+ # client.subscriptions.create(customer_id: "cus_abc123", plan_id: "plan_abc123")
7
+ # client.subscriptions.list
8
+ # client.subscriptions.update("sub_abc123", metadata: { "tier" => "premium" })
9
+ class Subscriptions
10
+ # @api private
11
+ def initialize(http_client)
12
+ @http = http_client
13
+ end
14
+
15
+ # Create a new subscription.
16
+ #
17
+ # @param customer_id [String] customer identifier
18
+ # @param plan_id [String] plan identifier
19
+ # @param metadata [Hash, nil] arbitrary key-value pairs
20
+ # @return [BillingIO::Subscription]
21
+ # @raise [BillingIO::Error]
22
+ def create(customer_id:, plan_id:, metadata: nil)
23
+ body = {
24
+ "customer_id" => customer_id,
25
+ "plan_id" => plan_id
26
+ }
27
+ body["metadata"] = metadata if metadata
28
+
29
+ data = @http.post("/subscriptions", body)
30
+ Subscription.from_hash(data)
31
+ end
32
+
33
+ # List subscriptions with cursor-based pagination.
34
+ #
35
+ # @param cursor [String, nil] opaque cursor for the next page
36
+ # @param limit [Integer] items per page (1..100, default 25)
37
+ # @param customer_id [String, nil] filter by customer
38
+ # @param status [String, nil] filter by subscription status
39
+ # @return [BillingIO::PaginatedList<BillingIO::Subscription>]
40
+ # @raise [BillingIO::Error]
41
+ def list(cursor: nil, limit: 25, customer_id: nil, status: nil)
42
+ params = { limit: limit }
43
+ params[:cursor] = cursor if cursor
44
+ params[:customer_id] = customer_id if customer_id
45
+ params[:status] = status if status
46
+
47
+ data = @http.get("/subscriptions", params)
48
+ PaginatedList.from_hash(data, Subscription)
49
+ end
50
+
51
+ # Update an existing subscription.
52
+ #
53
+ # @param subscription_id [String] subscription identifier (prefixed +sub_+)
54
+ # @param status [String, nil] new status (e.g. "canceled")
55
+ # @param metadata [Hash, nil] new metadata (replaces existing)
56
+ # @return [BillingIO::Subscription]
57
+ # @raise [BillingIO::Error]
58
+ def update(subscription_id, status: nil, metadata: nil)
59
+ body = {}
60
+ body["status"] = status if status
61
+ body["metadata"] = metadata if metadata
62
+
63
+ data = @http.patch("/subscriptions/#{subscription_id}", body)
64
+ Subscription.from_hash(data)
65
+ end
66
+ end
67
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BillingIO
4
- VERSION = "1.0.0"
4
+ VERSION = "2.0.0"
5
5
  end
data/lib/billingio.rb CHANGED
@@ -15,11 +15,35 @@ require_relative "billingio/models/webhook_endpoint"
15
15
  require_relative "billingio/models/event"
16
16
  require_relative "billingio/models/health_response"
17
17
  require_relative "billingio/models/paginated_list"
18
+ require_relative "billingio/models/customer"
19
+ require_relative "billingio/models/payment_method"
20
+ require_relative "billingio/models/payment_link"
21
+ require_relative "billingio/models/subscription_plan"
22
+ require_relative "billingio/models/subscription"
23
+ require_relative "billingio/models/subscription_renewal"
24
+ require_relative "billingio/models/entitlement"
25
+ require_relative "billingio/models/entitlement_check"
26
+ require_relative "billingio/models/payout_intent"
27
+ require_relative "billingio/models/settlement"
28
+ require_relative "billingio/models/revenue_event"
29
+ require_relative "billingio/models/accounting_report"
30
+ require_relative "billingio/models/adjustment"
18
31
 
19
32
  # Resources
20
33
  require_relative "billingio/resources/checkouts"
21
34
  require_relative "billingio/resources/webhooks"
22
35
  require_relative "billingio/resources/events"
23
36
  require_relative "billingio/resources/health"
37
+ require_relative "billingio/resources/customers"
38
+ require_relative "billingio/resources/payment_methods"
39
+ require_relative "billingio/resources/payment_links"
40
+ require_relative "billingio/resources/subscription_plans"
41
+ require_relative "billingio/resources/subscriptions"
42
+ require_relative "billingio/resources/subscription_renewals"
43
+ require_relative "billingio/resources/entitlements"
44
+ require_relative "billingio/resources/payout_intents"
45
+ require_relative "billingio/resources/settlements"
46
+ require_relative "billingio/resources/revenue_events"
47
+ require_relative "billingio/resources/adjustments"
24
48
 
25
49
  require_relative "billingio/client"
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: billingio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - billing.io
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-30 00:00:00.000000000 Z
11
+ date: 2026-02-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Official Ruby client for billing.io -- non-custodial crypto payment checkouts
14
- with stablecoin settlement. Create checkouts, manage webhooks, verify signatures,
15
- and query event history.
13
+ description: Official Ruby client for billing.io -- non-custodial crypto payments
14
+ with stablecoin settlement. Manage customers, checkouts, subscriptions, payouts,
15
+ revenue tracking, entitlements, webhooks, and more.
16
16
  email:
17
17
  - support@billing.io
18
18
  executables: []
@@ -26,15 +26,39 @@ files:
26
26
  - lib/billingio/client.rb
27
27
  - lib/billingio/errors.rb
28
28
  - lib/billingio/http_client.rb
29
+ - lib/billingio/models/accounting_report.rb
30
+ - lib/billingio/models/adjustment.rb
29
31
  - lib/billingio/models/checkout.rb
30
32
  - lib/billingio/models/checkout_status.rb
33
+ - lib/billingio/models/customer.rb
34
+ - lib/billingio/models/entitlement.rb
35
+ - lib/billingio/models/entitlement_check.rb
31
36
  - lib/billingio/models/event.rb
32
37
  - lib/billingio/models/health_response.rb
33
38
  - lib/billingio/models/paginated_list.rb
39
+ - lib/billingio/models/payment_link.rb
40
+ - lib/billingio/models/payment_method.rb
41
+ - lib/billingio/models/payout_intent.rb
42
+ - lib/billingio/models/revenue_event.rb
43
+ - lib/billingio/models/settlement.rb
44
+ - lib/billingio/models/subscription.rb
45
+ - lib/billingio/models/subscription_plan.rb
46
+ - lib/billingio/models/subscription_renewal.rb
34
47
  - lib/billingio/models/webhook_endpoint.rb
48
+ - lib/billingio/resources/adjustments.rb
35
49
  - lib/billingio/resources/checkouts.rb
50
+ - lib/billingio/resources/customers.rb
51
+ - lib/billingio/resources/entitlements.rb
36
52
  - lib/billingio/resources/events.rb
37
53
  - lib/billingio/resources/health.rb
54
+ - lib/billingio/resources/payment_links.rb
55
+ - lib/billingio/resources/payment_methods.rb
56
+ - lib/billingio/resources/payout_intents.rb
57
+ - lib/billingio/resources/revenue_events.rb
58
+ - lib/billingio/resources/settlements.rb
59
+ - lib/billingio/resources/subscription_plans.rb
60
+ - lib/billingio/resources/subscription_renewals.rb
61
+ - lib/billingio/resources/subscriptions.rb
38
62
  - lib/billingio/resources/webhooks.rb
39
63
  - lib/billingio/version.rb
40
64
  - lib/billingio/webhook.rb
@@ -66,5 +90,5 @@ requirements: []
66
90
  rubygems_version: 3.0.3.1
67
91
  signing_key:
68
92
  specification_version: 4
69
- summary: Ruby SDK for the billing.io crypto checkout API
93
+ summary: Ruby SDK for the billing.io payments platform
70
94
  test_files: []