@hazeljs/payment 0.2.0-alpha.4

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 (42) hide show
  1. package/LICENSE +192 -0
  2. package/README.md +224 -0
  3. package/dist/index.d.ts +12 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +15 -0
  6. package/dist/payment.controller.d.ts +29 -0
  7. package/dist/payment.controller.d.ts.map +1 -0
  8. package/dist/payment.controller.js +98 -0
  9. package/dist/payment.controller.test.d.ts +2 -0
  10. package/dist/payment.controller.test.d.ts.map +1 -0
  11. package/dist/payment.controller.test.js +131 -0
  12. package/dist/payment.module.d.ts +21 -0
  13. package/dist/payment.module.d.ts.map +1 -0
  14. package/dist/payment.module.js +40 -0
  15. package/dist/payment.module.test.d.ts +2 -0
  16. package/dist/payment.module.test.d.ts.map +1 -0
  17. package/dist/payment.module.test.js +71 -0
  18. package/dist/payment.service.d.ts +33 -0
  19. package/dist/payment.service.d.ts.map +1 -0
  20. package/dist/payment.service.js +88 -0
  21. package/dist/payment.service.test.d.ts +2 -0
  22. package/dist/payment.service.test.d.ts.map +1 -0
  23. package/dist/payment.service.test.js +219 -0
  24. package/dist/providers/index.d.ts +8 -0
  25. package/dist/providers/index.d.ts.map +1 -0
  26. package/dist/providers/index.js +9 -0
  27. package/dist/providers/provider.interface.d.ts +32 -0
  28. package/dist/providers/provider.interface.d.ts.map +1 -0
  29. package/dist/providers/provider.interface.js +5 -0
  30. package/dist/providers/stripe/stripe.provider.d.ts +26 -0
  31. package/dist/providers/stripe/stripe.provider.d.ts.map +1 -0
  32. package/dist/providers/stripe/stripe.provider.js +143 -0
  33. package/dist/providers/stripe/stripe.provider.test.d.ts +2 -0
  34. package/dist/providers/stripe/stripe.provider.test.d.ts.map +1 -0
  35. package/dist/providers/stripe/stripe.provider.test.js +383 -0
  36. package/dist/providers/stripe/stripe.types.d.ts +15 -0
  37. package/dist/providers/stripe/stripe.types.d.ts.map +1 -0
  38. package/dist/providers/stripe/stripe.types.js +5 -0
  39. package/dist/types/payment.types.d.ts +94 -0
  40. package/dist/types/payment.types.d.ts.map +1 -0
  41. package/dist/types/payment.types.js +5 -0
  42. package/package.json +55 -0
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Provider-agnostic payment types for @hazeljs/payment.
3
+ */
4
+ /**
5
+ * Generic customer returned by any provider.
6
+ */
7
+ export interface Customer {
8
+ id: string;
9
+ email?: string | null;
10
+ name?: string | null;
11
+ metadata?: Record<string, string>;
12
+ }
13
+ /**
14
+ * Generic subscription list item.
15
+ */
16
+ export interface Subscription {
17
+ id: string;
18
+ status: string;
19
+ customerId: string;
20
+ [key: string]: unknown;
21
+ }
22
+ /**
23
+ * Generic checkout session info (e.g. after redirect).
24
+ */
25
+ export interface CheckoutSessionInfo {
26
+ id: string;
27
+ url: string | null;
28
+ customerId?: string | null;
29
+ subscriptionId?: string | null;
30
+ status?: string;
31
+ [key: string]: unknown;
32
+ }
33
+ /**
34
+ * Provider-agnostic options for creating a checkout session (one-time or subscription).
35
+ * Provider-specific extras go in providerOptions[providerName].
36
+ */
37
+ export interface CreateCheckoutSessionOptions {
38
+ /** Success URL after payment. */
39
+ successUrl: string;
40
+ /** Cancel URL when user cancels. */
41
+ cancelUrl: string;
42
+ /** Existing provider customer ID. */
43
+ customerId?: string;
44
+ /** Customer email (for new customer). */
45
+ customerEmail?: string;
46
+ /** Client reference (e.g. user id, order id). */
47
+ clientReferenceId?: string;
48
+ /** One-time payment: line items (price id or custom amount). */
49
+ lineItems?: Array<{
50
+ priceId?: string;
51
+ quantity?: number;
52
+ priceData?: {
53
+ currency: string;
54
+ unitAmount: number;
55
+ productData: {
56
+ name: string;
57
+ description?: string;
58
+ images?: string[];
59
+ };
60
+ };
61
+ }>;
62
+ /** Subscription: price ID and optional trial. */
63
+ subscription?: {
64
+ priceId: string;
65
+ quantity?: number;
66
+ trialPeriodDays?: number;
67
+ };
68
+ /** Allow promotion codes (when supported by provider). */
69
+ allowPromotionCodes?: boolean;
70
+ /** Mode: 'payment' (one-time) or 'subscription'. Inferred from subscription if not set. */
71
+ mode?: 'payment' | 'subscription';
72
+ /** Provider-specific options, e.g. { stripe: { ... } }. */
73
+ providerOptions?: Record<string, unknown>;
74
+ }
75
+ /**
76
+ * Result of creating a checkout session.
77
+ */
78
+ export interface CreateCheckoutSessionResult {
79
+ sessionId: string;
80
+ url: string | null;
81
+ }
82
+ /**
83
+ * Options for creating a customer.
84
+ */
85
+ export interface CreateCustomerOptions {
86
+ email: string;
87
+ name?: string;
88
+ metadata?: Record<string, string>;
89
+ }
90
+ /**
91
+ * Subscription status filter for listSubscriptions.
92
+ */
93
+ export type SubscriptionStatusFilter = 'active' | 'canceled' | 'incomplete_expired' | 'unpaid' | 'all';
94
+ //# sourceMappingURL=payment.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment.types.d.ts","sourceRoot":"","sources":["../../src/types/payment.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,GAA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,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAChC,QAAQ,GACR,UAAU,GACV,oBAAoB,GACpB,QAAQ,GACR,KAAK,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * Provider-agnostic payment types for @hazeljs/payment.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@hazeljs/payment",
3
+ "version": "0.2.0-alpha.4",
4
+ "description": "Stripe payment integration for HazelJS - checkout sessions, customers, subscriptions, webhooks",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "test": "jest --coverage --passWithNoTests",
13
+ "lint": "eslint \"src/**/*.ts\"",
14
+ "lint:fix": "eslint \"src/**/*.ts\" --fix",
15
+ "clean": "rm -rf dist"
16
+ },
17
+ "dependencies": {
18
+ "stripe": "^17.4.0"
19
+ },
20
+ "devDependencies": {
21
+ "@types/node": "^20.17.50",
22
+ "@typescript-eslint/eslint-plugin": "^8.18.2",
23
+ "@typescript-eslint/parser": "^8.18.2",
24
+ "eslint": "^8.56.0",
25
+ "jest": "^29.7.0",
26
+ "ts-jest": "^29.1.2",
27
+ "typescript": "^5.3.3"
28
+ },
29
+ "peerDependencies": {
30
+ "@hazeljs/core": ">=0.2.0-beta.0"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/hazel-js/hazeljs.git",
38
+ "directory": "packages/payment"
39
+ },
40
+ "keywords": [
41
+ "hazeljs",
42
+ "payment",
43
+ "stripe",
44
+ "checkout",
45
+ "subscriptions",
46
+ "webhooks"
47
+ ],
48
+ "author": "Muhammad Arslan <muhammad.arslan@hazeljs.com>",
49
+ "license": "Apache-2.0",
50
+ "bugs": {
51
+ "url": "https://github.com/hazeljs/hazel-js/issues"
52
+ },
53
+ "homepage": "https://hazeljs.com",
54
+ "gitHead": "1ba645b7dd3ee97b463e54fdb6bebdffcd9e4190"
55
+ }