@86d-app/payments 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/.turbo/turbo-build.log +1 -0
  2. package/AGENTS.md +52 -45
  3. package/README.md +26 -5
  4. package/dist/__tests__/controllers.test.d.ts +2 -0
  5. package/dist/__tests__/controllers.test.d.ts.map +1 -0
  6. package/dist/__tests__/edge-cases.test.d.ts +2 -0
  7. package/dist/__tests__/edge-cases.test.d.ts.map +1 -0
  8. package/dist/__tests__/endpoint-security.test.d.ts +2 -0
  9. package/dist/__tests__/endpoint-security.test.d.ts.map +1 -0
  10. package/dist/__tests__/financial-safety.test.d.ts +2 -0
  11. package/dist/__tests__/financial-safety.test.d.ts.map +1 -0
  12. package/dist/__tests__/service-impl.test.d.ts +2 -0
  13. package/dist/__tests__/service-impl.test.d.ts.map +1 -0
  14. package/dist/admin/components/index.d.ts +2 -0
  15. package/dist/admin/components/index.d.ts.map +1 -0
  16. package/dist/admin/components/payments-admin.d.ts +2 -0
  17. package/dist/admin/components/payments-admin.d.ts.map +1 -0
  18. package/dist/admin/endpoints/create-refund.d.ts +20 -0
  19. package/dist/admin/endpoints/create-refund.d.ts.map +1 -0
  20. package/dist/admin/endpoints/get-intent.d.ts +16 -0
  21. package/dist/admin/endpoints/get-intent.d.ts.map +1 -0
  22. package/dist/admin/endpoints/index.d.ts +63 -0
  23. package/dist/admin/endpoints/index.d.ts.map +1 -0
  24. package/dist/admin/endpoints/list-intents.d.ts +22 -0
  25. package/dist/admin/endpoints/list-intents.d.ts.map +1 -0
  26. package/dist/admin/endpoints/list-refunds.d.ts +10 -0
  27. package/dist/admin/endpoints/list-refunds.d.ts.map +1 -0
  28. package/dist/index.d.ts +11 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/schema.d.ts +169 -0
  31. package/dist/schema.d.ts.map +1 -0
  32. package/dist/service-impl.d.ts +4 -0
  33. package/dist/service-impl.d.ts.map +1 -0
  34. package/dist/service.d.ts +125 -0
  35. package/dist/service.d.ts.map +1 -0
  36. package/dist/store/endpoints/cancel-intent.d.ts +16 -0
  37. package/dist/store/endpoints/cancel-intent.d.ts.map +1 -0
  38. package/dist/store/endpoints/confirm-intent.d.ts +16 -0
  39. package/dist/store/endpoints/confirm-intent.d.ts.map +1 -0
  40. package/dist/store/endpoints/create-intent.d.ts +15 -0
  41. package/dist/store/endpoints/create-intent.d.ts.map +1 -0
  42. package/dist/store/endpoints/delete-method.d.ts +16 -0
  43. package/dist/store/endpoints/delete-method.d.ts.map +1 -0
  44. package/dist/store/endpoints/get-intent.d.ts +16 -0
  45. package/dist/store/endpoints/get-intent.d.ts.map +1 -0
  46. package/dist/store/endpoints/index.d.ts +83 -0
  47. package/dist/store/endpoints/index.d.ts.map +1 -0
  48. package/dist/store/endpoints/list-methods.d.ts +12 -0
  49. package/dist/store/endpoints/list-methods.d.ts.map +1 -0
  50. package/package.json +3 -3
  51. package/src/__tests__/controllers.test.ts +1043 -0
  52. package/src/__tests__/edge-cases.test.ts +547 -0
  53. package/src/__tests__/endpoint-security.test.ts +360 -0
  54. package/src/__tests__/financial-safety.test.ts +576 -0
  55. package/src/__tests__/service-impl.test.ts +30 -5
  56. package/src/admin/endpoints/create-refund.ts +11 -6
  57. package/src/service-impl.ts +60 -0
  58. package/src/store/endpoints/cancel-intent.ts +20 -4
  59. package/src/store/endpoints/confirm-intent.ts +20 -4
  60. package/src/store/endpoints/create-intent.ts +18 -5
  61. package/src/store/endpoints/delete-method.ts +11 -1
  62. package/src/store/endpoints/get-intent.ts +1 -1
  63. package/src/store/endpoints/list-methods.ts +7 -5
@@ -0,0 +1 @@
1
+ $ tsc
package/AGENTS.md CHANGED
@@ -1,47 +1,54 @@
1
1
  # payments module
2
2
 
3
- Provider-agnostic payment processing module. Tracks payment intents, saved payment methods, and refunds locally. Delegates actual payment processing to a configurable `PaymentProvider` (e.g. Stripe).
4
-
5
- ## Architecture
6
-
7
- - `schema.ts` — `paymentIntent`, `paymentMethod`, `refund` entities
8
- - `service.ts` — `PaymentController`, `PaymentProvider`, `PaymentIntent`, `PaymentMethod`, `Refund` types
9
- - `service-impl.ts` — `createPaymentController(data, provider?)` factory
10
- - `endpoints/store/` — customer-facing endpoints (create/confirm/cancel intent, manage payment methods)
11
- - `endpoints/admin/` — admin endpoints (list, get, refund)
12
-
13
- ## PaymentProvider Interface
14
-
15
- Users plug in a provider by implementing `PaymentProvider`:
16
- - `createIntent(params)` — returns `{ providerIntentId, status, providerMetadata? }`
17
- - `confirmIntent(providerIntentId)` — returns updated status
18
- - `cancelIntent(providerIntentId)` — returns cancelled status
19
- - `createRefund(params)` returns `{ providerRefundId, status, providerMetadata? }`
20
-
21
- The module works without a provider (offline mode) — intents are stored with `pending` status and transitions are handled locally.
22
-
23
- ## Store Endpoints
24
-
25
- | Method | Path | Description |
26
- |--------|------|-------------|
27
- | POST | `/payments/intents` | Create payment intent |
28
- | GET | `/payments/intents/:id` | Get intent by ID |
29
- | POST | `/payments/intents/:id/confirm` | Confirm payment |
30
- | POST | `/payments/intents/:id/cancel` | Cancel payment |
31
- | GET | `/payments/methods` | List customer's payment methods |
32
- | DELETE | `/payments/methods/:id` | Delete a payment method |
33
-
34
- ## Admin Endpoints
35
-
36
- | Method | Path | Description |
37
- |--------|------|-------------|
38
- | GET | `/admin/payments` | List all intents (filter: customerId, status, orderId) |
39
- | GET | `/admin/payments/:id` | Get intent detail |
40
- | POST | `/admin/payments/:id/refund` | Create refund |
41
- | GET | `/admin/payments/:id/refunds` | List refunds for intent |
42
-
43
- ## Tests (34 tests)
44
-
45
- Run: `bun test` from this directory.
46
-
47
- Covers: createIntent, getIntent, confirmIntent, cancelIntent, listIntents, savePaymentMethod, getPaymentMethod, listPaymentMethods, deletePaymentMethod, createRefund, getRefund, listRefunds — all with and without provider.
3
+ Provider-agnostic payment processing. Tracks payment intents, saved payment methods, and refunds. Delegates processing to a configurable `PaymentProvider` (Stripe, Square, PayPal, etc.).
4
+
5
+ ## File structure
6
+
7
+ ```
8
+ src/
9
+ index.ts Module definition, PaymentsOptions
10
+ schema.ts paymentIntent, paymentMethod, refund entities
11
+ service.ts PaymentController, PaymentProvider, type definitions
12
+ service-impl.ts createPaymentController(data, provider?) factory
13
+ store/endpoints/ 6 customer-facing endpoints
14
+ admin/endpoints/ 4 admin endpoints
15
+ admin/components/ PaymentsAdmin UI (intents table, refund modal)
16
+ __tests__/
17
+ service-impl.test.ts Core CRUD (47 tests)
18
+ controllers.test.ts Edge cases (65 tests)
19
+ edge-cases.test.ts Provider, webhook, filter edge cases (32 tests)
20
+ endpoint-security.test.ts Security regressions (26 tests)
21
+ financial-safety.test.ts Amount validation, status guards, refund cap, webhook dedup (35 tests)
22
+ ```
23
+
24
+ ## Key patterns
25
+
26
+ - **Amount**: Always in smallest currency unit (cents). Must be a positive integer at controller level.
27
+ - **Status machine**: `pending processing succeeded → refunded`. Terminal states: `cancelled`, `failed`, `refunded`.
28
+ - **Status guards**: `confirmIntent` only from pending/processing. `cancelIntent` only from pending/processing. `createRefund` only from succeeded/refunded.
29
+ - **Refund cap**: Cumulative non-failed refunds cannot exceed original intent amount. Controller calculates `totalRefunded()` before each refund.
30
+ - **Webhook dedup**: `handleWebhookRefund` deduplicates by `providerRefundId` — retries return the existing refund.
31
+ - **Default payment method**: Only one per customer. `savePaymentMethod(isDefault: true)` clears previous defaults.
32
+ - **Ownership**: Controller has no ownership checks endpoints must verify `session.user.id === intent.customerId`.
33
+ - **Provider delegation**: If provider configured, delegates to it for createIntent/confirmIntent/cancelIntent/createRefund. Without provider, operates in local mode.
34
+
35
+ ## Data models
36
+
37
+ - **paymentIntent**: id, providerIntentId?, customerId?, email?, amount, currency, status, orderId?, checkoutSessionId?, metadata, providerMetadata, timestamps
38
+ - **paymentMethod**: id, customerId, providerMethodId, type, last4?, brand?, expiryMonth?, expiryYear?, isDefault, timestamps
39
+ - **refund**: id, paymentIntentId, providerRefundId, amount, reason?, status (pending|succeeded|failed), timestamps
40
+
41
+ ## Events emitted
42
+
43
+ `payment.completed`, `payment.failed`, `payment.refunded`
44
+
45
+ ## Gotchas
46
+
47
+ - Endpoint validates `amount` as `z.number().int().positive()` controller also validates (defense in depth).
48
+ - `createRefund` throws on non-existent intent, wrong status, exceeded cap, or missing provider. Endpoints should catch and return structured errors.
49
+ - `handleWebhookEvent` has no status guards — it trusts the provider (Stripe can set any status). `handleWebhookRefund` deduplicates but doesn't cap amounts (provider-side refunds are authoritative).
50
+ - Admin refund endpoint checks intent existence before calling controller, but doesn't validate intent status — controller handles that.
51
+
52
+ ## Tests (205 total)
53
+
54
+ Run: `bun test` from this directory. All 5 test files cover: CRUD, status guards, refund cap, webhook dedup, provider delegation, customer isolation, pagination.
package/README.md CHANGED
@@ -17,7 +17,7 @@
17
17
  > [!WARNING]
18
18
  > This project is under active development and is not ready for production use. Please proceed with caution. Use at your own risk.
19
19
 
20
- # @86d-app/payments
20
+ # Payments Module
21
21
 
22
22
  Provider-agnostic payment processing for the 86d commerce platform. Tracks payment intents, saved payment methods, and refunds locally. Delegates actual processing to a configurable `PaymentProvider` (Stripe, Square, PayPal, etc.).
23
23
 
@@ -103,7 +103,7 @@ interface PaymentProvider {
103
103
  // ── Payment intents ─────────────────────────────────────────────────────────
104
104
 
105
105
  controller.createIntent(params: {
106
- amount: number; // in smallest currency unit (e.g. cents)
106
+ amount: number; // positive integer, smallest currency unit (e.g. cents)
107
107
  currency?: string; // default: module currency option
108
108
  customerId?: string;
109
109
  email?: string;
@@ -111,12 +111,15 @@ controller.createIntent(params: {
111
111
  checkoutSessionId?: string;
112
112
  metadata?: Record<string, unknown>;
113
113
  }): Promise<PaymentIntent>
114
+ // Throws: "Amount must be a positive integer"
114
115
 
115
116
  controller.getIntent(id: string): Promise<PaymentIntent | null>
116
117
 
117
118
  controller.confirmIntent(id: string): Promise<PaymentIntent | null>
119
+ // Throws: "Cannot confirm intent in '{status}' state" for terminal states
118
120
 
119
121
  controller.cancelIntent(id: string): Promise<PaymentIntent | null>
122
+ // Throws: "Cannot cancel intent in '{status}' state" for succeeded/failed/refunded
120
123
 
121
124
  controller.listIntents(params?: {
122
125
  customerId?: string;
@@ -148,12 +151,16 @@ controller.deletePaymentMethod(id: string): Promise<boolean>
148
151
 
149
152
  // ── Refunds ─────────────────────────────────────────────────────────────────
150
153
 
151
- // Throws if payment intent not found; marks intent status as "refunded"
154
+ // Only on succeeded/refunded intents. Cumulative refunds capped at intent amount.
152
155
  controller.createRefund(params: {
153
156
  intentId: string;
154
- amount?: number; // omit for full refund
157
+ amount?: number; // positive integer; omit for full refund
155
158
  reason?: string;
156
159
  }): Promise<Refund>
160
+ // Throws: "Payment intent not found"
161
+ // Throws: "Cannot refund intent in '{status}' state"
162
+ // Throws: "Refund amount must be positive"
163
+ // Throws: "Refund amount {n} exceeds remaining refundable amount {m}"
157
164
 
158
165
  controller.getRefund(id: string): Promise<Refund | null>
159
166
 
@@ -205,7 +212,21 @@ const method = await controller.savePaymentMethod({
205
212
  | `succeeded` | Payment completed successfully |
206
213
  | `failed` | Payment failed |
207
214
  | `cancelled` | Intent was cancelled |
208
- | `refunded` | Payment has been refunded |
215
+ | `refunded` | Payment has been (partially or fully) refunded |
216
+
217
+ ## Financial Safety Guards
218
+
219
+ The payments controller enforces several financial safety rules at the controller level:
220
+
221
+ | Rule | Description |
222
+ |---|---|
223
+ | **Amount validation** | `createIntent` rejects zero, negative, and fractional amounts. Amount must be a positive integer (smallest currency unit). |
224
+ | **Confirm guards** | `confirmIntent` only works on `pending` or `processing` intents. Throws on `cancelled`, `failed`, `refunded`. |
225
+ | **Cancel guards** | `cancelIntent` only works on `pending` or `processing` intents. Throws on `succeeded`, `failed`, `refunded`. |
226
+ | **Refund guards** | `createRefund` only works on `succeeded` or `refunded` intents. Throws on `pending`, `processing`, `cancelled`, `failed`. |
227
+ | **Refund cap** | Cumulative non-failed refunds cannot exceed the original intent amount. Partial refunds are tracked and summed. |
228
+ | **Refund amount** | Refund amount must be positive. Zero and negative amounts are rejected. |
229
+ | **Webhook dedup** | `handleWebhookRefund` deduplicates by `providerRefundId` — webhook retries return the existing refund instead of creating duplicates. |
209
230
 
210
231
  ## Types
211
232
 
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=controllers.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controllers.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/controllers.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=edge-cases.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edge-cases.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/edge-cases.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=endpoint-security.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-security.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/endpoint-security.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=financial-safety.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"financial-safety.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/financial-safety.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=service-impl.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-impl.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/service-impl.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export { PaymentsAdmin } from "./payments-admin";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/admin/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function PaymentsAdmin(): import("react").JSX.Element;
2
+ //# sourceMappingURL=payments-admin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payments-admin.d.ts","sourceRoot":"","sources":["../../../src/admin/components/payments-admin.tsx"],"names":[],"mappings":"AA8fA,wBAAgB,aAAa,gCAU5B"}
@@ -0,0 +1,20 @@
1
+ import { z } from "@86d-app/core";
2
+ export declare const createRefund: import("better-call").StrictEndpoint<"/admin/payments/:id/refund", {
3
+ method: "POST";
4
+ params: z.ZodObject<{
5
+ id: z.ZodString;
6
+ }, z.core.$strip>;
7
+ body: z.ZodObject<{
8
+ amount: z.ZodOptional<z.ZodNumber>;
9
+ reason: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
10
+ }, z.core.$strip>;
11
+ }, {
12
+ error: string;
13
+ status: number;
14
+ refund?: never;
15
+ } | {
16
+ refund: import("../..").Refund;
17
+ error?: never;
18
+ status?: never;
19
+ }>;
20
+ //# sourceMappingURL=create-refund.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-refund.d.ts","sourceRoot":"","sources":["../../../src/admin/endpoints/create-refund.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,CAAC,EAAE,MAAM,eAAe,CAAC;AAGrE,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;EA0BxB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { z } from "@86d-app/core";
2
+ export declare const getIntentAdmin: import("better-call").StrictEndpoint<"/admin/payments/:id", {
3
+ method: "GET";
4
+ params: z.ZodObject<{
5
+ id: z.ZodString;
6
+ }, z.core.$strip>;
7
+ }, {
8
+ error: string;
9
+ status: number;
10
+ intent?: never;
11
+ } | {
12
+ intent: import("../..").PaymentIntent;
13
+ error?: never;
14
+ status?: never;
15
+ }>;
16
+ //# sourceMappingURL=get-intent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-intent.d.ts","sourceRoot":"","sources":["../../../src/admin/endpoints/get-intent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,CAAC,EAAE,MAAM,eAAe,CAAC;AAGvD,eAAO,MAAM,cAAc;;;;;;;;;;;;;EAY1B,CAAC"}
@@ -0,0 +1,63 @@
1
+ export declare const adminEndpoints: {
2
+ "/admin/payments": import("better-call").StrictEndpoint<"/admin/payments", {
3
+ method: "GET";
4
+ query: import("zod").ZodObject<{
5
+ customerId: import("zod").ZodOptional<import("zod").ZodString>;
6
+ status: import("zod").ZodOptional<import("zod").ZodEnum<{
7
+ pending: "pending";
8
+ processing: "processing";
9
+ succeeded: "succeeded";
10
+ failed: "failed";
11
+ cancelled: "cancelled";
12
+ refunded: "refunded";
13
+ }>>;
14
+ orderId: import("zod").ZodOptional<import("zod").ZodString>;
15
+ take: import("zod").ZodOptional<import("zod").ZodCoercedNumber<unknown>>;
16
+ skip: import("zod").ZodOptional<import("zod").ZodCoercedNumber<unknown>>;
17
+ }, import("zod/v4/core").$strip>;
18
+ }, {
19
+ intents: import("../..").PaymentIntent[];
20
+ total: number;
21
+ }>;
22
+ "/admin/payments/:id": import("better-call").StrictEndpoint<"/admin/payments/:id", {
23
+ method: "GET";
24
+ params: import("zod").ZodObject<{
25
+ id: import("zod").ZodString;
26
+ }, import("zod/v4/core").$strip>;
27
+ }, {
28
+ error: string;
29
+ status: number;
30
+ intent?: never;
31
+ } | {
32
+ intent: import("../..").PaymentIntent;
33
+ error?: never;
34
+ status?: never;
35
+ }>;
36
+ "/admin/payments/:id/refund": import("better-call").StrictEndpoint<"/admin/payments/:id/refund", {
37
+ method: "POST";
38
+ params: import("zod").ZodObject<{
39
+ id: import("zod").ZodString;
40
+ }, import("zod/v4/core").$strip>;
41
+ body: import("zod").ZodObject<{
42
+ amount: import("zod").ZodOptional<import("zod").ZodNumber>;
43
+ reason: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<string, string>>>;
44
+ }, import("zod/v4/core").$strip>;
45
+ }, {
46
+ error: string;
47
+ status: number;
48
+ refund?: never;
49
+ } | {
50
+ refund: import("../..").Refund;
51
+ error?: never;
52
+ status?: never;
53
+ }>;
54
+ "/admin/payments/:id/refunds": import("better-call").StrictEndpoint<"/admin/payments/:id/refunds", {
55
+ method: "GET";
56
+ params: import("zod").ZodObject<{
57
+ id: import("zod").ZodString;
58
+ }, import("zod/v4/core").$strip>;
59
+ }, {
60
+ refunds: import("../..").Refund[];
61
+ }>;
62
+ };
63
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/admin/endpoints/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAK1B,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { z } from "@86d-app/core";
2
+ export declare const listIntents: import("better-call").StrictEndpoint<"/admin/payments", {
3
+ method: "GET";
4
+ query: z.ZodObject<{
5
+ customerId: z.ZodOptional<z.ZodString>;
6
+ status: z.ZodOptional<z.ZodEnum<{
7
+ pending: "pending";
8
+ processing: "processing";
9
+ succeeded: "succeeded";
10
+ failed: "failed";
11
+ cancelled: "cancelled";
12
+ refunded: "refunded";
13
+ }>>;
14
+ orderId: z.ZodOptional<z.ZodString>;
15
+ take: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
16
+ skip: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
17
+ }, z.core.$strip>;
18
+ }, {
19
+ intents: import("../..").PaymentIntent[];
20
+ total: number;
21
+ }>;
22
+ //# sourceMappingURL=list-intents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-intents.d.ts","sourceRoot":"","sources":["../../../src/admin/endpoints/list-intents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,CAAC,EAAE,MAAM,eAAe,CAAC;AAGvD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;EAgCvB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { z } from "@86d-app/core";
2
+ export declare const listRefunds: import("better-call").StrictEndpoint<"/admin/payments/:id/refunds", {
3
+ method: "GET";
4
+ params: z.ZodObject<{
5
+ id: z.ZodString;
6
+ }, z.core.$strip>;
7
+ }, {
8
+ refunds: import("../..").Refund[];
9
+ }>;
10
+ //# sourceMappingURL=list-refunds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-refunds.d.ts","sourceRoot":"","sources":["../../../src/admin/endpoints/list-refunds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,CAAC,EAAE,MAAM,eAAe,CAAC;AAGvD,eAAO,MAAM,WAAW;;;;;;;EAWvB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { Module } from "@86d-app/core";
2
+ import type { PaymentProvider } from "./service";
3
+ export type { PaymentController, PaymentIntent, PaymentIntentStatus, PaymentMethod, PaymentProvider, ProviderIntentResult, ProviderRefundResult, Refund, RefundStatus, } from "./service";
4
+ export interface PaymentsOptions {
5
+ /** Default currency for payment intents */
6
+ currency?: string;
7
+ /** Payment provider implementation (e.g. StripePaymentProvider) */
8
+ provider?: PaymentProvider;
9
+ }
10
+ export default function payments(options?: PaymentsOptions): Module;
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AAG3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAIjD,YAAY,EACX,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,MAAM,EACN,YAAY,GACZ,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,eAAe;IAC/B,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC3B;AAED,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,MAAM,CA+BlE"}
@@ -0,0 +1,169 @@
1
+ export declare const paymentsSchema: {
2
+ paymentIntent: {
3
+ fields: {
4
+ id: {
5
+ type: "string";
6
+ required: true;
7
+ };
8
+ /** Provider-assigned intent ID (e.g. Stripe's pi_xxx) */
9
+ providerIntentId: {
10
+ type: "string";
11
+ required: false;
12
+ };
13
+ customerId: {
14
+ type: "string";
15
+ required: false;
16
+ };
17
+ email: {
18
+ type: "string";
19
+ required: false;
20
+ };
21
+ /** Amount in smallest currency unit (e.g. cents) */
22
+ amount: {
23
+ type: "number";
24
+ required: true;
25
+ };
26
+ currency: {
27
+ type: "string";
28
+ required: true;
29
+ defaultValue: string;
30
+ };
31
+ status: {
32
+ type: ("pending" | "processing" | "succeeded" | "failed" | "cancelled" | "refunded")[];
33
+ required: true;
34
+ defaultValue: string;
35
+ };
36
+ paymentMethodId: {
37
+ type: "string";
38
+ required: false;
39
+ };
40
+ orderId: {
41
+ type: "string";
42
+ required: false;
43
+ };
44
+ checkoutSessionId: {
45
+ type: "string";
46
+ required: false;
47
+ };
48
+ metadata: {
49
+ type: "json";
50
+ required: false;
51
+ defaultValue: {};
52
+ };
53
+ providerMetadata: {
54
+ type: "json";
55
+ required: false;
56
+ defaultValue: {};
57
+ };
58
+ createdAt: {
59
+ type: "date";
60
+ required: true;
61
+ defaultValue: () => Date;
62
+ };
63
+ updatedAt: {
64
+ type: "date";
65
+ required: true;
66
+ defaultValue: () => Date;
67
+ onUpdate: () => Date;
68
+ };
69
+ };
70
+ };
71
+ paymentMethod: {
72
+ fields: {
73
+ id: {
74
+ type: "string";
75
+ required: true;
76
+ };
77
+ customerId: {
78
+ type: "string";
79
+ required: true;
80
+ };
81
+ /** Provider-assigned method ID (e.g. Stripe's pm_xxx) */
82
+ providerMethodId: {
83
+ type: "string";
84
+ required: true;
85
+ };
86
+ /** card | bank_transfer | wallet */
87
+ type: {
88
+ type: "string";
89
+ required: true;
90
+ defaultValue: string;
91
+ };
92
+ last4: {
93
+ type: "string";
94
+ required: false;
95
+ };
96
+ brand: {
97
+ type: "string";
98
+ required: false;
99
+ };
100
+ expiryMonth: {
101
+ type: "number";
102
+ required: false;
103
+ };
104
+ expiryYear: {
105
+ type: "number";
106
+ required: false;
107
+ };
108
+ isDefault: {
109
+ type: "boolean";
110
+ required: true;
111
+ defaultValue: false;
112
+ };
113
+ createdAt: {
114
+ type: "date";
115
+ required: true;
116
+ defaultValue: () => Date;
117
+ };
118
+ updatedAt: {
119
+ type: "date";
120
+ required: true;
121
+ defaultValue: () => Date;
122
+ onUpdate: () => Date;
123
+ };
124
+ };
125
+ };
126
+ refund: {
127
+ fields: {
128
+ id: {
129
+ type: "string";
130
+ required: true;
131
+ };
132
+ paymentIntentId: {
133
+ type: "string";
134
+ required: true;
135
+ };
136
+ /** Provider-assigned refund ID */
137
+ providerRefundId: {
138
+ type: "string";
139
+ required: true;
140
+ };
141
+ /** Refund amount in smallest currency unit */
142
+ amount: {
143
+ type: "number";
144
+ required: true;
145
+ };
146
+ reason: {
147
+ type: "string";
148
+ required: false;
149
+ };
150
+ status: {
151
+ type: ("pending" | "succeeded" | "failed")[];
152
+ required: true;
153
+ defaultValue: string;
154
+ };
155
+ createdAt: {
156
+ type: "date";
157
+ required: true;
158
+ defaultValue: () => Date;
159
+ };
160
+ updatedAt: {
161
+ type: "date";
162
+ required: true;
163
+ defaultValue: () => Date;
164
+ onUpdate: () => Date;
165
+ };
166
+ };
167
+ };
168
+ };
169
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc;;;;;;;YAIxB,yDAAyD;;;;;;;;;;;;;YAIzD,oDAAoD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqCpD,yDAAyD;;;;;YAEzD,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAwBpC,kCAAkC;;;;;YAElC,8CAA8C;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqBzB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ModuleDataService } from "@86d-app/core";
2
+ import type { PaymentController, PaymentProvider } from "./service";
3
+ export declare function createPaymentController(data: ModuleDataService, provider?: PaymentProvider): PaymentController;
4
+ //# sourceMappingURL=service-impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-impl.d.ts","sourceRoot":"","sources":["../src/service-impl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EACX,iBAAiB,EAIjB,eAAe,EAEf,MAAM,WAAW,CAAC;AAEnB,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,iBAAiB,EACvB,QAAQ,CAAC,EAAE,eAAe,GACxB,iBAAiB,CAyXnB"}