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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be246a686bc1dac9b2c0bf75a6f66c5f77b58ba205ad72628a09d72a57d4a9e0
4
- data.tar.gz: 610719813172e602cc3b78c4f5b21120d91320a34945fc483c6ecc9743a4f8af
3
+ metadata.gz: 8be425bd5a196519fc083794cb40c7d6e0aeade7354739867e9221f67e57538a
4
+ data.tar.gz: 9fe922dc7b07f6af96df71d73dc9a40b008a62cf297e7b2b8b24303dea833a11
5
5
  SHA512:
6
- metadata.gz: dfce4a65d73b3c03f3a968fe376c4b6ca47d22fa5f693c8134672b94c09972872109b00b5abd3047d22a84f27b7acbb57fbc26860d1f100411cc03cd37b241a3
7
- data.tar.gz: a47bdd1a11a97832bb68bb3d0c17baa6f45b6259430106a3e859b7266b39bf75238541c61995f01c6f700b1ddc25ca9cdb1c7e880dcf407d93d39a403cc3c6f5
6
+ metadata.gz: 716b4c36731a3cffe27fb2342379e1ed75ab83958f1845621b21dee41833f5ace4dc2ab1eb5e64ad0eb8c801ae5f8d86e98c29c497a2b79356d28dc28381b373
7
+ data.tar.gz: 718ef6e1f6a2ac87710095902585c5eaa2685151109ff0f87217d5cdcd14ed5f5f21da3fd2fd612f815c9bc340c155e60648cffc0f876cef9872e8be245ce7d6
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # billingio
2
2
 
3
- Official Ruby SDK for the [billing.io](https://billing.io) crypto checkout API.
3
+ Official Ruby SDK for the [billing.io](https://billing.io) payments platform.
4
4
 
5
+ - Manage customers, payment methods, and payment links
5
6
  - Create payment checkouts settled in USDT / USDC on Tron or Arbitrum
7
+ - Recurring billing with subscription plans, renewals, and entitlements
8
+ - Payouts and settlement tracking
9
+ - Revenue events, accounting reports, and adjustments
6
10
  - Manage webhook endpoints and verify signatures
7
11
  - Query event history with cursor-based pagination
8
12
  - Zero runtime dependencies (stdlib only)
@@ -57,6 +61,71 @@ puts status.required_confirmations # => 19
57
61
  puts status.polling_interval_ms # => 2000
58
62
  ```
59
63
 
64
+ ## Customers
65
+
66
+ ```ruby
67
+ # Create a customer
68
+ customer = client.customers.create(
69
+ email: "user@example.com",
70
+ name: "Jane Doe",
71
+ metadata: { "org" => "acme" }
72
+ )
73
+ puts customer.customer_id # => "cus_..."
74
+
75
+ # List customers
76
+ customers = client.customers.list(limit: 10)
77
+ customers.each { |c| puts c.email }
78
+
79
+ # Retrieve a customer
80
+ customer = client.customers.get("cus_abc123")
81
+
82
+ # Update a customer
83
+ customer = client.customers.update("cus_abc123", name: "Jane Smith")
84
+ ```
85
+
86
+ ## Payment Methods
87
+
88
+ ```ruby
89
+ # Register a payment method
90
+ pm = client.payment_methods.create(
91
+ customer_id: "cus_abc123",
92
+ type: "wallet",
93
+ chain: "tron",
94
+ token: "USDT",
95
+ address: "T..."
96
+ )
97
+ puts pm.payment_method_id # => "pm_..."
98
+
99
+ # List payment methods
100
+ methods = client.payment_methods.list(customer_id: "cus_abc123")
101
+ methods.each { |m| puts "#{m.payment_method_id}: #{m.type}" }
102
+
103
+ # Update a payment method
104
+ client.payment_methods.update("pm_abc123", metadata: { "label" => "primary" })
105
+
106
+ # Set as default
107
+ client.payment_methods.set_default("pm_abc123")
108
+
109
+ # Delete a payment method
110
+ client.payment_methods.delete("pm_abc123")
111
+ ```
112
+
113
+ ## Payment Links
114
+
115
+ ```ruby
116
+ # Create a payment link
117
+ link = client.payment_links.create(
118
+ amount_usd: 25.00,
119
+ chain: "tron",
120
+ token: "USDT"
121
+ )
122
+ puts link.url # => "https://pay.billing.io/..."
123
+
124
+ # List payment links
125
+ links = client.payment_links.list
126
+ links.each { |l| puts "#{l.payment_link_id}: #{l.url}" }
127
+ ```
128
+
60
129
  ## Checkouts
61
130
 
62
131
  ```ruby
@@ -79,6 +148,162 @@ list = client.checkouts.list(status: "confirmed", limit: 10)
79
148
  list.each { |c| puts c.checkout_id }
80
149
  ```
81
150
 
151
+ ## Subscription Plans
152
+
153
+ ```ruby
154
+ # Create a plan
155
+ plan = client.subscription_plans.create(
156
+ name: "Pro Monthly",
157
+ amount_usd: 29.99,
158
+ interval: "monthly"
159
+ )
160
+ puts plan.plan_id # => "plan_..."
161
+
162
+ # List plans
163
+ plans = client.subscription_plans.list
164
+ plans.each { |p| puts "#{p.plan_id}: #{p.name} ($#{p.amount_usd})" }
165
+
166
+ # Update a plan
167
+ client.subscription_plans.update("plan_abc123", name: "Pro Plus Monthly")
168
+ ```
169
+
170
+ ## Subscriptions
171
+
172
+ ```ruby
173
+ # Create a subscription
174
+ sub = client.subscriptions.create(
175
+ customer_id: "cus_abc123",
176
+ plan_id: "plan_abc123"
177
+ )
178
+ puts sub.subscription_id # => "sub_..."
179
+ puts sub.status # => "active"
180
+
181
+ # List subscriptions
182
+ subs = client.subscriptions.list(customer_id: "cus_abc123", status: "active")
183
+ subs.each { |s| puts "#{s.subscription_id}: #{s.status}" }
184
+
185
+ # Cancel a subscription
186
+ client.subscriptions.update("sub_abc123", status: "canceled")
187
+ ```
188
+
189
+ ## Subscription Renewals
190
+
191
+ ```ruby
192
+ # List renewals
193
+ renewals = client.subscription_renewals.list(subscription_id: "sub_abc123")
194
+ renewals.each { |r| puts "#{r.renewal_id}: #{r.status}" }
195
+
196
+ # Retry a failed renewal
197
+ renewal = client.subscription_renewals.retry("ren_abc123")
198
+ puts renewal.status # => "pending"
199
+ ```
200
+
201
+ ## Entitlements
202
+
203
+ ```ruby
204
+ # Create an entitlement
205
+ ent = client.entitlements.create(
206
+ subscription_id: "sub_abc123",
207
+ feature_key: "api_calls",
208
+ value: 10_000
209
+ )
210
+ puts ent.entitlement_id # => "ent_..."
211
+
212
+ # List entitlements
213
+ ents = client.entitlements.list(subscription_id: "sub_abc123")
214
+ ents.each { |e| puts "#{e.feature_key}: #{e.value}" }
215
+
216
+ # Update an entitlement
217
+ client.entitlements.update("ent_abc123", value: 50_000)
218
+
219
+ # Check entitlement access
220
+ check = client.entitlements.check(
221
+ customer_id: "cus_abc123",
222
+ feature_key: "api_calls"
223
+ )
224
+ puts check.entitled # => true
225
+ puts check.value # => 50000
226
+
227
+ # Delete an entitlement
228
+ client.entitlements.delete("ent_abc123")
229
+ ```
230
+
231
+ ## Payout Intents
232
+
233
+ ```ruby
234
+ # Create a payout
235
+ payout = client.payout_intents.create(
236
+ amount_usd: 500.00,
237
+ chain: "tron",
238
+ token: "USDT",
239
+ destination: "T..."
240
+ )
241
+ puts payout.payout_id # => "po_..."
242
+ puts payout.status # => "pending"
243
+
244
+ # List payouts
245
+ payouts = client.payout_intents.list(status: "pending")
246
+ payouts.each { |p| puts "#{p.payout_id}: $#{p.amount_usd}" }
247
+
248
+ # Update a payout
249
+ client.payout_intents.update("po_abc123", metadata: { "ref" => "inv_001" })
250
+
251
+ # Execute a payout (trigger on-chain transfer)
252
+ payout = client.payout_intents.execute("po_abc123")
253
+ puts payout.status # => "executing"
254
+ puts payout.tx_hash # => "0x..."
255
+ ```
256
+
257
+ ## Settlements
258
+
259
+ ```ruby
260
+ # List settlements
261
+ settlements = client.settlements.list
262
+ settlements.each do |s|
263
+ puts "#{s.settlement_id}: $#{s.net_usd} (fee: $#{s.fee_usd})"
264
+ end
265
+
266
+ # Filter by payout
267
+ settlements = client.settlements.list(payout_id: "po_abc123")
268
+ ```
269
+
270
+ ## Revenue Events
271
+
272
+ ```ruby
273
+ # List revenue events
274
+ events = client.revenue_events.list(type: "payment", customer_id: "cus_abc123")
275
+ events.each do |e|
276
+ puts "#{e.revenue_event_id}: #{e.type} $#{e.amount_usd}"
277
+ end
278
+
279
+ # Get accounting summary
280
+ report = client.revenue_events.accounting(
281
+ period_start: "2025-01-01",
282
+ period_end: "2025-01-31"
283
+ )
284
+ puts report.total_revenue # => 12500.00
285
+ puts report.total_fees # => 125.00
286
+ puts report.total_net # => 12375.00
287
+ puts report.transaction_count # => 340
288
+ ```
289
+
290
+ ## Adjustments
291
+
292
+ ```ruby
293
+ # Create a revenue adjustment
294
+ adj = client.adjustments.create(
295
+ type: "credit",
296
+ amount_usd: 10.00,
297
+ reason: "Goodwill credit",
298
+ customer_id: "cus_abc123"
299
+ )
300
+ puts adj.adjustment_id # => "adj_..."
301
+
302
+ # List adjustments
303
+ adjustments = client.adjustments.list(customer_id: "cus_abc123")
304
+ adjustments.each { |a| puts "#{a.adjustment_id}: #{a.type} $#{a.amount_usd}" }
305
+ ```
306
+
82
307
  ## Webhook Endpoints
83
308
 
84
309
  ```ruby
data/billingio.gemspec CHANGED
@@ -8,10 +8,11 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["billing.io"]
9
9
  spec.email = ["support@billing.io"]
10
10
 
11
- spec.summary = "Ruby SDK for the billing.io crypto checkout API"
11
+ spec.summary = "Ruby SDK for the billing.io payments platform"
12
12
  spec.description = "Official Ruby client for billing.io -- non-custodial crypto " \
13
- "payment checkouts with stablecoin settlement. Create checkouts, " \
14
- "manage webhooks, verify signatures, and query event history."
13
+ "payments with stablecoin settlement. Manage customers, checkouts, " \
14
+ "subscriptions, payouts, revenue tracking, entitlements, webhooks, " \
15
+ "and more."
15
16
  spec.homepage = "https://github.com/billingio/billingio-ruby"
16
17
  spec.license = "MIT"
17
18
 
@@ -40,5 +40,60 @@ module BillingIO
40
40
  def health
41
41
  @health ||= Health.new(@http)
42
42
  end
43
+
44
+ # @return [BillingIO::Customers]
45
+ def customers
46
+ @customers ||= Customers.new(@http)
47
+ end
48
+
49
+ # @return [BillingIO::PaymentMethods]
50
+ def payment_methods
51
+ @payment_methods ||= PaymentMethods.new(@http)
52
+ end
53
+
54
+ # @return [BillingIO::PaymentLinks]
55
+ def payment_links
56
+ @payment_links ||= PaymentLinks.new(@http)
57
+ end
58
+
59
+ # @return [BillingIO::SubscriptionPlans]
60
+ def subscription_plans
61
+ @subscription_plans ||= SubscriptionPlans.new(@http)
62
+ end
63
+
64
+ # @return [BillingIO::Subscriptions]
65
+ def subscriptions
66
+ @subscriptions ||= Subscriptions.new(@http)
67
+ end
68
+
69
+ # @return [BillingIO::SubscriptionRenewals]
70
+ def subscription_renewals
71
+ @subscription_renewals ||= SubscriptionRenewals.new(@http)
72
+ end
73
+
74
+ # @return [BillingIO::Entitlements]
75
+ def entitlements
76
+ @entitlements ||= Entitlements.new(@http)
77
+ end
78
+
79
+ # @return [BillingIO::PayoutIntents]
80
+ def payout_intents
81
+ @payout_intents ||= PayoutIntents.new(@http)
82
+ end
83
+
84
+ # @return [BillingIO::Settlements]
85
+ def settlements
86
+ @settlements ||= Settlements.new(@http)
87
+ end
88
+
89
+ # @return [BillingIO::RevenueEvents]
90
+ def revenue_events
91
+ @revenue_events ||= RevenueEvents.new(@http)
92
+ end
93
+
94
+ # @return [BillingIO::Adjustments]
95
+ def adjustments
96
+ @adjustments ||= Adjustments.new(@http)
97
+ end
43
98
  end
44
99
  end
@@ -37,6 +37,16 @@ module BillingIO
37
37
  execute(uri, request)
38
38
  end
39
39
 
40
+ def patch(path, body = nil)
41
+ uri = build_uri(path)
42
+ request = Net::HTTP::Patch.new(uri)
43
+ if body
44
+ request.body = JSON.generate(body)
45
+ request["Content-Type"] = "application/json"
46
+ end
47
+ execute(uri, request)
48
+ end
49
+
40
50
  def delete(path)
41
51
  uri = build_uri(path)
42
52
  request = Net::HTTP::Delete.new(uri)
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BillingIO
4
+ # Represents an accounting summary report.
5
+ #
6
+ # @attr_reader period_start [String] ISO-8601 period start
7
+ # @attr_reader period_end [String] ISO-8601 period end
8
+ # @attr_reader total_revenue [Float] total revenue in USD
9
+ # @attr_reader total_fees [Float] total fees in USD
10
+ # @attr_reader total_net [Float] total net revenue in USD
11
+ # @attr_reader transaction_count [Integer] number of transactions
12
+ # @attr_reader currency [String] report currency
13
+ class AccountingReport
14
+ ATTRS = %i[
15
+ period_start period_end total_revenue
16
+ total_fees total_net transaction_count currency
17
+ ].freeze
18
+
19
+ attr_reader(*ATTRS)
20
+
21
+ # @param attrs [Hash{String,Symbol => Object}]
22
+ def initialize(attrs = {})
23
+ ATTRS.each do |attr|
24
+ value = attrs[attr.to_s] || attrs[attr]
25
+ instance_variable_set(:"@#{attr}", value)
26
+ end
27
+ end
28
+
29
+ # @param hash [Hash]
30
+ # @return [BillingIO::AccountingReport]
31
+ def self.from_hash(hash)
32
+ new(hash)
33
+ end
34
+
35
+ # @return [Hash{String => Object}]
36
+ def to_h
37
+ ATTRS.each_with_object({}) do |attr, h|
38
+ h[attr.to_s] = instance_variable_get(:"@#{attr}")
39
+ end
40
+ end
41
+
42
+ def inspect
43
+ "#<BillingIO::AccountingReport period_start=#{@period_start.inspect} total_revenue=#{@total_revenue.inspect}>"
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BillingIO
4
+ # Represents a revenue adjustment (credit, debit, or correction).
5
+ #
6
+ # @attr_reader adjustment_id [String] unique identifier (prefixed +adj_+)
7
+ # @attr_reader type [String] adjustment type (e.g. "credit", "debit", "correction")
8
+ # @attr_reader amount_usd [Float] adjustment amount in USD
9
+ # @attr_reader reason [String, nil] human-readable reason
10
+ # @attr_reader customer_id [String, nil] related customer
11
+ # @attr_reader metadata [Hash, nil] arbitrary key-value pairs
12
+ # @attr_reader created_at [String] ISO-8601 creation timestamp
13
+ class Adjustment
14
+ ATTRS = %i[
15
+ adjustment_id type amount_usd reason
16
+ customer_id metadata created_at
17
+ ].freeze
18
+
19
+ attr_reader(*ATTRS)
20
+
21
+ # @param attrs [Hash{String,Symbol => Object}]
22
+ def initialize(attrs = {})
23
+ ATTRS.each do |attr|
24
+ value = attrs[attr.to_s] || attrs[attr]
25
+ instance_variable_set(:"@#{attr}", value)
26
+ end
27
+ end
28
+
29
+ # @param hash [Hash]
30
+ # @return [BillingIO::Adjustment]
31
+ def self.from_hash(hash)
32
+ new(hash)
33
+ end
34
+
35
+ # @return [Hash{String => Object}]
36
+ def to_h
37
+ ATTRS.each_with_object({}) do |attr, h|
38
+ h[attr.to_s] = instance_variable_get(:"@#{attr}")
39
+ end
40
+ end
41
+
42
+ def inspect
43
+ "#<BillingIO::Adjustment adjustment_id=#{@adjustment_id.inspect} type=#{@type.inspect} amount_usd=#{@amount_usd.inspect}>"
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BillingIO
4
+ # Represents a customer record.
5
+ #
6
+ # @attr_reader customer_id [String] unique identifier (prefixed +cus_+)
7
+ # @attr_reader email [String, nil] customer email address
8
+ # @attr_reader name [String, nil] customer display name
9
+ # @attr_reader metadata [Hash, nil] arbitrary key-value pairs
10
+ # @attr_reader status [String] customer status
11
+ # @attr_reader created_at [String] ISO-8601 creation timestamp
12
+ # @attr_reader updated_at [String] ISO-8601 last-update timestamp
13
+ class Customer
14
+ ATTRS = %i[
15
+ customer_id email name metadata
16
+ status created_at updated_at
17
+ ].freeze
18
+
19
+ attr_reader(*ATTRS)
20
+
21
+ # @param attrs [Hash{String,Symbol => Object}]
22
+ def initialize(attrs = {})
23
+ ATTRS.each do |attr|
24
+ value = attrs[attr.to_s] || attrs[attr]
25
+ instance_variable_set(:"@#{attr}", value)
26
+ end
27
+ end
28
+
29
+ # @param hash [Hash]
30
+ # @return [BillingIO::Customer]
31
+ def self.from_hash(hash)
32
+ new(hash)
33
+ end
34
+
35
+ # @return [Hash{String => Object}]
36
+ def to_h
37
+ ATTRS.each_with_object({}) do |attr, h|
38
+ h[attr.to_s] = instance_variable_get(:"@#{attr}")
39
+ end
40
+ end
41
+
42
+ def inspect
43
+ "#<BillingIO::Customer customer_id=#{@customer_id.inspect} email=#{@email.inspect} status=#{@status.inspect}>"
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BillingIO
4
+ # Represents a subscription entitlement (feature or access grant).
5
+ #
6
+ # @attr_reader entitlement_id [String] unique identifier (prefixed +ent_+)
7
+ # @attr_reader subscription_id [String] parent subscription
8
+ # @attr_reader feature_key [String] machine-readable feature identifier
9
+ # @attr_reader value [Object, nil] entitlement value (boolean, numeric, or string)
10
+ # @attr_reader metadata [Hash, nil] arbitrary key-value pairs
11
+ # @attr_reader created_at [String] ISO-8601 creation timestamp
12
+ # @attr_reader updated_at [String] ISO-8601 last-update timestamp
13
+ class Entitlement
14
+ ATTRS = %i[
15
+ entitlement_id subscription_id feature_key
16
+ value metadata created_at updated_at
17
+ ].freeze
18
+
19
+ attr_reader(*ATTRS)
20
+
21
+ # @param attrs [Hash{String,Symbol => Object}]
22
+ def initialize(attrs = {})
23
+ ATTRS.each do |attr|
24
+ value = attrs[attr.to_s] || attrs[attr]
25
+ instance_variable_set(:"@#{attr}", value)
26
+ end
27
+ end
28
+
29
+ # @param hash [Hash]
30
+ # @return [BillingIO::Entitlement]
31
+ def self.from_hash(hash)
32
+ new(hash)
33
+ end
34
+
35
+ # @return [Hash{String => Object}]
36
+ def to_h
37
+ ATTRS.each_with_object({}) do |attr, h|
38
+ h[attr.to_s] = instance_variable_get(:"@#{attr}")
39
+ end
40
+ end
41
+
42
+ def inspect
43
+ "#<BillingIO::Entitlement entitlement_id=#{@entitlement_id.inspect} feature_key=#{@feature_key.inspect}>"
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BillingIO
4
+ # Represents the result of an entitlement check.
5
+ #
6
+ # @attr_reader entitled [Boolean] whether the customer has the entitlement
7
+ # @attr_reader feature_key [String] the feature key that was checked
8
+ # @attr_reader value [Object, nil] entitlement value if entitled
9
+ class EntitlementCheck
10
+ ATTRS = %i[entitled feature_key value].freeze
11
+
12
+ attr_reader(*ATTRS)
13
+
14
+ # @param attrs [Hash{String,Symbol => Object}]
15
+ def initialize(attrs = {})
16
+ ATTRS.each do |attr|
17
+ value = attrs[attr.to_s] || attrs[attr]
18
+ instance_variable_set(:"@#{attr}", value)
19
+ end
20
+ end
21
+
22
+ # @param hash [Hash]
23
+ # @return [BillingIO::EntitlementCheck]
24
+ def self.from_hash(hash)
25
+ new(hash)
26
+ end
27
+
28
+ # @return [Hash{String => Object}]
29
+ def to_h
30
+ ATTRS.each_with_object({}) do |attr, h|
31
+ h[attr.to_s] = instance_variable_get(:"@#{attr}")
32
+ end
33
+ end
34
+
35
+ def inspect
36
+ "#<BillingIO::EntitlementCheck feature_key=#{@feature_key.inspect} entitled=#{@entitled.inspect}>"
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BillingIO
4
+ # Represents a reusable payment link.
5
+ #
6
+ # @attr_reader payment_link_id [String] unique identifier (prefixed +pl_+)
7
+ # @attr_reader url [String] hosted payment URL
8
+ # @attr_reader amount_usd [Float, nil] fixed amount in USD (nil for open-amount)
9
+ # @attr_reader chain [String, nil] blockchain network
10
+ # @attr_reader token [String, nil] stablecoin token
11
+ # @attr_reader metadata [Hash, nil] arbitrary key-value pairs
12
+ # @attr_reader status [String] link status
13
+ # @attr_reader created_at [String] ISO-8601 creation timestamp
14
+ class PaymentLink
15
+ ATTRS = %i[
16
+ payment_link_id url amount_usd chain token
17
+ metadata status created_at
18
+ ].freeze
19
+
20
+ attr_reader(*ATTRS)
21
+
22
+ # @param attrs [Hash{String,Symbol => Object}]
23
+ def initialize(attrs = {})
24
+ ATTRS.each do |attr|
25
+ value = attrs[attr.to_s] || attrs[attr]
26
+ instance_variable_set(:"@#{attr}", value)
27
+ end
28
+ end
29
+
30
+ # @param hash [Hash]
31
+ # @return [BillingIO::PaymentLink]
32
+ def self.from_hash(hash)
33
+ new(hash)
34
+ end
35
+
36
+ # @return [Hash{String => Object}]
37
+ def to_h
38
+ ATTRS.each_with_object({}) do |attr, h|
39
+ h[attr.to_s] = instance_variable_get(:"@#{attr}")
40
+ end
41
+ end
42
+
43
+ def inspect
44
+ "#<BillingIO::PaymentLink payment_link_id=#{@payment_link_id.inspect} url=#{@url.inspect} status=#{@status.inspect}>"
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BillingIO
4
+ # Represents a stored payment method (wallet address or card token).
5
+ #
6
+ # @attr_reader payment_method_id [String] unique identifier (prefixed +pm_+)
7
+ # @attr_reader customer_id [String] owning customer
8
+ # @attr_reader type [String] payment method type
9
+ # @attr_reader chain [String, nil] blockchain network
10
+ # @attr_reader token [String, nil] stablecoin token
11
+ # @attr_reader address [String, nil] wallet address
12
+ # @attr_reader is_default [Boolean] whether this is the default method
13
+ # @attr_reader metadata [Hash, nil] arbitrary key-value pairs
14
+ # @attr_reader status [String] method status
15
+ # @attr_reader created_at [String] ISO-8601 creation timestamp
16
+ # @attr_reader updated_at [String] ISO-8601 last-update timestamp
17
+ class PaymentMethod
18
+ ATTRS = %i[
19
+ payment_method_id customer_id type chain token
20
+ address is_default metadata status
21
+ created_at updated_at
22
+ ].freeze
23
+
24
+ attr_reader(*ATTRS)
25
+
26
+ # @param attrs [Hash{String,Symbol => Object}]
27
+ def initialize(attrs = {})
28
+ ATTRS.each do |attr|
29
+ value = attrs[attr.to_s] || attrs[attr]
30
+ instance_variable_set(:"@#{attr}", value)
31
+ end
32
+ end
33
+
34
+ # @param hash [Hash]
35
+ # @return [BillingIO::PaymentMethod]
36
+ def self.from_hash(hash)
37
+ new(hash)
38
+ end
39
+
40
+ # @return [Hash{String => Object}]
41
+ def to_h
42
+ ATTRS.each_with_object({}) do |attr, h|
43
+ h[attr.to_s] = instance_variable_get(:"@#{attr}")
44
+ end
45
+ end
46
+
47
+ def inspect
48
+ "#<BillingIO::PaymentMethod payment_method_id=#{@payment_method_id.inspect} type=#{@type.inspect} is_default=#{@is_default.inspect}>"
49
+ end
50
+ end
51
+ end