@lunora/payment 1.0.0-alpha.12 → 1.0.0-alpha.120
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/LICENSE.md +6 -0
- package/README.md +8 -4
- package/dist/index.d.mts +396 -530
- package/dist/index.d.ts +396 -530
- package/dist/index.mjs +1 -16
- package/dist/packem_shared/LunoraPaymentError-BSxyhWgu.mjs +1 -0
- package/dist/packem_shared/MemoryPaymentStore-CZbrrEb1.mjs +1 -0
- package/dist/packem_shared/PAYMENT_TERMINAL_STATES-Dxxpk_br.mjs +1 -0
- package/dist/packem_shared/adapter.d-CeLGlHv_.d.mts +488 -0
- package/dist/packem_shared/adapter.d-CeLGlHv_.d.ts +488 -0
- package/dist/packem_shared/addMoney-B4ufWAnD.mjs +1 -0
- package/dist/packem_shared/applyWebhookAction-DqM4qNr3.mjs +1 -0
- package/dist/packem_shared/constantTimeEqual-ggrwGvRa.mjs +1 -0
- package/dist/packem_shared/createAdapterRegistry-DyCsry1Q.mjs +1 -0
- package/dist/packem_shared/createDatabasePaymentStore-DWe1Vz4V.mjs +1 -0
- package/dist/packem_shared/createPayment-Cmyk1BcJ.mjs +1 -0
- package/dist/packem_shared/entitlementsForReference-Bq-9UUL8.mjs +1 -0
- package/dist/packem_shared/idempotencyKey-DBL6bpmj.mjs +1 -0
- package/dist/packem_shared/json-BJJPJVYj.mjs +1 -0
- package/dist/packem_shared/lunoraDatabaseToPaymentDatabase-CZmZ5LeG.mjs +1 -0
- package/dist/packem_shared/not-supported-Cl0brzhn.mjs +1 -0
- package/dist/packem_shared/observability-BteZ2dJS.mjs +1 -0
- package/dist/packem_shared/paymentTables-Be-_11ux.mjs +1 -0
- package/dist/packem_shared/reconcile-Cm45pURT.mjs +1 -0
- package/dist/packem_shared/subscription-event-C8GiQSFM.mjs +1 -0
- package/dist/providers/autumn-features.d.mts +129 -0
- package/dist/providers/autumn-features.d.ts +129 -0
- package/dist/providers/autumn-features.mjs +1 -0
- package/dist/providers/autumn.d.mts +28 -0
- package/dist/providers/autumn.d.ts +28 -0
- package/dist/providers/autumn.mjs +1 -0
- package/dist/providers/creem.d.mts +26 -0
- package/dist/providers/creem.d.ts +26 -0
- package/dist/providers/creem.mjs +1 -0
- package/dist/providers/dodopayments.d.mts +30 -0
- package/dist/providers/dodopayments.d.ts +30 -0
- package/dist/providers/dodopayments.mjs +1 -0
- package/dist/providers/polar.d.mts +31 -0
- package/dist/providers/polar.d.ts +31 -0
- package/dist/providers/polar.mjs +1 -0
- package/dist/providers/stripe.d.mts +32 -0
- package/dist/providers/stripe.d.ts +32 -0
- package/dist/providers/stripe.mjs +1 -0
- package/package.json +45 -4
- package/dist/packem_shared/LunoraPaymentError-B3hEzXSs.mjs +0 -22
- package/dist/packem_shared/MemoryPaymentStore-DvgdWa3C.mjs +0 -72
- package/dist/packem_shared/PAYMENT_TERMINAL_STATES-DrxV0clv.mjs +0 -26
- package/dist/packem_shared/addMoney-bCcs1nyw.mjs +0 -60
- package/dist/packem_shared/applyWebhookAction-DpAqf3Lw.mjs +0 -177
- package/dist/packem_shared/constantTimeEqual-CfY0jYcL.mjs +0 -95
- package/dist/packem_shared/createAdapterRegistry-BuDHFCBc.mjs +0 -24
- package/dist/packem_shared/createDatabasePaymentStore-bYB_HUE6.mjs +0 -172
- package/dist/packem_shared/createPayment-BccfPGyw.mjs +0 -190
- package/dist/packem_shared/createPolarAdapter-CgErk9zo.mjs +0 -220
- package/dist/packem_shared/createStripeAdapter-oDvMhpeX.mjs +0 -279
- package/dist/packem_shared/entitlementsForReference-CzZGXPoZ.mjs +0 -51
- package/dist/packem_shared/idempotencyKey-BFzDCA7g.mjs +0 -3
- package/dist/packem_shared/json-Db337f36.mjs +0 -6
- package/dist/packem_shared/lunoraDatabaseToPaymentDatabase-RlKX3Kcd.mjs +0 -29
- package/dist/packem_shared/observability-CvhJ205g.mjs +0 -11
- package/dist/packem_shared/paymentTables-DccHwWr_.mjs +0 -127
- package/dist/packem_shared/reconcile-CI1ukJF9.mjs +0 -73
package/LICENSE.md
CHANGED
|
@@ -103,3 +103,9 @@ Unless required by applicable law or agreed to in writing, software distributed
|
|
|
103
103
|
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
104
|
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
105
|
specific language governing permissions and limitations under the License.
|
|
106
|
+
|
|
107
|
+
<!-- DEPENDENCIES -->
|
|
108
|
+
<!-- /DEPENDENCIES -->
|
|
109
|
+
|
|
110
|
+
<!-- TYPE_DEPENDENCIES -->
|
|
111
|
+
<!-- /TYPE_DEPENDENCIES -->
|
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
<!-- END_PACKAGE_OG_IMAGE_PLACEHOLDER -->
|
|
12
12
|
|
|
13
|
+
> **Experimental** — this package is outside the Lunora 1.0 stability promise: its API may change in any release, without a major version bump.
|
|
14
|
+
|
|
13
15
|
<br />
|
|
14
16
|
|
|
15
17
|
<div align="center">
|
|
@@ -46,14 +48,15 @@ Part of the [Lunora](https://github.com/anolilab/lunora) framework — a type-sa
|
|
|
46
48
|
pnpm add @lunora/payment stripe
|
|
47
49
|
```
|
|
48
50
|
|
|
49
|
-
`stripe` is an optional peer dependency — install only the provider SDK you use; the adapter takes the client by injection.
|
|
51
|
+
`stripe` is an optional peer dependency — install only the provider SDK you use; the adapter takes the client by injection. The same holds for the other providers: `createPolarAdapter` (Polar), `createAutumnAdapter` ([Autumn](https://useautumn.com)), `createDodoPaymentsAdapter` ([Dodo Payments](https://dodopayments.com)), and `createCreemAdapter` ([Creem](https://creem.io)) take a structural client too, so no provider SDK is a hard dependency of this package. Additional providers plug in via `PaymentAdapter`.
|
|
50
52
|
|
|
51
53
|
## Usage
|
|
52
54
|
|
|
53
55
|
Build a facade from an adapter and a store, then start a hosted checkout:
|
|
54
56
|
|
|
55
57
|
```ts
|
|
56
|
-
import { createPayment,
|
|
58
|
+
import { createPayment, MemoryPaymentStore } from "@lunora/payment";
|
|
59
|
+
import { createStripeAdapter } from "@lunora/payment/stripe";
|
|
57
60
|
import Stripe from "stripe";
|
|
58
61
|
|
|
59
62
|
const payment = createPayment({
|
|
@@ -95,6 +98,7 @@ Webhook signature verification needs the raw request body, so the endpoint runs
|
|
|
95
98
|
|
|
96
99
|
```ts
|
|
97
100
|
// lunora/http.ts
|
|
101
|
+
import { webhookResponse } from "@lunora/payment";
|
|
98
102
|
import { httpAction, httpRouter } from "lunorash/server";
|
|
99
103
|
import { processWebhook } from "./billing";
|
|
100
104
|
|
|
@@ -106,12 +110,12 @@ app.post(
|
|
|
106
110
|
const body = await request.text();
|
|
107
111
|
const signature = request.headers.get("stripe-signature") ?? "";
|
|
108
112
|
|
|
109
|
-
return
|
|
113
|
+
return webhookResponse(await ctx.runAction(processWebhook, { body, signature }));
|
|
110
114
|
}),
|
|
111
115
|
);
|
|
112
116
|
```
|
|
113
117
|
|
|
114
|
-
`handleWebhook`
|
|
118
|
+
Once the signature verifies, `handleWebhook` acknowledges with `200` — a duplicate or no-op event is not re-applied — with one deliberate exception: an **orphaned** event, one patching a row whose create event has not arrived yet, answers `500` so the provider retries it (bounded to a single retry). That is why the route must use `webhookResponse`: `Response.json(result)` would answer `200` for every outcome, and an out-of-order delivery would be lost for good.
|
|
115
119
|
|
|
116
120
|
> This README covers the basics. For the full API — entitlements, usage metering, reconciliation, and the stored tables — see the [documentation](https://lunora.sh/docs/packages/payment).
|
|
117
121
|
|