@thecryptodonkey/toll-booth 3.3.1 → 3.4.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.
@@ -43,18 +43,14 @@ export async function handleCreateInvoice(deps, request) {
43
43
  if (!Number.isSafeInteger(requestedAmount) || requestedAmount < 1 || requestedAmount > 2_100_000_000_000_000) {
44
44
  return { success: false, error: 'amountSats must be a positive integer' };
45
45
  }
46
- // Find matching tier or validate amount
46
+ // Find matching tier for bonus credits, or accept custom amount at 1:1
47
47
  let creditSats = requestedAmount;
48
48
  if (deps.tiers.length > 0) {
49
49
  const tier = deps.tiers.find(t => t.amountSats === requestedAmount);
50
- if (!tier) {
51
- return {
52
- success: false,
53
- error: 'Invalid amount. Choose from available tiers.',
54
- tiers: deps.tiers,
55
- };
50
+ if (tier) {
51
+ creditSats = tier.creditSats;
56
52
  }
57
- creditSats = tier.creditSats;
53
+ // Custom amounts are accepted at 1:1 (no bonus) — no rejection
58
54
  }
59
55
  let paymentHash;
60
56
  let bolt11;
@@ -77,6 +77,10 @@ export function createTollBooth(config) {
77
77
  if (pricedEntry !== undefined && isTieredPricing(pricedEntry)) {
78
78
  challengeBody.tiers = normaliseTiersMap(pricedEntry);
79
79
  }
80
+ // Include credit purchase tiers so clients can offer volume discounts
81
+ if (config.creditTiers && config.creditTiers.length > 0) {
82
+ challengeBody.credit_tiers = config.creditTiers;
83
+ }
80
84
  // Store invoice data from L402 rail if present
81
85
  const l402Data = challengeBody.l402;
82
86
  if (l402Data?.payment_hash) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecryptodonkey/toll-booth",
3
- "version": "3.3.1",
3
+ "version": "3.4.0",
4
4
  "type": "module",
5
5
  "description": "Monetise any API with HTTP 402 payments. Payment-rail agnostic middleware for Express, Hono, Deno, Bun, and Workers.",
6
6
  "license": "MIT",