@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 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/client/api.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,uGAAuG;AACvG,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAE9C;;;;;;GAMG;AACH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A;CAAE,GAClD;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,eAAe,CAAA;CAAE,CAAC;AAElD;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EAC9E,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CAMhC;AAED,4GAA4G;AAC5G,wBAAsB,iBAAiB,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAGxG;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,GAAG,QAAQ,EAAE,MAAM,CAAC,CAGhF,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAKzG;AAED,kEAAkE;AAClE,MAAM,WAAW,qBAAqB;IACpC,iFAAiF;IACjF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yFAAyF;IACzF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,MAAM,GAAG,IAAI,CAKtF"}
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
//#region src/client/api.ts
|
|
2
|
+
/**
|
|
3
|
+
* The framework-free half of the client surface: five calls against this project's own payments routes,
|
|
4
|
+
* and the guards that make their answers safe to read.
|
|
5
|
+
*
|
|
6
|
+
* **This module lives in the package on purpose.** `pithy ui add` writes a screen once and may never
|
|
7
|
+
* rewrite it, and a frozen paywall ages badly — store rules move under it, so price-change consent
|
|
8
|
+
* prompts, external purchase link entitlements, and subscription-management requirements all arrive
|
|
9
|
+
* after the file was written. So the calls, the error mapping, and the redirect-and-return dance ship
|
|
10
|
+
* here and upgrade with a minor release; the scaffolded stub renders and styles, and calls these.
|
|
11
|
+
*
|
|
12
|
+
* **Cookie/session, same origin.** Every request carries `credentials: "include"` and nothing else. No
|
|
13
|
+
* token in `localStorage` or `sessionStorage`, no `Authorization` header, no refresh rotation. The SPA
|
|
14
|
+
* and its Worker share an origin, so the session rides an httpOnly cookie that JavaScript cannot read
|
|
15
|
+
* and the server's same-origin check covers CSRF. Bearer is the mobile path — supported by the same
|
|
16
|
+
* routes, documented rather than scaffolded.
|
|
17
|
+
*
|
|
18
|
+
* **Nothing here throws, and nothing here hides a failure either.** An unreachable Worker, an HTML error
|
|
19
|
+
* page from a proxy, a 500 — each becomes a renderable {@link PaymentsFailure} on a `PaymentsResult`, and
|
|
20
|
+
* every reader answers one. Failing shut is a decision for a caller to make and to write down: a route
|
|
21
|
+
* guard does `result.ok && result.value.some(…)`, a screen that names the plan reports the failure
|
|
22
|
+
* instead. A reader that collapsed the two would make the choice for callers that must not have it made
|
|
23
|
+
* for them, which is what `api.test.ts` now holds the module to.
|
|
24
|
+
*
|
|
25
|
+
* The server's `requireEntitlement()` is still the security boundary. Nothing on this side of the wire
|
|
26
|
+
* protects a feature; it only decides what a screen shows.
|
|
27
|
+
*
|
|
28
|
+
* **No absolute URL literals, and no schema library.** Paths are relative, so the calls follow whatever
|
|
29
|
+
* origin the bundle is served from. Answers are narrowed by hand-written `is…(value: unknown): value is T`
|
|
30
|
+
* guards rather than Zod: this file is compiled into a browser bundle, and it must not drag the server's
|
|
31
|
+
* schema graph in behind it.
|
|
32
|
+
*/
|
|
33
|
+
/** Where the payments routes mount by default — the same default `PaymentsConfig.basePath` carries. */
|
|
34
|
+
const PAYMENTS_BASE_PATH = "/payments";
|
|
35
|
+
/**
|
|
36
|
+
* The query parameter a returning Stripe buyer carries the Checkout Session id in.
|
|
37
|
+
*
|
|
38
|
+
* It is a default, not a rule: `config.stripe.successUrl` is the adopter's own URL, and the documented
|
|
39
|
+
* shape puts `{CHECKOUT_SESSION_ID}` in `?session=`. A project that named it something else passes the
|
|
40
|
+
* name to {@link returnedCheckoutSession}.
|
|
41
|
+
*/
|
|
42
|
+
const CHECKOUT_SESSION_PARAM = "session";
|
|
43
|
+
/**
|
|
44
|
+
* The runtime mirror of {@link PaymentsHostedRail} — and the one list a screen gates a billing button on.
|
|
45
|
+
*
|
|
46
|
+
* Exported rather than private, because the screens need it. A scaffolded subscription page shows
|
|
47
|
+
* "Manage billing" when any hosted rail is on, and a scaffolded paywall offers to sell on any hosted
|
|
48
|
+
* rail a product is listed on: both are the same question, and both were open-coding the answer. A rail
|
|
49
|
+
* added to the package now reaches a template that was copied into an adopter's repo a year ago,
|
|
50
|
+
* because the template imports this rather than repeating it.
|
|
51
|
+
*
|
|
52
|
+
* Selling and portal-minting are one list, not two that agree — `CheckoutRail` declares both methods
|
|
53
|
+
* together, so a rail cannot have one without the other. `../data/rail.ts` carries the argument in full,
|
|
54
|
+
* and `providers.test.ts` holds this list to the rails that actually implement the interface.
|
|
55
|
+
*/
|
|
56
|
+
const PAYMENTS_HOSTED_RAILS = [
|
|
57
|
+
"stripe",
|
|
58
|
+
"lemonSqueezy",
|
|
59
|
+
"paddle"
|
|
60
|
+
];
|
|
61
|
+
/** The runtime mirrors of the two unions above, for the guards. */
|
|
62
|
+
const PADDLE_ENVIRONMENTS = ["sandbox", "production"];
|
|
63
|
+
const PADDLE_DISPLAY_MODES = ["overlay", "inline"];
|
|
64
|
+
/** The worker could not be reached at all. Offline, or a DNS failure, or a hard CORS refusal. */
|
|
65
|
+
const PAYMENTS_UNREACHABLE = {
|
|
66
|
+
code: "client/unreachable",
|
|
67
|
+
message: "We couldn't reach the store.",
|
|
68
|
+
action: "Check your connection, then try again."
|
|
69
|
+
};
|
|
70
|
+
/** The worker answered with something this client cannot read. A proxy's HTML page, or a shape change. */
|
|
71
|
+
const PAYMENTS_UNREADABLE = {
|
|
72
|
+
code: "client/unreadable",
|
|
73
|
+
message: "The store answered with something we couldn't read.",
|
|
74
|
+
action: "Try again. If it keeps happening, the app and the backend are out of step."
|
|
75
|
+
};
|
|
76
|
+
/** There is no browser here to send anywhere — server-side rendering, or a test with no DOM. */
|
|
77
|
+
const PAYMENTS_NO_BROWSER = {
|
|
78
|
+
code: "client/no_browser",
|
|
79
|
+
message: "There's no browser to send you to the payment page.",
|
|
80
|
+
action: "Start checkout from the page in the browser, not before it has loaded."
|
|
81
|
+
};
|
|
82
|
+
/** Whether a value is a plain record — the first step of every guard below. */
|
|
83
|
+
function isRecord(value) {
|
|
84
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
85
|
+
}
|
|
86
|
+
/** Whether a value is a string, or explicitly null. The shape every nullable timestamp arrives in. */
|
|
87
|
+
function isNullableString(value) {
|
|
88
|
+
return value === null || typeof value === "string";
|
|
89
|
+
}
|
|
90
|
+
/** Whether a value is one of a fixed set of strings. */
|
|
91
|
+
function isMember(value, members) {
|
|
92
|
+
return typeof value === "string" && members.includes(value);
|
|
93
|
+
}
|
|
94
|
+
const RAILS = [
|
|
95
|
+
"apple",
|
|
96
|
+
"google",
|
|
97
|
+
"stripe",
|
|
98
|
+
"lemonSqueezy",
|
|
99
|
+
"paddle"
|
|
100
|
+
];
|
|
101
|
+
const PRODUCT_TYPES = [
|
|
102
|
+
"consumable",
|
|
103
|
+
"non_consumable",
|
|
104
|
+
"subscription"
|
|
105
|
+
];
|
|
106
|
+
const STATUSES = [
|
|
107
|
+
"active",
|
|
108
|
+
"in_grace",
|
|
109
|
+
"on_hold",
|
|
110
|
+
"canceled",
|
|
111
|
+
"expired",
|
|
112
|
+
"never_paid",
|
|
113
|
+
"refunded",
|
|
114
|
+
"revoked",
|
|
115
|
+
"paused"
|
|
116
|
+
];
|
|
117
|
+
const ENVIRONMENTS = ["production", "sandbox"];
|
|
118
|
+
const OUTCOMES = [
|
|
119
|
+
"created",
|
|
120
|
+
"updated",
|
|
121
|
+
"ignored"
|
|
122
|
+
];
|
|
123
|
+
/** Whether a value is one entitlement as the route returns it. */
|
|
124
|
+
function isEntitlementView(value) {
|
|
125
|
+
return isRecord(value) && typeof value.key === "string" && typeof value.granted === "boolean" && isNullableString(value.expiresAt);
|
|
126
|
+
}
|
|
127
|
+
/** Whether a value is one purchase as the write routes return it. */
|
|
128
|
+
function isPurchaseView(value) {
|
|
129
|
+
return isRecord(value) && typeof value.id === "string" && isMember(value.rail, RAILS) && typeof value.productId === "string" && isMember(value.type, PRODUCT_TYPES) && isMember(value.status, STATUSES) && isMember(value.environment, ENVIRONMENTS) && typeof value.purchasedAt === "string" && isNullableString(value.expiresAt) && isMember(value.outcome, OUTCOMES);
|
|
130
|
+
}
|
|
131
|
+
/** Every element, or nothing. A half-read list is worse than none — a screen renders the gap as absence. */
|
|
132
|
+
function isArrayOf(value, guard) {
|
|
133
|
+
return Array.isArray(value) && value.every(guard);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Whether a string is a URL this client may navigate to.
|
|
137
|
+
*
|
|
138
|
+
* The scheme check is the point. Such a URL is handed straight to `location.assign`, and
|
|
139
|
+
* `javascript:` there executes in the current page — the same guard the scaffolded sign-in screen makes
|
|
140
|
+
* on a social redirect, made here because here is where the value is read.
|
|
141
|
+
*/
|
|
142
|
+
function isNavigable(value) {
|
|
143
|
+
if (typeof value !== "string") return false;
|
|
144
|
+
try {
|
|
145
|
+
const { protocol } = new URL(value);
|
|
146
|
+
return protocol === "https:" || protocol === "http:";
|
|
147
|
+
} catch {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Whether a value is a checkout handoff this client can act on.
|
|
153
|
+
*
|
|
154
|
+
* Two shapes, and each is checked for what acting on it would do. A `redirect` is navigated to, so its
|
|
155
|
+
* URL goes through {@link isNavigable}. A `paddle` handoff is passed to `Paddle.Checkout.open`, so every
|
|
156
|
+
* field it carries has to be a string of the right kind — an environment or a display mode this client
|
|
157
|
+
* does not know is a server it does not understand, and guessing would open a checkout in the wrong
|
|
158
|
+
* Paddle account.
|
|
159
|
+
*/
|
|
160
|
+
function isCheckoutHandoff(value) {
|
|
161
|
+
if (!isRecord(value)) return false;
|
|
162
|
+
if (value.kind === "redirect") return isNavigable(value.url);
|
|
163
|
+
if (value.kind !== "paddle") return false;
|
|
164
|
+
return isNonEmpty(value.transactionId) && isNonEmpty(value.clientToken) && isMember(value.environment, PADDLE_ENVIRONMENTS) && isMember(value.displayMode, PADDLE_DISPLAY_MODES) && isNavigable(value.successUrl);
|
|
165
|
+
}
|
|
166
|
+
/** Whether a value is a portal handoff: an overview page, and any per-subscription deep links. */
|
|
167
|
+
function isPortalHandoff(value) {
|
|
168
|
+
if (!isRecord(value) || !isNavigable(value.url)) return false;
|
|
169
|
+
if (value.subscriptions === void 0) return true;
|
|
170
|
+
return isArrayOf(value.subscriptions, isPortalSubscription);
|
|
171
|
+
}
|
|
172
|
+
/** Whether a value is one subscription's deep links. Every URL is navigated to, so every URL is checked. */
|
|
173
|
+
function isPortalSubscription(value) {
|
|
174
|
+
return isRecord(value) && isNonEmpty(value.subscriptionId) && isNavigable(value.cancel) && isNavigable(value.updatePaymentMethod);
|
|
175
|
+
}
|
|
176
|
+
/** A non-empty string. */
|
|
177
|
+
function isNonEmpty(value) {
|
|
178
|
+
return typeof value === "string" && value !== "";
|
|
179
|
+
}
|
|
180
|
+
/** The globals to use — the injected ones, else the real ones. */
|
|
181
|
+
function globals(options) {
|
|
182
|
+
return options?.global ?? globalThis;
|
|
183
|
+
}
|
|
184
|
+
/** A failure read off `{ error: { code, message, action } }`, or the generic one when the body is not that. */
|
|
185
|
+
function readFailure(body) {
|
|
186
|
+
if (!isRecord(body) || !isRecord(body.error)) return PAYMENTS_UNREADABLE;
|
|
187
|
+
const { code, message, action, params } = body.error;
|
|
188
|
+
if (typeof code !== "string" || typeof message !== "string") return PAYMENTS_UNREADABLE;
|
|
189
|
+
const scalars = isRecord(params) ? Object.fromEntries(Object.entries(params).filter((entry) => typeof entry[1] === "string" || typeof entry[1] === "number" || typeof entry[1] === "boolean")) : void 0;
|
|
190
|
+
return {
|
|
191
|
+
code,
|
|
192
|
+
message,
|
|
193
|
+
action: typeof action === "string" ? action : null,
|
|
194
|
+
...scalars && Object.keys(scalars).length > 0 ? { params: scalars } : {}
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* One call: same-origin, cookie-carrying, never throwing. **The only producer of that request.**
|
|
199
|
+
*
|
|
200
|
+
* The body is read before the status is judged, because a refusal's body is the failure a screen renders.
|
|
201
|
+
* A body that will not parse is the generic failure rather than a crash — a corporate proxy's HTML page
|
|
202
|
+
* reaches a browser far more often than anyone expects.
|
|
203
|
+
*
|
|
204
|
+
* **Exported, and that is the point of it.** This was private, so `../pricing/visitor.ts` wrote a second
|
|
205
|
+
* fetch with the same base-path default, the same `credentials: "include"`, and the same three failure
|
|
206
|
+
* directions — two producers of one rule, which is the shape of every recurring defect this kit has
|
|
207
|
+
* shipped. The second producer is always the cheap one to add and the one that drifts. Every browser
|
|
208
|
+
* program that asks this Worker a question calls this, and `sameOrigin.test.ts` fails the build on any
|
|
209
|
+
* module that grows its own (#346).
|
|
210
|
+
*
|
|
211
|
+
* **Zod-free, like everything on this side of the wire.** The answer is narrowed by the hand-written
|
|
212
|
+
* `guard` a caller passes, never by a schema: this compiles into an adopter's browser bundle, and
|
|
213
|
+
* dragging the Worker's schema graph in behind it would break their build.
|
|
214
|
+
*/
|
|
215
|
+
async function callPayments(path, init, options, guard) {
|
|
216
|
+
const fetcher = options?.fetch ?? globals(options).fetch;
|
|
217
|
+
if (!fetcher) return {
|
|
218
|
+
ok: false,
|
|
219
|
+
failure: PAYMENTS_UNREACHABLE
|
|
220
|
+
};
|
|
221
|
+
const base = options?.basePath ?? "/payments";
|
|
222
|
+
let response;
|
|
223
|
+
try {
|
|
224
|
+
response = await fetcher(`${base}${path}`, {
|
|
225
|
+
...init,
|
|
226
|
+
credentials: "include"
|
|
227
|
+
});
|
|
228
|
+
} catch {
|
|
229
|
+
return {
|
|
230
|
+
ok: false,
|
|
231
|
+
failure: PAYMENTS_UNREACHABLE
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
let body;
|
|
235
|
+
try {
|
|
236
|
+
body = await response.json();
|
|
237
|
+
} catch {
|
|
238
|
+
return {
|
|
239
|
+
ok: false,
|
|
240
|
+
failure: PAYMENTS_UNREADABLE
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
if (!response.ok) return {
|
|
244
|
+
ok: false,
|
|
245
|
+
failure: readFailure(body)
|
|
246
|
+
};
|
|
247
|
+
return guard(body) ? {
|
|
248
|
+
ok: true,
|
|
249
|
+
value: body
|
|
250
|
+
} : {
|
|
251
|
+
ok: false,
|
|
252
|
+
failure: PAYMENTS_UNREADABLE
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
/** A JSON POST body, serialized once so the request signature stays one shape. */
|
|
256
|
+
function jsonPost(body) {
|
|
257
|
+
return {
|
|
258
|
+
method: "POST",
|
|
259
|
+
headers: { "content-type": "application/json" },
|
|
260
|
+
body: JSON.stringify(body)
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/** Whether a value is the entitlements envelope. */
|
|
264
|
+
function isEntitlementsBody(value) {
|
|
265
|
+
return isRecord(value) && isArrayOf(value.entitlements, isEntitlementView);
|
|
266
|
+
}
|
|
267
|
+
/** Whether a value is the purchase envelope both write routes' single-purchase form returns. */
|
|
268
|
+
function isPurchaseBody(value) {
|
|
269
|
+
return isRecord(value) && isPurchaseView(value.purchase) && isArrayOf(value.entitlements, isEntitlementView);
|
|
270
|
+
}
|
|
271
|
+
/** Whether a value is the restore envelope. */
|
|
272
|
+
function isRestoreBody(value) {
|
|
273
|
+
return isRecord(value) && isArrayOf(value.purchases, isPurchaseView) && isArrayOf(value.entitlements, isEntitlementView);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* The caller's own entitlements. Always the caller's — the id comes from the session, never from here.
|
|
277
|
+
*
|
|
278
|
+
* **A failure is not an empty list**, and the distinction is the whole point of the return type. Failing
|
|
279
|
+
* shut is still the right default for a *lock*, because a lock is a refusal and the caller can carry an
|
|
280
|
+
* escape route on it. It is wrong for a caller that **names** the plan: free is the floor of every ladder,
|
|
281
|
+
* carrying no entitlement key and matching unconditionally, so `[]` is a positive assertion that this
|
|
282
|
+
* customer is on the cheapest tier. A screen rendering that from a failed read tells an Enterprise
|
|
283
|
+
* customer they are on Free and offers to sell them what they already pay for.
|
|
284
|
+
*
|
|
285
|
+
* So the failure `call` already built travels out intact, and a caller that wants fail-shut writes
|
|
286
|
+
* `result.ok ? result.value : []` — one line, and it reads as the decision it is rather than as the
|
|
287
|
+
* absence of one. {@link useEntitlement} does exactly that; {@link useSubscription} reports the failure.
|
|
288
|
+
*/
|
|
289
|
+
async function getEntitlements(options) {
|
|
290
|
+
const result = await callPayments("/entitlements", {}, options, isEntitlementsBody);
|
|
291
|
+
return result.ok ? {
|
|
292
|
+
ok: true,
|
|
293
|
+
value: result.value.entitlements
|
|
294
|
+
} : result;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Submit one receipt for verification, so the buyer sees their entitlement without waiting for the webhook.
|
|
298
|
+
*
|
|
299
|
+
* On the web this is the Stripe return path: `successUrl` carries the Checkout Session id, and posting it
|
|
300
|
+
* here projects the purchase at once. On a native client it is the store SDK's transaction. A replay by
|
|
301
|
+
* its own owner is a 200 with `outcome: "ignored"` — the write path is idempotent, so repeating is free.
|
|
302
|
+
*/
|
|
303
|
+
function submitPurchase(input, options) {
|
|
304
|
+
return callPayments("/purchases", jsonPost(input), options, isPurchaseBody);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Restore Purchases — rebind a store account's history to the signed-in user.
|
|
308
|
+
*
|
|
309
|
+
* Native only in practice: only the device can enumerate what its store account owns. One bad receipt
|
|
310
|
+
* fails the whole batch by design, and every receipt that did project stays projected.
|
|
311
|
+
*/
|
|
312
|
+
function restorePurchases(input, options) {
|
|
313
|
+
return callPayments("/restore", jsonPost(input), options, isRestoreBody);
|
|
314
|
+
}
|
|
315
|
+
/** Create a checkout for a product, and say how the browser reaches it. */
|
|
316
|
+
function createCheckout(input, options) {
|
|
317
|
+
return callPayments("/checkout", jsonPost(input), options, isCheckoutHandoff);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Create a Billing Portal session for the caller's own store account.
|
|
321
|
+
*
|
|
322
|
+
* No body, and that is the request contract: there is exactly one customer this caller may manage, and
|
|
323
|
+
* the server resolves it from the provider-account map. A `customer` field here would be the whole
|
|
324
|
+
* vulnerability.
|
|
325
|
+
*/
|
|
326
|
+
function createPortal(options) {
|
|
327
|
+
return callPayments("/portal", { method: "POST" }, options, isPortalHandoff);
|
|
328
|
+
}
|
|
329
|
+
/** How to leave the page, from the injected navigator or the browser's own. */
|
|
330
|
+
function navigator(options) {
|
|
331
|
+
if (options?.navigate) return options.navigate;
|
|
332
|
+
const location = globals(options).location;
|
|
333
|
+
return location?.assign ? (url) => location.assign?.(url) : void 0;
|
|
334
|
+
}
|
|
335
|
+
/** Go to a URL a guard has already vetted. Null means the browser left; anything else is a failure. */
|
|
336
|
+
function leaveFor(url, options) {
|
|
337
|
+
const go = navigator(options);
|
|
338
|
+
if (!go) return PAYMENTS_NO_BROWSER;
|
|
339
|
+
go(url);
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Buy a product: create the checkout, and either hand the browser over or hand the caller the handoff.
|
|
344
|
+
*
|
|
345
|
+
* A redirect rail needs no SDK script and no client-side key — the server mints a session and answers
|
|
346
|
+
* with a URL, and a full page load is the whole integration. Paddle's overlay and inline modes need
|
|
347
|
+
* Paddle.js and the publishable token the server returned, and opening it is the screen's job because
|
|
348
|
+
* that is where the container lives. Pithy never owns payment UI, SCA, tax, or proration either way.
|
|
349
|
+
*/
|
|
350
|
+
async function startCheckout(input, options) {
|
|
351
|
+
const result = await createCheckout(input, options);
|
|
352
|
+
if (!result.ok) return {
|
|
353
|
+
kind: "refused",
|
|
354
|
+
failure: result.failure
|
|
355
|
+
};
|
|
356
|
+
if (result.value.kind === "paddle") return {
|
|
357
|
+
kind: "paddle",
|
|
358
|
+
handoff: result.value
|
|
359
|
+
};
|
|
360
|
+
const refused = leaveFor(result.value.url, options);
|
|
361
|
+
return refused === null ? { kind: "left" } : {
|
|
362
|
+
kind: "refused",
|
|
363
|
+
failure: refused
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
/** Open the billing portal — where a subscriber changes a card, or cancels, under the store's own rules. */
|
|
367
|
+
async function openBillingPortal(options) {
|
|
368
|
+
const result = await createPortal(options);
|
|
369
|
+
return result.ok ? leaveFor(result.value.url, options) : result.failure;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Where a store sends a subscriber to manage a subscription they bought in an app.
|
|
373
|
+
*
|
|
374
|
+
* These live in the package rather than in a scaffolded screen for the reason the whole client surface
|
|
375
|
+
* does: they are Apple's and Google's URLs, not the adopter's, and when a store moves one the fix should
|
|
376
|
+
* be a minor release rather than an edit to a file Pithy may never rewrite. It is also what keeps the
|
|
377
|
+
* scaffolded templates free of absolute URLs, which the CLI's own scaffold check enforces.
|
|
378
|
+
*
|
|
379
|
+
* There is no Stripe entry. Stripe's equivalent is a *session* the server mints per caller — see
|
|
380
|
+
* {@link openBillingPortal} — and a static URL there would be a link to nobody's account.
|
|
381
|
+
*/
|
|
382
|
+
const STORE_SUBSCRIPTION_URLS = {
|
|
383
|
+
apple: "https://apps.apple.com/account/subscriptions",
|
|
384
|
+
google: "https://play.google.com/store/account/subscriptions"
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* Send the browser to a store's own subscription-management page.
|
|
388
|
+
*
|
|
389
|
+
* Returns false only when there is no browser to send. A web page cannot cancel a StoreKit or Play
|
|
390
|
+
* Billing subscription — the store owns that, by its own rules — so linking there is the whole of what a
|
|
391
|
+
* web screen can honestly offer.
|
|
392
|
+
*/
|
|
393
|
+
function openStoreSubscriptions(rail, options) {
|
|
394
|
+
const go = navigator(options);
|
|
395
|
+
if (!go) return false;
|
|
396
|
+
go(STORE_SUBSCRIPTION_URLS[rail]);
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* The Checkout Session id a returning buyer arrived with, or null.
|
|
401
|
+
*
|
|
402
|
+
* This is the second half of the redirect-and-return dance. Stripe substitutes the real id into the
|
|
403
|
+
* `{CHECKOUT_SESSION_ID}` token in the adopter's `successUrl`, and posting it to `/payments/purchases`
|
|
404
|
+
* projects the purchase immediately instead of waiting for the webhook. The webhook is still
|
|
405
|
+
* authoritative and still arrives — this only decides whether the buyer sees their entitlement now or in
|
|
406
|
+
* a few seconds.
|
|
407
|
+
*/
|
|
408
|
+
function returnedCheckoutSession(options) {
|
|
409
|
+
const search = options?.search ?? (options?.global ?? globalThis).location?.search ?? "";
|
|
410
|
+
if (search === "") return null;
|
|
411
|
+
const value = new URLSearchParams(search).get(options?.param ?? "session");
|
|
412
|
+
return value === null || value === "" ? null : value;
|
|
413
|
+
}
|
|
414
|
+
//#endregion
|
|
415
|
+
export { CHECKOUT_SESSION_PARAM, PAYMENTS_BASE_PATH, PAYMENTS_HOSTED_RAILS, PAYMENTS_NO_BROWSER, PAYMENTS_UNREACHABLE, PAYMENTS_UNREADABLE, STORE_SUBSCRIPTION_URLS, callPayments, createCheckout, createPortal, getEntitlements, isEntitlementView, isPurchaseView, openBillingPortal, openStoreSubscriptions, restorePurchases, returnedCheckoutSession, startCheckout, submitPurchase };
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { type PaddleCheckoutHandoff, type PaymentsFailure } from "./api";
|
|
2
|
+
import { type PaddleCheckoutTheme, type PaddleCheckoutVariant, type PaddleOptions } from "./paddle";
|
|
3
|
+
/**
|
|
4
|
+
* Opening a Paddle checkout over the adopter's own page, or inside it.
|
|
5
|
+
*
|
|
6
|
+
* This is the half of the rail a redirect cannot do. `startCheckout` on a redirect rail sends the browser
|
|
7
|
+
* to somebody else's domain and the sale finishes there; Paddle's overlay draws the card form over the
|
|
8
|
+
* page the buyer was already on, and its inline mode draws it *in* the page, in a container the screen
|
|
9
|
+
* put there. Nothing about the money moves — Paddle is still the merchant of record, still owns SCA, tax
|
|
10
|
+
* and the card fields — but the buyer never leaves.
|
|
11
|
+
*
|
|
12
|
+
* ## `items[]` or `transactionId`, settled
|
|
13
|
+
*
|
|
14
|
+
* Paddle offers two ways to open a checkout. `items: [{ priceId, quantity }]` needs no server at all: a
|
|
15
|
+
* page with the publishable client token can open a checkout in one click, which is the single most
|
|
16
|
+
* pleasant thing about this provider. `transactionId` needs a round trip first, because a transaction is
|
|
17
|
+
* something the server creates.
|
|
18
|
+
*
|
|
19
|
+
* **This kit only ever opens a transaction, and the reason is the price and the buyer — not the stamp.**
|
|
20
|
+
* `items[]` lets the page name what is being sold and to whom, and every other route in this capability
|
|
21
|
+
* takes the price from the catalog entry a product id resolves to precisely so a client cannot buy Pro
|
|
22
|
+
* for the price of a coin pack. There is no reading under which that rule holds at `POST /checkout` and
|
|
23
|
+
* stops holding here. So the cost is one round trip before the overlay appears, paid once per purchase.
|
|
24
|
+
*
|
|
25
|
+
* **What `transactionId` does not buy is the ownership stamp, and that was measured rather than assumed.**
|
|
26
|
+
* #309 argued the stamp needed no proof because `Paddle.Checkout.open` refuses `customData` beside a
|
|
27
|
+
* transaction id. It does not refuse it. Against the live sandbox on 2026-08-13: a server-created
|
|
28
|
+
* transaction stamped `pithy_user: "server-owner"` was opened with
|
|
29
|
+
* `Paddle.Checkout.open({ transactionId, customData: { pithy_user: "attacker", … } })` from a page holding
|
|
30
|
+
* only the publishable client token, paid with a test card, and came back from `GET /transactions/{id}`
|
|
31
|
+
* carrying the attacker's values — same id, `origin` still `"api"`, stamp replaced. The recording is
|
|
32
|
+
* `../rails/paddle/fixtures/browserForged.ts` and the refusal is gated on it.
|
|
33
|
+
*
|
|
34
|
+
* So the two halves are independent, and both are needed. The transaction fixes what is sold; the MAC over
|
|
35
|
+
* `(environment, user)` keyed on the destination secret is the *only* thing that fixes who it belongs to,
|
|
36
|
+
* on either form of the call. See `../rails/paddle/objects.ts` for that half in full, and
|
|
37
|
+
* {@link PaddleCheckoutOpen} in `./paddle` for the type that keeps this one unrepresentable rather than
|
|
38
|
+
* merely conventional.
|
|
39
|
+
*
|
|
40
|
+
* ## How it looks is the caller's to say, and only what Paddle lets code say
|
|
41
|
+
*
|
|
42
|
+
* `theme`, `locale` and `variant` are passed through from the caller and are **never inferred**. No
|
|
43
|
+
* `prefers-color-scheme`, no `matchMedia`, no reading a computed style off the page. The OS preference is
|
|
44
|
+
* not the app's theme: an app with its own light/dark toggle, or one that is dark whatever the machine
|
|
45
|
+
* says, would get a card form contradicting the page it opened over — and a wrong guess is far harder to
|
|
46
|
+
* find than an option nobody passed. The adopter knows. So this takes it, and defaults to Paddle's default
|
|
47
|
+
* by saying nothing.
|
|
48
|
+
*
|
|
49
|
+
* **Saying nothing is a real message.** An omitted setting must reach `Checkout.open` as an absent key,
|
|
50
|
+
* not as a key holding `undefined`, because these overlay account-level settings a seller configured in
|
|
51
|
+
* the Paddle dashboard. {@link settingsFor} builds them one at a time for that reason, and the tests assert
|
|
52
|
+
* on `Object.keys` rather than on values.
|
|
53
|
+
*
|
|
54
|
+
* **Colors and fonts are not here because they are not anywhere in code.** Paddle configures them in its
|
|
55
|
+
* own dashboard — *Checkout → Branded inline checkout* for the 50-odd inline options, logo and brand
|
|
56
|
+
* color for the overlay. That is Paddle's product decision rather than a missing endpoint, and the one
|
|
57
|
+
* API that writes `primary_checkout_color` is a Partners route for a platform configuring another
|
|
58
|
+
* seller's account. Nothing to add here, and nothing to go looking for.
|
|
59
|
+
*
|
|
60
|
+
* ## Nothing here throws
|
|
61
|
+
*
|
|
62
|
+
* `Paddle.Checkout.open` is synchronous and returns nothing, so its only way to report a problem is to
|
|
63
|
+
* throw — inside a click handler, where an unhandled rejection is what a buyer gets instead of a card
|
|
64
|
+
* form. Every path through this module answers with a {@link PaymentsFailure} or with null.
|
|
65
|
+
*/
|
|
66
|
+
/** A screen said `inline`, and there is no element with that class on the page to render into. */
|
|
67
|
+
export declare const PADDLE_NO_CONTAINER: PaymentsFailure;
|
|
68
|
+
/** Paddle.js refused to open the checkout. A transaction it will not sell, or one already completed. */
|
|
69
|
+
export declare const PADDLE_CHECKOUT_REFUSED: PaymentsFailure;
|
|
70
|
+
/**
|
|
71
|
+
* The default styling of an inline checkout's container.
|
|
72
|
+
*
|
|
73
|
+
* Paddle's own recommendation, and `min-width` in it is a compliance requirement rather than taste: the
|
|
74
|
+
* inline frame carries the footer naming Paddle as merchant of record, and below 312px that footer is cut
|
|
75
|
+
* off. A default here rather than in the scaffolded screen keeps the number out of a file Pithy may never
|
|
76
|
+
* rewrite — and a screen that wants its own passes one.
|
|
77
|
+
*/
|
|
78
|
+
export declare const PADDLE_FRAME_STYLE = "width: 100%; min-width: 312px; background-color: transparent; border: none;";
|
|
79
|
+
/** The container's height in pixels before the frame resizes itself. Paddle's recommended 450. */
|
|
80
|
+
export declare const PADDLE_FRAME_HEIGHT = 450;
|
|
81
|
+
/**
|
|
82
|
+
* The slice of `document` this module reads, as an injectable seam.
|
|
83
|
+
*
|
|
84
|
+
* Structural for the reason `PaymentsGlobal` is: the package compiles in a program with no DOM lib
|
|
85
|
+
* alongside the Worker's code, and a test proves the no-browser path without a DOM.
|
|
86
|
+
*/
|
|
87
|
+
export interface PaddleDocument {
|
|
88
|
+
/** Elements carrying a class. Paddle's `frameTarget` is a class name, so this is the lookup it does. */
|
|
89
|
+
getElementsByClassName(names: string): {
|
|
90
|
+
length: number;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** What {@link openPaddleCheckout} lets a caller replace or decide. */
|
|
94
|
+
export interface PaddleCheckoutOptions extends PaddleOptions {
|
|
95
|
+
/**
|
|
96
|
+
* Light or dark. Omit to take Paddle's default, which is light.
|
|
97
|
+
*
|
|
98
|
+
* **Pass the theme your app is in. This kit will not work it out.** Reading `prefers-color-scheme` here
|
|
99
|
+
* would answer a different question — the machine's preference, not the app's — and an app with its own
|
|
100
|
+
* toggle would open a light card form over a dark page for a reader who chose dark. The screen already
|
|
101
|
+
* knows which theme it rendered; that is the only source that is right every time.
|
|
102
|
+
*
|
|
103
|
+
* Theme is the whole of what code may set. Colors and fonts live in the Paddle dashboard, deliberately.
|
|
104
|
+
*/
|
|
105
|
+
theme?: PaddleCheckoutTheme;
|
|
106
|
+
/**
|
|
107
|
+
* The buyer's language — `"fr"`, `"pt-BR"`. Omit to take the browser's.
|
|
108
|
+
*
|
|
109
|
+
* Worth passing exactly when the app has a language choice of its own, for the reason `theme` is worth
|
|
110
|
+
* passing: a reader who set the app to French should not meet a checkout in the language their browser
|
|
111
|
+
* was installed with.
|
|
112
|
+
*/
|
|
113
|
+
locale?: string;
|
|
114
|
+
/** One page or several. Omit to take Paddle's default, which is `multi-page`. */
|
|
115
|
+
variant?: PaddleCheckoutVariant;
|
|
116
|
+
/**
|
|
117
|
+
* The **class name** of the element an inline checkout renders into.
|
|
118
|
+
*
|
|
119
|
+
* The screen's to name, not the server's: the container is a thing in a layout, and a project switching
|
|
120
|
+
* `paddle.checkout` between `overlay` and `inline` in its config must not have to edit a scaffolded
|
|
121
|
+
* screen to match. So a screen passes one always and it is used only when the handoff says inline.
|
|
122
|
+
*/
|
|
123
|
+
frameTarget?: string;
|
|
124
|
+
/** Styles for that element. Defaults to {@link PADDLE_FRAME_STYLE}. */
|
|
125
|
+
frameStyle?: string;
|
|
126
|
+
/** Its height in pixels on load. Defaults to {@link PADDLE_FRAME_HEIGHT}. */
|
|
127
|
+
frameInitialHeight?: number;
|
|
128
|
+
/** Where the container is looked for. Defaults to the browser's own `document`. */
|
|
129
|
+
document?: PaddleDocument;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Open the checkout the server handed back, over this page or inside it.
|
|
133
|
+
*
|
|
134
|
+
* Loads Paddle.js if it is not loaded, from the token and environment on the handoff itself — so a screen
|
|
135
|
+
* needs no second source of truth for which Paddle account it is selling through, and a handoff for one
|
|
136
|
+
* account cannot open against another page's Paddle. Returns null when the checkout opened, and a failure
|
|
137
|
+
* to render otherwise.
|
|
138
|
+
*
|
|
139
|
+
* **The container must be on the page before this is called.** In React that means an effect rather than
|
|
140
|
+
* a click handler: the render that reveals the container has to commit first. `usePaddleCheckout` in
|
|
141
|
+
* `./hooks` is that ordering, written once.
|
|
142
|
+
*/
|
|
143
|
+
export declare function openPaddleCheckout(handoff: PaddleCheckoutHandoff, options?: PaddleCheckoutOptions): Promise<PaymentsFailure | null>;
|
|
144
|
+
//# sourceMappingURL=checkout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/client/checkout.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuB,KAAK,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,OAAO,CAAC;AAC9F,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EACnB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAEH,kGAAkG;AAClG,eAAO,MAAM,mBAAmB,EAAE,eAIjC,CAAC;AAEF,wGAAwG;AACxG,eAAO,MAAM,uBAAuB,EAAE,eAIrC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,gFAAgF,CAAC;AAEhH,kGAAkG;AAClG,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,wGAAwG;IACxG,sBA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