@pithy-sh/payments 0.1.1 → 0.1.3
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.
- package/dist/admin/coverage.d.ts +35 -0
- package/dist/admin/coverage.d.ts.map +1 -0
- package/dist/admin/coverage.js +56 -0
- package/dist/admin/read.d.ts +222 -0
- package/dist/admin/read.d.ts.map +1 -0
- package/dist/admin/read.js +159 -0
- package/dist/audit/actions.d.ts +211 -0
- package/dist/audit/actions.d.ts.map +1 -0
- package/dist/audit/actions.js +211 -0
- package/dist/capability.d.ts +72 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +228 -0
- package/dist/client/api.d.ts +435 -0
- package/dist/client/api.d.ts.map +1 -0
- package/dist/client/api.js +415 -0
- package/dist/client/checkout.d.ts +144 -0
- package/dist/client/checkout.d.ts.map +1 -0
- package/dist/client/checkout.js +173 -0
- package/dist/client/fixtures/price-preview-de.js +89 -0
- package/dist/client/fixtures/price-preview-gb.js +89 -0
- package/dist/client/fixtures/price-preview-jp-yen.js +89 -0
- package/dist/client/fixtures/price-preview-us-country-only.js +89 -0
- package/dist/client/fixtures/price-preview-us-new-york.js +89 -0
- package/dist/client/fixtures/pricePreview.d.ts +54 -0
- package/dist/client/fixtures/pricePreview.d.ts.map +1 -0
- package/dist/client/fixtures/pricePreview.js +61 -0
- package/dist/client/hooks.d.ts +235 -0
- package/dist/client/hooks.d.ts.map +1 -0
- package/dist/client/hooks.js +428 -0
- package/dist/client/paddle.d.ts +433 -0
- package/dist/client/paddle.d.ts.map +1 -0
- package/dist/client/paddle.js +391 -0
- package/dist/client/paddleCache.d.ts +123 -0
- package/dist/client/paddleCache.d.ts.map +1 -0
- package/dist/client/paddleCache.js +159 -0
- package/dist/client/paddlePrices.d.ts +94 -0
- package/dist/client/paddlePrices.d.ts.map +1 -0
- package/dist/client/paddlePrices.js +55 -0
- package/dist/client/paddlePricesTag.d.ts +127 -0
- package/dist/client/paddlePricesTag.d.ts.map +1 -0
- package/dist/client/paddlePricesTag.js +207 -0
- package/dist/client/projection.d.ts +128 -0
- package/dist/client/projection.d.ts.map +1 -0
- package/dist/client/projection.js +0 -0
- package/dist/client/test-utils/cacheStore.d.ts +18 -0
- package/dist/client/test-utils/cacheStore.d.ts.map +1 -0
- package/dist/client/test-utils/cacheStore.js +42 -0
- package/dist/client/wholeUnits.d.ts +18 -0
- package/dist/client/wholeUnits.d.ts.map +1 -0
- package/dist/client/wholeUnits.js +120 -0
- package/dist/config/config.d.ts +238 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +249 -0
- package/dist/data/discount.d.ts +127 -0
- package/dist/data/discount.d.ts.map +1 -0
- package/dist/data/discount.js +91 -0
- package/dist/data/entitlement.d.ts +43 -0
- package/dist/data/entitlement.d.ts.map +1 -0
- package/dist/data/entitlement.js +43 -0
- package/dist/data/money.d.ts +15 -0
- package/dist/data/money.d.ts.map +1 -0
- package/dist/data/money.js +76 -0
- package/dist/data/pause.d.ts +133 -0
- package/dist/data/pause.d.ts.map +1 -0
- package/dist/data/pause.js +63 -0
- package/dist/data/providerAccount.d.ts +40 -0
- package/dist/data/providerAccount.d.ts.map +1 -0
- package/dist/data/providerAccount.js +34 -0
- package/dist/data/purchase.d.ts +107 -0
- package/dist/data/purchase.d.ts.map +1 -0
- package/dist/data/purchase.js +77 -0
- package/dist/data/rail.d.ts +74 -0
- package/dist/data/rail.d.ts.map +1 -0
- package/dist/data/rail.js +74 -0
- package/dist/data/reconcileRun.d.ts +120 -0
- package/dist/data/reconcileRun.d.ts.map +1 -0
- package/dist/data/reconcileRun.js +120 -0
- package/dist/data/renderMoney.d.ts +85 -0
- package/dist/data/renderMoney.d.ts.map +1 -0
- package/dist/data/renderMoney.js +146 -0
- package/dist/data/status.d.ts +58 -0
- package/dist/data/status.d.ts.map +1 -0
- package/dist/data/status.js +68 -0
- package/dist/data/subject.d.ts +111 -0
- package/dist/data/subject.d.ts.map +1 -0
- package/dist/data/subject.js +125 -0
- package/dist/data/subscription.d.ts +624 -0
- package/dist/data/subscription.d.ts.map +1 -0
- package/dist/data/subscription.js +497 -0
- package/dist/data/syncCursor.d.ts +33 -0
- package/dist/data/syncCursor.d.ts.map +1 -0
- package/dist/data/syncCursor.js +29 -0
- package/dist/data/tables.d.ts +37 -0
- package/dist/data/tables.d.ts.map +1 -0
- package/dist/data/tables.js +44 -0
- package/dist/data/webhookEvent.d.ts +134 -0
- package/dist/data/webhookEvent.d.ts.map +1 -0
- package/dist/data/webhookEvent.js +128 -0
- package/dist/entitlement/manual.d.ts +101 -0
- package/dist/entitlement/manual.d.ts.map +1 -0
- package/dist/entitlement/manual.js +84 -0
- package/dist/entitlement/resolver.d.ts +60 -0
- package/dist/entitlement/resolver.d.ts.map +1 -0
- package/dist/entitlement/resolver.js +101 -0
- package/dist/entitlement/subjectSeam.d.ts +102 -0
- package/dist/entitlement/subjectSeam.d.ts.map +1 -0
- package/dist/entitlement/subjectSeam.js +85 -0
- package/dist/error/errors.d.ts +247 -0
- package/dist/error/errors.d.ts.map +1 -0
- package/dist/error/errors.js +326 -0
- package/dist/grants/apply.d.ts +74 -0
- package/dist/grants/apply.d.ts.map +1 -0
- package/dist/grants/apply.js +148 -0
- package/dist/grants/clawback.d.ts +43 -0
- package/dist/grants/clawback.d.ts.map +1 -0
- package/dist/grants/clawback.js +71 -0
- package/dist/grants/ledgerSeam.d.ts +89 -0
- package/dist/grants/ledgerSeam.d.ts.map +1 -0
- package/dist/grants/ledgerSeam.js +66 -0
- package/dist/http/dispatch.d.ts +35 -0
- package/dist/http/dispatch.d.ts.map +1 -0
- package/dist/http/dispatch.js +40 -0
- package/dist/http/guards.d.ts +43 -0
- package/dist/http/guards.d.ts.map +1 -0
- package/dist/http/guards.js +52 -0
- package/dist/http/manifestConfig.d.ts +38 -0
- package/dist/http/manifestConfig.d.ts.map +1 -0
- package/dist/http/manifestConfig.js +49 -0
- package/dist/http/responses.d.ts +1455 -0
- package/dist/http/responses.d.ts.map +1 -0
- package/dist/http/responses.js +728 -0
- package/dist/http/routes.d.ts +315 -0
- package/dist/http/routes.d.ts.map +1 -0
- package/dist/http/routes.js +1966 -0
- package/dist/http/schemas.d.ts +404 -0
- package/dist/http/schemas.d.ts.map +1 -0
- package/dist/http/schemas.js +359 -0
- package/dist/http/scopes.d.ts +160 -0
- package/dist/http/scopes.d.ts.map +1 -0
- package/dist/http/scopes.js +240 -0
- package/dist/http/view.d.ts +96 -0
- package/dist/http/view.d.ts.map +1 -0
- package/dist/http/view.js +170 -0
- package/dist/http/webhookGuard.d.ts +109 -0
- package/dist/http/webhookGuard.d.ts.map +1 -0
- package/dist/http/webhookGuard.js +206 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/migrations/0001_purchases.d.ts +35 -0
- package/dist/migrations/0001_purchases.d.ts.map +1 -0
- package/dist/migrations/0001_purchases.js +80 -0
- package/dist/pricing/location.d.ts +138 -0
- package/dist/pricing/location.d.ts.map +1 -0
- package/dist/pricing/location.js +81 -0
- package/dist/pricing/visitor.d.ts +56 -0
- package/dist/pricing/visitor.d.ts.map +1 -0
- package/dist/pricing/visitor.js +35 -0
- package/dist/projection/event.d.ts +66 -0
- package/dist/projection/event.d.ts.map +1 -0
- package/dist/projection/event.js +45 -0
- package/dist/projection/orphans.d.ts +114 -0
- package/dist/projection/orphans.d.ts.map +1 -0
- package/dist/projection/orphans.js +162 -0
- package/dist/projection/owner.d.ts +121 -0
- package/dist/projection/owner.d.ts.map +1 -0
- package/dist/projection/owner.js +114 -0
- package/dist/projection/resolve.d.ts +30 -0
- package/dist/projection/resolve.d.ts.map +1 -0
- package/dist/projection/resolve.js +42 -0
- package/dist/projection/writer.d.ts +103 -0
- package/dist/projection/writer.d.ts.map +1 -0
- package/dist/projection/writer.js +280 -0
- package/dist/provision/resolvePaymentsConfig.d.ts +48 -0
- package/dist/provision/resolvePaymentsConfig.d.ts.map +1 -0
- package/dist/provision/resolvePaymentsConfig.js +41 -0
- package/dist/rails/apple/certs.d.ts +7 -0
- package/dist/rails/apple/certs.d.ts.map +1 -0
- package/dist/rails/apple/certs.js +8 -0
- package/dist/rails/apple/der.d.ts +107 -0
- package/dist/rails/apple/der.d.ts.map +1 -0
- package/dist/rails/apple/der.js +217 -0
- package/dist/rails/apple/fixtures/chain.d.ts +117 -0
- package/dist/rails/apple/fixtures/chain.d.ts.map +1 -0
- package/dist/rails/apple/fixtures/chain.js +289 -0
- package/dist/rails/apple/http.d.ts +74 -0
- package/dist/rails/apple/http.d.ts.map +1 -0
- package/dist/rails/apple/http.js +32 -0
- package/dist/rails/apple/jws.d.ts +17 -0
- package/dist/rails/apple/jws.d.ts.map +1 -0
- package/dist/rails/apple/jws.js +75 -0
- package/dist/rails/apple/notification.d.ts +116 -0
- package/dist/rails/apple/notification.d.ts.map +1 -0
- package/dist/rails/apple/notification.js +199 -0
- package/dist/rails/apple/rail.d.ts +25 -0
- package/dist/rails/apple/rail.d.ts.map +1 -0
- package/dist/rails/apple/rail.js +68 -0
- package/dist/rails/apple/serverApi.d.ts +120 -0
- package/dist/rails/apple/serverApi.d.ts.map +1 -0
- package/dist/rails/apple/serverApi.js +244 -0
- package/dist/rails/apple/verify.d.ts +36 -0
- package/dist/rails/apple/verify.d.ts.map +1 -0
- package/dist/rails/apple/verify.js +46 -0
- package/dist/rails/apple/x509.d.ts +85 -0
- package/dist/rails/apple/x509.d.ts.map +1 -0
- package/dist/rails/apple/x509.js +273 -0
- package/dist/rails/contract.d.ts +871 -0
- package/dist/rails/contract.d.ts.map +1 -0
- package/dist/rails/contract.js +60 -0
- package/dist/rails/google/fixtures/push.d.ts +71 -0
- package/dist/rails/google/fixtures/push.d.ts.map +1 -0
- package/dist/rails/google/fixtures/push.js +107 -0
- package/dist/rails/google/http.d.ts +77 -0
- package/dist/rails/google/http.d.ts.map +1 -0
- package/dist/rails/google/http.js +39 -0
- package/dist/rails/google/jwt.d.ts +53 -0
- package/dist/rails/google/jwt.d.ts.map +1 -0
- package/dist/rails/google/jwt.js +94 -0
- package/dist/rails/google/oidc.d.ts +112 -0
- package/dist/rails/google/oidc.d.ts.map +1 -0
- package/dist/rails/google/oidc.js +179 -0
- package/dist/rails/google/playApi.d.ts +188 -0
- package/dist/rails/google/playApi.d.ts.map +1 -0
- package/dist/rails/google/playApi.js +350 -0
- package/dist/rails/google/rail.d.ts +57 -0
- package/dist/rails/google/rail.d.ts.map +1 -0
- package/dist/rails/google/rail.js +70 -0
- package/dist/rails/google/rtdn.d.ts +105 -0
- package/dist/rails/google/rtdn.d.ts.map +1 -0
- package/dist/rails/google/rtdn.js +179 -0
- package/dist/rails/google/verify.d.ts +20 -0
- package/dist/rails/google/verify.d.ts.map +1 -0
- package/dist/rails/google/verify.js +76 -0
- package/dist/rails/lemonSqueezy/api.d.ts +92 -0
- package/dist/rails/lemonSqueezy/api.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/api.js +121 -0
- package/dist/rails/lemonSqueezy/checkout.d.ts +52 -0
- package/dist/rails/lemonSqueezy/checkout.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/checkout.js +84 -0
- package/dist/rails/lemonSqueezy/discounts.d.ts +50 -0
- package/dist/rails/lemonSqueezy/discounts.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/discounts.js +75 -0
- package/dist/rails/lemonSqueezy/fixtures/events.d.ts +56 -0
- package/dist/rails/lemonSqueezy/fixtures/events.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/fixtures/events.js +144 -0
- package/dist/rails/lemonSqueezy/objects.d.ts +229 -0
- package/dist/rails/lemonSqueezy/objects.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/objects.js +379 -0
- package/dist/rails/lemonSqueezy/portal.d.ts +35 -0
- package/dist/rails/lemonSqueezy/portal.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/portal.js +18 -0
- package/dist/rails/lemonSqueezy/pricing.d.ts +25 -0
- package/dist/rails/lemonSqueezy/pricing.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/pricing.js +54 -0
- package/dist/rails/lemonSqueezy/rail.d.ts +41 -0
- package/dist/rails/lemonSqueezy/rail.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/rail.js +67 -0
- package/dist/rails/lemonSqueezy/read.d.ts +28 -0
- package/dist/rails/lemonSqueezy/read.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/read.js +37 -0
- package/dist/rails/lemonSqueezy/refresh.d.ts +42 -0
- package/dist/rails/lemonSqueezy/refresh.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/refresh.js +40 -0
- package/dist/rails/lemonSqueezy/signature.d.ts +56 -0
- package/dist/rails/lemonSqueezy/signature.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/signature.js +92 -0
- package/dist/rails/lemonSqueezy/verify.d.ts +33 -0
- package/dist/rails/lemonSqueezy/verify.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/verify.js +41 -0
- package/dist/rails/lemonSqueezy/webhook.d.ts +53 -0
- package/dist/rails/lemonSqueezy/webhook.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/webhook.js +179 -0
- package/dist/rails/paddle/adjustments.d.ts +60 -0
- package/dist/rails/paddle/adjustments.d.ts.map +1 -0
- package/dist/rails/paddle/adjustments.js +66 -0
- package/dist/rails/paddle/api.d.ts +138 -0
- package/dist/rails/paddle/api.d.ts.map +1 -0
- package/dist/rails/paddle/api.js +152 -0
- package/dist/rails/paddle/checkout.d.ts +69 -0
- package/dist/rails/paddle/checkout.d.ts.map +1 -0
- package/dist/rails/paddle/checkout.js +100 -0
- package/dist/rails/paddle/discounts.d.ts +67 -0
- package/dist/rails/paddle/discounts.d.ts.map +1 -0
- package/dist/rails/paddle/discounts.js +73 -0
- package/dist/rails/paddle/events.d.ts +140 -0
- package/dist/rails/paddle/events.d.ts.map +1 -0
- package/dist/rails/paddle/events.js +183 -0
- package/dist/rails/paddle/fixtures/browserForged.d.ts +42 -0
- package/dist/rails/paddle/fixtures/browserForged.d.ts.map +1 -0
- package/dist/rails/paddle/fixtures/browserForged.js +52 -0
- package/dist/rails/paddle/fixtures/pausedSubscription.d.ts +78 -0
- package/dist/rails/paddle/fixtures/pausedSubscription.d.ts.map +1 -0
- package/dist/rails/paddle/fixtures/pausedSubscription.js +76 -0
- package/dist/rails/paddle/objects.d.ts +519 -0
- package/dist/rails/paddle/objects.d.ts.map +1 -0
- package/dist/rails/paddle/objects.js +588 -0
- package/dist/rails/paddle/portal.d.ts +45 -0
- package/dist/rails/paddle/portal.d.ts.map +1 -0
- package/dist/rails/paddle/portal.js +42 -0
- package/dist/rails/paddle/rail.d.ts +55 -0
- package/dist/rails/paddle/rail.d.ts.map +1 -0
- package/dist/rails/paddle/rail.js +117 -0
- package/dist/rails/paddle/read.d.ts +53 -0
- package/dist/rails/paddle/read.d.ts.map +1 -0
- package/dist/rails/paddle/read.js +66 -0
- package/dist/rails/paddle/recorded.d.ts +49 -0
- package/dist/rails/paddle/recorded.d.ts.map +1 -0
- package/dist/rails/paddle/recorded.js +79 -0
- package/dist/rails/paddle/refresh.d.ts +54 -0
- package/dist/rails/paddle/refresh.d.ts.map +1 -0
- package/dist/rails/paddle/refresh.js +94 -0
- package/dist/rails/paddle/refund.d.ts +82 -0
- package/dist/rails/paddle/refund.d.ts.map +1 -0
- package/dist/rails/paddle/refund.js +175 -0
- package/dist/rails/paddle/signature.d.ts +83 -0
- package/dist/rails/paddle/signature.d.ts.map +1 -0
- package/dist/rails/paddle/signature.js +163 -0
- package/dist/rails/paddle/subscription.d.ts +137 -0
- package/dist/rails/paddle/subscription.d.ts.map +1 -0
- package/dist/rails/paddle/subscription.js +538 -0
- package/dist/rails/paddle/verify.d.ts +46 -0
- package/dist/rails/paddle/verify.d.ts.map +1 -0
- package/dist/rails/paddle/verify.js +43 -0
- package/dist/rails/paddle/webhook.d.ts +98 -0
- package/dist/rails/paddle/webhook.d.ts.map +1 -0
- package/dist/rails/paddle/webhook.js +181 -0
- package/dist/rails/providers.d.ts +73 -0
- package/dist/rails/providers.d.ts.map +1 -0
- package/dist/rails/providers.js +62 -0
- package/dist/rails/stripe/api.d.ts +118 -0
- package/dist/rails/stripe/api.d.ts.map +1 -0
- package/dist/rails/stripe/api.js +153 -0
- package/dist/rails/stripe/checkout.d.ts +60 -0
- package/dist/rails/stripe/checkout.d.ts.map +1 -0
- package/dist/rails/stripe/checkout.js +86 -0
- package/dist/rails/stripe/discounts.d.ts +50 -0
- package/dist/rails/stripe/discounts.d.ts.map +1 -0
- package/dist/rails/stripe/discounts.js +87 -0
- package/dist/rails/stripe/fixtures/events.d.ts +64 -0
- package/dist/rails/stripe/fixtures/events.d.ts.map +1 -0
- package/dist/rails/stripe/fixtures/events.js +67 -0
- package/dist/rails/stripe/objects.d.ts +237 -0
- package/dist/rails/stripe/objects.d.ts.map +1 -0
- package/dist/rails/stripe/objects.js +389 -0
- package/dist/rails/stripe/portal.d.ts +29 -0
- package/dist/rails/stripe/portal.d.ts.map +1 -0
- package/dist/rails/stripe/portal.js +41 -0
- package/dist/rails/stripe/pricing.d.ts +25 -0
- package/dist/rails/stripe/pricing.d.ts.map +1 -0
- package/dist/rails/stripe/pricing.js +68 -0
- package/dist/rails/stripe/rail.d.ts +28 -0
- package/dist/rails/stripe/rail.d.ts.map +1 -0
- package/dist/rails/stripe/rail.js +81 -0
- package/dist/rails/stripe/refresh.d.ts +33 -0
- package/dist/rails/stripe/refresh.d.ts.map +1 -0
- package/dist/rails/stripe/refresh.js +21 -0
- package/dist/rails/stripe/signature.d.ts +71 -0
- package/dist/rails/stripe/signature.d.ts.map +1 -0
- package/dist/rails/stripe/signature.js +92 -0
- package/dist/rails/stripe/verify.d.ts +15 -0
- package/dist/rails/stripe/verify.d.ts.map +1 -0
- package/dist/rails/stripe/verify.js +63 -0
- package/dist/rails/stripe/webhook.d.ts +26 -0
- package/dist/rails/stripe/webhook.d.ts.map +1 -0
- package/dist/rails/stripe/webhook.js +31 -0
- package/dist/secret/registry.d.ts +192 -0
- package/dist/secret/registry.d.ts.map +1 -0
- package/dist/secret/registry.js +154 -0
- package/dist/seeds/example.d.ts +3 -0
- package/dist/seeds/example.d.ts.map +1 -0
- package/dist/seeds/example.js +171 -0
- package/dist/version.generated.d.ts +5 -0
- package/dist/version.generated.d.ts.map +1 -0
- package/dist/version.generated.js +7 -0
- package/dist/workflows/paddleSweep.d.ts +175 -0
- package/dist/workflows/paddleSweep.d.ts.map +1 -0
- package/dist/workflows/paddleSweep.js +433 -0
- package/dist/workflows/railAccess.d.ts +48 -0
- package/dist/workflows/railAccess.d.ts.map +1 -0
- package/dist/workflows/railAccess.js +36 -0
- package/dist/workflows/reconcile.d.ts +161 -0
- package/dist/workflows/reconcile.d.ts.map +1 -0
- package/dist/workflows/reconcile.js +352 -0
- package/dist/workflows/report.d.ts +28 -0
- package/dist/workflows/report.d.ts.map +1 -0
- package/dist/workflows/report.js +54 -0
- package/dist/workflows/retryPolicy.d.ts +29 -0
- package/dist/workflows/retryPolicy.d.ts.map +1 -0
- package/dist/workflows/retryPolicy.js +37 -0
- package/dist/workflows/specs.d.ts +102 -0
- package/dist/workflows/specs.d.ts.map +1 -0
- package/dist/workflows/specs.js +84 -0
- package/dist/workflows/worker.d.ts +62 -0
- package/dist/workflows/worker.d.ts.map +1 -0
- package/dist/workflows/worker.js +92 -0
- package/dist/workflows/workerConfig.d.ts +46 -0
- package/dist/workflows/workerConfig.d.ts.map +1 -0
- package/dist/workflows/workerConfig.js +38 -0
- package/package.json +22 -13
- package/pithy.manifest.json +19 -13
- package/src/version.generated.ts +1 -1
- package/src/client/paddlePrices.iife.ts +0 -43
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
import { type PaymentsFailure, type PaymentsPaddleDisplayMode, type PaymentsPaddleEnvironment, type PaymentsResult } from "./api";
|
|
2
|
+
import { type PaddleQuoteCache } from "./paddleCache";
|
|
3
|
+
/**
|
|
4
|
+
* Paddle.js: loading it once, asking it what this visitor pays, and reading the answer safely.
|
|
5
|
+
*
|
|
6
|
+
* **This is the half of the Paddle rail a redirect cannot do.** The server mints transactions and takes
|
|
7
|
+
* webhooks; nothing on that side can tell a visitor in Berlin that the $5.00 they see includes $0.80 of
|
|
8
|
+
* VAT while a visitor in Chicago will be charged $5.75. Only a script running in that browser, talking to
|
|
9
|
+
* Paddle from that IP, knows — so the whole of localized pricing lives here or it does not exist.
|
|
10
|
+
*
|
|
11
|
+
* **Never format a price yourself here, and never write one down.** Paddle returns `formattedTotals`
|
|
12
|
+
* already rendered for the visitor: the right symbol, the right separators, and whole units for the
|
|
13
|
+
* zero-decimal currencies (¥725 is `725`, not `72500`). The raw amounts are exposed too, but they are for
|
|
14
|
+
* **comparing**, never for showing.
|
|
15
|
+
*
|
|
16
|
+
* **The reason this line used to give was false, and it was measured false (#465, 2026-08-28).** It said a
|
|
17
|
+
* kit reaching for `Intl.NumberFormat` "would have to carry a table of which currencies have two decimals,
|
|
18
|
+
* and would get one wrong". `Intl` carries that table, from CLDR:
|
|
19
|
+
* `new Intl.NumberFormat(locale, { style: "currency", currency }).resolvedOptions().maximumFractionDigits`
|
|
20
|
+
* answers 2 for `USD` and `GBP` and 0 for `JPY`, `KRW` and `CLP`, and renders `$65.82`, `¥6,582` and
|
|
21
|
+
* `₩6,582` from the same 6582. Paddle's own documentation instructs adopters to do exactly this — "use a
|
|
22
|
+
* currency library to format monetary values to the correct number of decimals… symbols and decimal
|
|
23
|
+
* separators are placed correctly" (api-reference/about/data-types).
|
|
24
|
+
*
|
|
25
|
+
* **What the kit still refuses is deriving an AMOUNT, and that is the rule this paragraph is load-bearing
|
|
26
|
+
* for.** The figure is Paddle's; a renderer places a point and attaches a symbol and decides nothing about
|
|
27
|
+
* how much money there is. Where Paddle already rendered the string — here, on the pricing surfaces, where
|
|
28
|
+
* `formattedTotals` exists — that string is what ships, because a second rendering of one price is a second
|
|
29
|
+
* spelling of it and the visitor's browser locale is not the one Paddle used. Where Paddle renders nothing
|
|
30
|
+
* — `subscriptions.preview` and `transactions.preview` return no formatted field at any depth, verified
|
|
31
|
+
* against the recordings — the alternative to rendering is a confirmation screen with no figure on it. That
|
|
32
|
+
* case is `data/renderMoney.ts`, on the server, from the negotiated locale, and it carries the measurement
|
|
33
|
+
* that the exponent must come from ISO 4217 rather than from CLDR's display digits.
|
|
34
|
+
*
|
|
35
|
+
* **Amended: removing a zero fraction from Paddle's string is not composing one (Jim, 2026-08-21).** The
|
|
36
|
+
* rule above was read as forbidding any touch of a formatted total, and two adopter surfaces each wrote
|
|
37
|
+
* their own `total.replace(/([.,])00(?=\D*$)/, "")` rather than break it — the same wrong regex, twice,
|
|
38
|
+
* in two repositories (`#427`). Nothing is assembled by dropping an all-zero fraction: the symbol, the
|
|
39
|
+
* separators, the grouping and the digits are still the ones Paddle chose, and one run of characters is
|
|
40
|
+
* gone. What the rule actually forbids is *deciding* what a price looks like from raw minor units, and
|
|
41
|
+
* that decision is still Paddle's. So {@link PriceSummaryOptions.wholeUnits} exists, is off unless a
|
|
42
|
+
* caller asks, and removes only a fraction the arithmetic in `./wholeUnits` has already proved is zero —
|
|
43
|
+
* which is the part neither adopter could do, because `totals` never leaves this package.
|
|
44
|
+
*
|
|
45
|
+
* **What "localized" actually means, measured rather than assumed.** With no `unit_price_overrides` on
|
|
46
|
+
* the price, every country is billed in the catalog's currency — a preview from a UK address on a USD
|
|
47
|
+
* price comes back in dollars. Currency is a catalog decision. What this delivers without one is tax
|
|
48
|
+
* and formatting, which is real: the US adds tax to the listed figure and settles it at the postal code,
|
|
49
|
+
* while the EU, the UK and Japan take it out of an inclusive one. {@link priceSummary} is where that
|
|
50
|
+
* difference stops being a footnote and becomes two different sentences.
|
|
51
|
+
*
|
|
52
|
+
* **No API key is reachable from this module or any other under `src/client/`.** The client token is
|
|
53
|
+
* publishable by design and is the only credential that belongs in a browser. `paddle.test.ts` sweeps the
|
|
54
|
+
* directory for the shapes of the ones that do not.
|
|
55
|
+
*
|
|
56
|
+
* Cookie/session and same-origin are irrelevant here: none of this talks to the adopter's Worker. It
|
|
57
|
+
* talks to Paddle, with Paddle's own publishable token, exactly as Paddle's documentation intends.
|
|
58
|
+
*/
|
|
59
|
+
/** Paddle.js could not be loaded at all: an ad blocker, a Content Security Policy, or no network. */
|
|
60
|
+
export declare const PADDLE_UNAVAILABLE: PaymentsFailure;
|
|
61
|
+
/**
|
|
62
|
+
* Paddle.js loaded and then refused to initialize. A token from the wrong account is the usual cause.
|
|
63
|
+
*
|
|
64
|
+
* Distinct from {@link PADDLE_UNAVAILABLE} because the two are fixed by different people: one is the
|
|
65
|
+
* visitor's browser, the other is the project's configuration.
|
|
66
|
+
*/
|
|
67
|
+
export declare const PADDLE_NOT_INITIALIZED: PaymentsFailure;
|
|
68
|
+
/** A second, different Paddle account was asked for on a page that already has one. */
|
|
69
|
+
export declare const PADDLE_ACCOUNT_CONFLICT: PaymentsFailure;
|
|
70
|
+
/** Paddle refused the price request itself — an unknown price id, or a token scoped elsewhere. */
|
|
71
|
+
export declare const PADDLE_PREVIEW_REFUSED: PaymentsFailure;
|
|
72
|
+
/** What Paddle.js needs to start: the publishable token, and which account it belongs to. */
|
|
73
|
+
export interface PaddleSetup {
|
|
74
|
+
/** Paddle's publishable client token — `test_…` in sandbox, `live_…` in production. */
|
|
75
|
+
clientToken: string;
|
|
76
|
+
/** Which Paddle account the token belongs to. Sandbox and live are separate accounts, not a flag. */
|
|
77
|
+
environment: PaymentsPaddleEnvironment;
|
|
78
|
+
}
|
|
79
|
+
/** One line of a price request. */
|
|
80
|
+
export interface PaddlePriceItem {
|
|
81
|
+
/** The Paddle price — `pri_…`. `paymentsConfig.products[].skus.paddle` carries it. */
|
|
82
|
+
priceId: string;
|
|
83
|
+
/** How many. Paddle refuses a quantity outside the price's own `quantity` bounds. */
|
|
84
|
+
quantity: number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* What to ask a price for, and on whose behalf.
|
|
88
|
+
*
|
|
89
|
+
* **Location is optional, and where it comes from is a real decision.** Omitted, Paddle resolves it from
|
|
90
|
+
* the browser's own IP, which is right for a marketing page nobody has signed in to. A Worker can do
|
|
91
|
+
* better for a signed-in visitor: `request.cf.country` is on every Cloudflare request, and a customer
|
|
92
|
+
* with a saved address has one on file at Paddle already — pass `customerId` and Paddle uses it.
|
|
93
|
+
*
|
|
94
|
+
* **Send a postal code where you have one.** United States tax resolves at the postal code, not the
|
|
95
|
+
* country: 15% in Chicago, 8.875% in New York, 0% in Oregon — and 0% for the country with no code at
|
|
96
|
+
* all. A country-only preview therefore quotes an American buyer $5.00 for something they will be
|
|
97
|
+
* charged $5.44 for. {@link priceSummary} says so rather than letting the page imply otherwise.
|
|
98
|
+
*/
|
|
99
|
+
export interface PaddlePriceQuery {
|
|
100
|
+
/** The prices to quote. */
|
|
101
|
+
items: readonly PaddlePriceItem[];
|
|
102
|
+
/** Where the visitor is. Omit to let Paddle resolve it from their IP. */
|
|
103
|
+
address?: {
|
|
104
|
+
countryCode: string;
|
|
105
|
+
postalCode?: string;
|
|
106
|
+
};
|
|
107
|
+
/** An existing Paddle customer, whose saved address Paddle will use. */
|
|
108
|
+
customerId?: string;
|
|
109
|
+
/** An IP to resolve location from, for a server that knows it better than the browser does. */
|
|
110
|
+
customerIpAddress?: string;
|
|
111
|
+
/** Force a currency. Only meaningful where the catalog has an override for it. */
|
|
112
|
+
currencyCode?: string;
|
|
113
|
+
/** A resolved Paddle discount — `dsc_…`. Never a raw code; resolving one needs the API key. */
|
|
114
|
+
discountId?: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The slice of Paddle.js this kit touches, declared structurally.
|
|
118
|
+
*
|
|
119
|
+
* Structural rather than `import type { Paddle }` for the reason `PaymentsFetch` is structural: this file
|
|
120
|
+
* compiles inside an adopter's browser program, and a narrow shape is one they can satisfy with a stub
|
|
121
|
+
* where the real type drags Paddle's whole graph in. `paddle.test.ts` pins it against the real `Paddle`
|
|
122
|
+
* type at compile time, so it cannot drift when Paddle renames something.
|
|
123
|
+
*/
|
|
124
|
+
export interface PaddleJs {
|
|
125
|
+
/** Whether `Initialize` has run and succeeded. Paddle.js sets it; nothing here writes it. */
|
|
126
|
+
Initialized: boolean;
|
|
127
|
+
/** Which account this instance talks to. Must be set before `Initialize`, which the loader does. */
|
|
128
|
+
Environment: {
|
|
129
|
+
set(environment: PaymentsPaddleEnvironment): void;
|
|
130
|
+
};
|
|
131
|
+
/** Prices for this visitor. The camelCase mirror of the server's `pricing-preview` endpoint. */
|
|
132
|
+
PricePreview(params: PaddlePriceQuery): Promise<unknown>;
|
|
133
|
+
/** The overlay and the inline frame. See {@link PaddleCheckoutOpen} for what this kit may hand it. */
|
|
134
|
+
Checkout: {
|
|
135
|
+
/** Open a checkout. Synchronous and returns nothing — a refusal arrives as a throw or not at all. */
|
|
136
|
+
open(options: PaddleCheckoutOpen): void;
|
|
137
|
+
/** Close whatever is open. Nothing happens when nothing is. */
|
|
138
|
+
close(): void;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Light or dark. Paddle's whole theme surface, and the only one there is.
|
|
143
|
+
*
|
|
144
|
+
* Not a palette. Colors, fonts, borders and focus states are configured in the Paddle dashboard and are
|
|
145
|
+
* not expressible from code at all — see {@link PaddleCheckoutSettings.theme} for where and why.
|
|
146
|
+
*/
|
|
147
|
+
export type PaddleCheckoutTheme = "light" | "dark";
|
|
148
|
+
/**
|
|
149
|
+
* Whether the card form is one page or several.
|
|
150
|
+
*
|
|
151
|
+
* Paddle's own type carries a third value, `express`, which its checkout-settings documentation does not
|
|
152
|
+
* list. Absent here rather than passed through: this kit hands Paddle only what Paddle documents a seller
|
|
153
|
+
* may set, and a value nobody can point at a page for is one nobody can support.
|
|
154
|
+
*/
|
|
155
|
+
export type PaddleCheckoutVariant = "one-page" | "multi-page";
|
|
156
|
+
/**
|
|
157
|
+
* How one checkout is presented. Paddle takes the same settings at `Initialize` and here.
|
|
158
|
+
*
|
|
159
|
+
* **Here, deliberately.** The loader is one per page and these are per checkout: the display mode comes
|
|
160
|
+
* off a handoff the server minted, and the container class is the screen's, so a page with a paywall and
|
|
161
|
+
* a pricing panel must be able to open two checkouts differently without re-initializing Paddle — which
|
|
162
|
+
* it cannot do, because `Initialize` runs once. Paddle's own documentation says `frameTarget` goes in
|
|
163
|
+
* `Paddle.Initialize()`; its `Checkout.open` reference then passes exactly these fields per call, and the
|
|
164
|
+
* live sandbox honors them on both forms. Where the two disagree, the measurement wins.
|
|
165
|
+
*
|
|
166
|
+
* **Every field here is optional and stays absent when nobody named one.** Paddle reads these over
|
|
167
|
+
* account-level settings a seller configured in the dashboard, so a key present and `undefined` is not
|
|
168
|
+
* the same message as no key — see `settingsFor` in `./checkout`, which is where that is enforced.
|
|
169
|
+
*/
|
|
170
|
+
export interface PaddleCheckoutSettings {
|
|
171
|
+
/** Over the page, or inside the element {@link PaddleCheckoutSettings.frameTarget} names. */
|
|
172
|
+
displayMode?: PaymentsPaddleDisplayMode;
|
|
173
|
+
/**
|
|
174
|
+
* Light or dark. Paddle defaults to `light`, which is why an app in dark mode has to say so.
|
|
175
|
+
*
|
|
176
|
+
* **Never inferred, and that is a decision rather than an omission.** Nothing in this kit reads
|
|
177
|
+
* `prefers-color-scheme`, samples a computed style, or calls `matchMedia`: the OS preference is not the
|
|
178
|
+
* app's theme — an app with its own toggle, or one that is dark whatever the OS says, would get a card
|
|
179
|
+
* form contradicting the page it opened over. The adopter knows; guessing wrong is worse than
|
|
180
|
+
* defaulting, and a wrong guess is harder to find than a missing option.
|
|
181
|
+
*
|
|
182
|
+
* **This is the whole of the theming Paddle exposes to code.** Colors, fonts, borders, hover and focus
|
|
183
|
+
* states are set in the Paddle dashboard under *Checkout → Branded inline checkout* (and logo plus
|
|
184
|
+
* brand color for the overlay). That is Paddle's deliberate product decision, not a missing endpoint,
|
|
185
|
+
* so there is no option to add here for it and nothing to go looking for.
|
|
186
|
+
*/
|
|
187
|
+
theme?: PaddleCheckoutTheme;
|
|
188
|
+
/** The buyer's language — `"fr"`, `"pt-BR"`. Paddle defaults to the browser's. Pass it where the app has its own. */
|
|
189
|
+
locale?: string;
|
|
190
|
+
/** One page or several. Paddle defaults to `multi-page`. */
|
|
191
|
+
variant?: PaddleCheckoutVariant;
|
|
192
|
+
/** The **class name** — not an id, not a selector — of the element an inline checkout renders into. */
|
|
193
|
+
frameTarget?: string;
|
|
194
|
+
/** Styles for that element. Paddle needs `min-width` at 312px or the merchant-of-record footer is cut off. */
|
|
195
|
+
frameStyle?: string;
|
|
196
|
+
/** Its height in pixels on load, before the frame resizes itself. Paddle recommends 450. */
|
|
197
|
+
frameInitialHeight?: number;
|
|
198
|
+
/** Where a buyer who paid is sent. From the server, never from a screen — see {@link PaddleCheckoutOpen}. */
|
|
199
|
+
successUrl?: string;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* What this kit is willing to open a checkout for: a transaction, and how to show it.
|
|
203
|
+
*
|
|
204
|
+
* **`items` and `customData` are absent, and their absence is deliberate in two different ways.**
|
|
205
|
+
*
|
|
206
|
+
* `items[]` is what makes Paddle pleasant — no server call, a checkout in one click — and it is also a
|
|
207
|
+
* checkout whose price and whose buyer are chosen by the page. This capability takes both from the
|
|
208
|
+
* catalog entry a product id resolves to, everywhere else, so that a client cannot buy Pro for the price
|
|
209
|
+
* of a coin pack. A transaction the server minted is that same rule, kept here.
|
|
210
|
+
*
|
|
211
|
+
* `customData` is the harder one, because leaving it out does **not** make the stamp safe. Measured live:
|
|
212
|
+
* Paddle accepts `customData` beside a `transactionId` and overwrites the `custom_data` the server wrote
|
|
213
|
+
* on that transaction. So omitting it here is hygiene — this kit has nothing to say through that field
|
|
214
|
+
* that it has not already said on the server — and the thing that actually protects ownership is the MAC
|
|
215
|
+
* in `../rails/paddle/objects.ts`. A reader who takes this type as the security boundary would be reading
|
|
216
|
+
* it wrongly, which is why it says so.
|
|
217
|
+
*/
|
|
218
|
+
export interface PaddleCheckoutOpen {
|
|
219
|
+
/** The transaction the server created — `txn_…`. The only thing a checkout here is ever opened for. */
|
|
220
|
+
transactionId: string;
|
|
221
|
+
/** How to present it. */
|
|
222
|
+
settings?: PaddleCheckoutSettings;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* How Paddle.js is fetched and started.
|
|
226
|
+
*
|
|
227
|
+
* The default is `initializePaddle` from `@paddle/paddle-js`. It is a seam because a test must never
|
|
228
|
+
* reach Paddle's CDN, and because a project with its own script-loading policy may want to hand one in.
|
|
229
|
+
*/
|
|
230
|
+
export type PaddleInitializer = (options: {
|
|
231
|
+
token: string;
|
|
232
|
+
environment?: PaymentsPaddleEnvironment;
|
|
233
|
+
}) => Promise<PaddleJs | undefined>;
|
|
234
|
+
/**
|
|
235
|
+
* Where "one initialization per page" is remembered.
|
|
236
|
+
*
|
|
237
|
+
* A parameter with a module-level default rather than a hidden singleton with a reset button. The
|
|
238
|
+
* default is the page, which is what every screen wants; a test passes its own and gets a fresh page
|
|
239
|
+
* without an escape hatch existing in shipped code for anyone else to reach for.
|
|
240
|
+
*/
|
|
241
|
+
export interface PaddleRegistry {
|
|
242
|
+
/** The one load in flight or already done, and which account it was for. */
|
|
243
|
+
current?: {
|
|
244
|
+
key: string;
|
|
245
|
+
paddle: Promise<PaymentsResult<PaddleJs>>;
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
/** What {@link loadPaddle} and {@link previewPrices} let a caller replace, and where a quote may rest. */
|
|
249
|
+
export interface PaddleOptions {
|
|
250
|
+
/** How to fetch and start Paddle.js. Defaults to `@paddle/paddle-js`. */
|
|
251
|
+
initialize?: PaddleInitializer;
|
|
252
|
+
/** Where the one-per-page load is remembered. Defaults to the page's own. */
|
|
253
|
+
registry?: PaddleRegistry;
|
|
254
|
+
/**
|
|
255
|
+
* Where a quote may be cached, under what name, and for how long. Omitted, nothing is cached.
|
|
256
|
+
*
|
|
257
|
+
* All three parts or none — see `readQuoteCache`. There is no default store and no default lifetime,
|
|
258
|
+
* because a quote resolved for a signed-in customer is that customer's price, and neither where it
|
|
259
|
+
* rests nor how long it stands is a thing this package may pick for the program that knows who is
|
|
260
|
+
* looking at it.
|
|
261
|
+
*/
|
|
262
|
+
cache?: PaddleQuoteCache;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Load and initialize Paddle.js, once per page.
|
|
266
|
+
*
|
|
267
|
+
* Idempotent by construction rather than by documentation: the first call's promise is remembered and
|
|
268
|
+
* every later call for the same account is handed the same one, so two components mounting at once
|
|
269
|
+
* produce one script and one `Initialize`. A call for a *different* account is refused — Paddle.js holds
|
|
270
|
+
* one environment and one token per page, `Environment.set` after `Initialize` leaves it half-moved, and
|
|
271
|
+
* silently re-pointing a live account at a sandbox is not a failure anyone would notice until a real
|
|
272
|
+
* card was declined.
|
|
273
|
+
*
|
|
274
|
+
* **`Environment.set` runs for sandbox and for production alike**, before `Initialize`. Passing it
|
|
275
|
+
* explicitly both ways is what makes the environment a declared fact rather than a default nobody looked
|
|
276
|
+
* at — and the two are separate accounts with separate tokens, so a token used against the wrong one is
|
|
277
|
+
* refused outright.
|
|
278
|
+
*
|
|
279
|
+
* Nothing here throws. A blocked script, a server render with no `window`, and a token the account
|
|
280
|
+
* rejects are three different {@link PaymentsFailure}s, because they are three different problems.
|
|
281
|
+
*/
|
|
282
|
+
export declare function loadPaddle(setup: PaddleSetup, options?: PaddleOptions): Promise<PaymentsResult<PaddleJs>>;
|
|
283
|
+
/** Four amounts, as Paddle sends them. Formatted or raw depending on which field they came off. */
|
|
284
|
+
export interface PriceTotals {
|
|
285
|
+
/** The price before tax. */
|
|
286
|
+
subtotal: string;
|
|
287
|
+
/** What any discount took off. */
|
|
288
|
+
discount: string;
|
|
289
|
+
/** The tax. */
|
|
290
|
+
tax: string;
|
|
291
|
+
/** What the buyer pays. Always `subtotal - discount + tax`. */
|
|
292
|
+
total: string;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* How tax sits against the figure the catalog lists, resolved for this visitor.
|
|
296
|
+
*
|
|
297
|
+
* Not a country table, and not readable off `taxMode` either: a price set to `location` — Paddle's own
|
|
298
|
+
* default — resolves to `added` in Denver and `included` in Berlin, and the mode says only that Paddle
|
|
299
|
+
* will decide. So this is derived from the numbers Paddle returned, by asking which of them is the
|
|
300
|
+
* listed price.
|
|
301
|
+
*
|
|
302
|
+
* - `added` — the listed price is the subtotal, and tax goes on top. The US convention.
|
|
303
|
+
* - `included` — the listed price is the total, and tax comes out of it. The EU, UK and Japan.
|
|
304
|
+
* - `none` — no tax at this address. The question does not arise; both readings are the same number.
|
|
305
|
+
* - `unknown` — it cannot be told. A currency conversion, or a discount, moved both figures away from
|
|
306
|
+
* the listed one. The total is still exactly what the buyer pays, which is what a screen renders.
|
|
307
|
+
*/
|
|
308
|
+
export type PriceTaxTreatment = "added" | "included" | "none" | "unknown";
|
|
309
|
+
/** One quoted price. */
|
|
310
|
+
export interface PriceLine {
|
|
311
|
+
/** The Paddle price this quotes — `pri_…`. */
|
|
312
|
+
priceId: string;
|
|
313
|
+
/** The product's name, as the catalog has it. */
|
|
314
|
+
productName: string;
|
|
315
|
+
/** The price's own name — "Monthly" — or null. */
|
|
316
|
+
priceName: string | null;
|
|
317
|
+
/** How many units this line quotes. */
|
|
318
|
+
quantity: number;
|
|
319
|
+
/** The tax rate as a decimal string — `"0.08875"`. `"0"` where none applies. */
|
|
320
|
+
taxRate: string;
|
|
321
|
+
/** How often this bills, or null for a one-off. */
|
|
322
|
+
billingCycle: {
|
|
323
|
+
interval: string;
|
|
324
|
+
frequency: number;
|
|
325
|
+
} | null;
|
|
326
|
+
/** Per unit, in minor units. For comparing. Never render these. */
|
|
327
|
+
unitTotals: PriceTotals;
|
|
328
|
+
/** The whole line, in minor units. For comparing. Never render these. */
|
|
329
|
+
totals: PriceTotals;
|
|
330
|
+
/** Per unit, rendered by Paddle for this visitor. Render these. */
|
|
331
|
+
formattedUnitTotals: PriceTotals;
|
|
332
|
+
/** The whole line, rendered by Paddle for this visitor. Render these. */
|
|
333
|
+
formattedTotals: PriceTotals;
|
|
334
|
+
/** Where tax sits against the listed figure here. */
|
|
335
|
+
taxTreatment: PriceTaxTreatment;
|
|
336
|
+
}
|
|
337
|
+
/** What Paddle quoted this visitor. */
|
|
338
|
+
export interface PricePreview {
|
|
339
|
+
/** The currency the quote is in. The catalog's, unless an override or `currencyCode` moved it. */
|
|
340
|
+
currencyCode: string;
|
|
341
|
+
/** The country Paddle resolved, or null. */
|
|
342
|
+
countryCode: string | null;
|
|
343
|
+
/**
|
|
344
|
+
* The postal code the quote was resolved at, or null.
|
|
345
|
+
*
|
|
346
|
+
* Null is load-bearing, not incidental. United States tax resolves below the country, so a quote with
|
|
347
|
+
* no postal code can be short by up to 15% — and Paddle returns it as `0%` rather than as an error.
|
|
348
|
+
*/
|
|
349
|
+
postalCode: string | null;
|
|
350
|
+
/** One line per item asked for, in the order asked. */
|
|
351
|
+
lines: readonly PriceLine[];
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Narrow Paddle's answer, or refuse it.
|
|
355
|
+
*
|
|
356
|
+
* **This is a trust boundary and it is treated as one.** The response comes from a third party's script
|
|
357
|
+
* over a network this kit does not control, and a page that read `lineItems[0].formattedTotals.total`
|
|
358
|
+
* off whatever arrived would render `undefined` as a price. Every field a caller can reach is checked
|
|
359
|
+
* here; nothing partial gets through, because half a price is worse than none.
|
|
360
|
+
*
|
|
361
|
+
* Hand-written guards rather than Zod, for the reason `api.ts` gives: this compiles into a browser
|
|
362
|
+
* bundle and must not drag the server's schema graph in behind it.
|
|
363
|
+
*/
|
|
364
|
+
export declare function readPricePreview(answer: unknown): PricePreview | null;
|
|
365
|
+
/**
|
|
366
|
+
* Ask Paddle what this visitor pays.
|
|
367
|
+
*
|
|
368
|
+
* Loads Paddle.js if it is not loaded, which is why a screen needs no separate setup step. Every failure
|
|
369
|
+
* on the way — a blocked script, a refused token, an unreadable answer — arrives as a
|
|
370
|
+
* {@link PaymentsFailure} and never as a thrown error and never as a number.
|
|
371
|
+
*/
|
|
372
|
+
export declare function previewPrices(setup: PaddleSetup, query: PaddlePriceQuery, options?: PaddleOptions): Promise<PaymentsResult<PricePreview>>;
|
|
373
|
+
/** What a pricing screen puts on the page for one line. */
|
|
374
|
+
export interface PriceSummary {
|
|
375
|
+
/** The figure that goes in large type, already rendered by Paddle. */
|
|
376
|
+
headline: string;
|
|
377
|
+
/** One sentence about tax, or null when there is nothing true to say. */
|
|
378
|
+
note: string | null;
|
|
379
|
+
/**
|
|
380
|
+
* Whether the tax in this quote may be short of what the buyer is charged.
|
|
381
|
+
*
|
|
382
|
+
* True when no postal code was resolved. United States tax lives below the country, so a country-only
|
|
383
|
+
* quote comes back at 0% and the card is charged more. A screen that hides this is the defect this
|
|
384
|
+
* whole module exists to avoid.
|
|
385
|
+
*/
|
|
386
|
+
estimated: boolean;
|
|
387
|
+
}
|
|
388
|
+
/** What a caller may ask {@link priceSummary} to do differently. */
|
|
389
|
+
export interface PriceSummaryOptions {
|
|
390
|
+
/**
|
|
391
|
+
* Drop the headline's fraction where it is entirely zero — `$6.00` becomes `$6`, `<U+200F>٦٫٠٠٠ د.ك.<U+200F>` becomes
|
|
392
|
+
* `<U+200F>٦ د.ك.<U+200F>`.
|
|
393
|
+
*
|
|
394
|
+
* **Off unless a caller says so, and that is the decision rather than the default.** A seller pricing
|
|
395
|
+
* at `$6.99` is unaffected either way, because only an all-zero fraction ever goes — but which figures
|
|
396
|
+
* a page advertises is a pricing decision, and the kit does not get to make it. An option is a caller
|
|
397
|
+
* saying *I do*.
|
|
398
|
+
*
|
|
399
|
+
* **Only the headline.** A tax sentence names an amount nobody chose: it is a rate applied to a base,
|
|
400
|
+
* so one plan's tax landing on a round number while the next plan's does not would put `$0.44` and
|
|
401
|
+
* `$1` in the same column. `./wholeUnits` is where the removal is argued and tested.
|
|
402
|
+
*/
|
|
403
|
+
readonly wholeUnits?: boolean;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* The one number to show, and the one sentence that makes it true.
|
|
407
|
+
*
|
|
408
|
+
* **The headline is not the same field in every country, and that is the point.** Where tax is added on
|
|
409
|
+
* top the listed price is the subtotal, and quoting the total would advertise a New Yorker's local sales
|
|
410
|
+
* tax as part of the price. Where tax is taken out of an inclusive figure the listed price *is* the
|
|
411
|
+
* total, and quoting the subtotal would advertise €4.20 for something that costs €5.00. One hardcoded
|
|
412
|
+
* string cannot mean "before tax" in Denver and "including VAT" in Berlin, so this returns two.
|
|
413
|
+
*
|
|
414
|
+
* It lives in the package rather than in the scaffolded screen for the reason the hooks do: an adopter's
|
|
415
|
+
* `pricing.tsx` is written once and never rewritten, and tax conventions are not a thing to freeze into
|
|
416
|
+
* somebody else's repository.
|
|
417
|
+
*
|
|
418
|
+
* Per unit, always. A pricing page quotes "$5.00 a month", not "$15.00 for the three seats you have not
|
|
419
|
+
* chosen yet"; a cart that wants the line total reads `formattedTotals` itself.
|
|
420
|
+
*/
|
|
421
|
+
export declare function priceSummary(preview: PricePreview, line: PriceLine, options?: PriceSummaryOptions): PriceSummary;
|
|
422
|
+
/**
|
|
423
|
+
* A stable key for a query, so an effect can depend on what was asked rather than on the object.
|
|
424
|
+
*
|
|
425
|
+
* A screen writes `usePricePreview(setup, { items: [{ priceId, quantity: 1 }] })` inline, which is a new
|
|
426
|
+
* object every render. An effect depending on it would fetch forever. Depending on this instead means
|
|
427
|
+
* the request repeats when — and only when — something about the request changed.
|
|
428
|
+
*
|
|
429
|
+
* Field order is fixed here rather than taken from the object, because `{ a, b }` and `{ b, a }` are the
|
|
430
|
+
* same query and `JSON.stringify` disagrees.
|
|
431
|
+
*/
|
|
432
|
+
export declare function priceQueryKey(query: PaddlePriceQuery): string;
|
|
433
|
+
//# sourceMappingURL=paddle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paddle.d.ts","sourceRoot":"","sources":["../../src/client/paddle.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB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