@talosjs/payment 1.0.0 → 1.1.1

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 (2) hide show
  1. package/README.md +4 -227
  2. package/package.json +9 -9
package/README.md CHANGED
@@ -1,30 +1,6 @@
1
1
  # @talosjs/payment
2
2
 
3
- Payment and pricing type definitions with currency handling, product categorization, and billing metadata for e-commerce integrations.
4
-
5
- ![Bun](https://img.shields.io/badge/Bun-Compatible-orange?style=flat-square&logo=bun)
6
- ![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue?style=flat-square&logo=typescript)
7
- ![MIT License](https://img.shields.io/badge/License-MIT-yellow?style=flat-square)
8
-
9
- ## Features
10
-
11
- ✅ **Polar Integration** - Full Polar SDK integration for products, checkouts, customers, discounts, and analytics
12
-
13
- ✅ **Checkout Flow** - Create and retrieve checkout sessions with customer and discount support
14
-
15
- ✅ **Product Management** - Create, update, and archive products with pricing, benefits, and custom fields
16
-
17
- ✅ **Customer Management** - Create, update, list, and delete customers with billing address and metadata
18
-
19
- ✅ **Discount System** - Percentage and fixed discounts with duration, redemption limits, and product scoping
20
-
21
- ✅ **Subscription Support** - Plans, credits, and recurring billing with trial periods
22
-
23
- ✅ **Analytics** - Revenue, order, and subscription analytics with configurable time intervals
24
-
25
- ✅ **Customer Portal** - Create customer portal sessions for self-service account management
26
-
27
- ✅ **Type-Safe** - Comprehensive TypeScript types for all payment entities and API responses
3
+ Payment and pricing type definitions with currency handling, product categorization, and billing metadata for e-commerce integrations
28
4
 
29
5
  ## Installation
30
6
 
@@ -32,209 +8,10 @@ Payment and pricing type definitions with currency handling, product categorizat
32
8
  bun add @talosjs/payment
33
9
  ```
34
10
 
35
- ## Usage
36
-
37
- ### Creating a Checkout
38
-
39
- ```typescript
40
- import { PolarCheckout } from '@talosjs/payment';
41
-
42
- // Requires POLAR_ACCESS_TOKEN environment variable
43
- const checkout = new PolarCheckout();
44
-
45
- const session = await checkout.create({
46
- products: ['product-id-1'],
47
- customerEmail: 'user@example.com',
48
- successUrl: 'https://example.com/success',
49
- allowDiscountCodes: true,
50
- });
51
-
52
- console.log(session.url); // Redirect user to this URL
53
- ```
54
-
55
- ### Managing Products
56
-
57
- ```typescript
58
- import { PolarProduct } from '@talosjs/payment';
59
-
60
- const products = new PolarProduct();
61
-
62
- // Create a product
63
- const product = await products.create({
64
- name: 'Pro Plan',
65
- description: 'Full access to all features',
66
- recurringInterval: 'monthly',
67
- prices: [
68
- { type: 'fixed', priceCurrency: 'usd', priceAmount: 2900 },
69
- ],
70
- });
71
-
72
- // Update a product
73
- await products.update('product-id', {
74
- name: 'Pro Plan (Updated)',
75
- });
76
-
77
- // Archive a product
78
- await products.remove('product-id');
79
- ```
80
-
81
- ### Customer Management
82
-
83
- ```typescript
84
- import { PolarCustomer } from '@talosjs/payment';
85
-
86
- const customers = new PolarCustomer();
87
-
88
- // Create a customer
89
- const customer = await customers.create({
90
- email: 'user@example.com',
91
- name: 'John Doe',
92
- metadata: { plan: 'pro' },
93
- });
94
-
95
- // List customers
96
- const result = await customers.list({
97
- query: 'john',
98
- limit: 20,
99
- });
100
- ```
101
-
102
- ### Managing Discounts
103
-
104
- ```typescript
105
- import { PolarDiscount } from '@talosjs/payment';
106
-
107
- const discounts = new PolarDiscount();
108
-
109
- // Create a percentage discount
110
- const discount = await discounts.create({
111
- name: '20% Off',
112
- code: 'SAVE20',
113
- type: 'percentage',
114
- amount: 2000, // basis points (20%)
115
- duration: 'once',
116
- });
117
- ```
118
-
119
- ### Revenue Analytics
120
-
121
- ```typescript
122
- import { PolarAnalytics } from '@talosjs/payment';
123
-
124
- const analytics = new PolarAnalytics();
125
-
126
- const data = await analytics.get({
127
- startDate: new Date('2024-01-01'),
128
- endDate: new Date('2024-12-31'),
129
- interval: 'month',
130
- });
131
-
132
- for (const period of data.periods) {
133
- console.log(`${period.timestamp}: $${period.revenue / 100}`);
134
- }
135
- ```
136
-
137
- ## API Reference
138
-
139
- ### Classes
140
-
141
- #### `PolarCheckout`
142
-
143
- Create and retrieve Polar checkout sessions.
144
-
145
- **Methods:**
146
- - `create(data: CheckoutCreateType): Promise<CheckoutType>` - Create a checkout session
147
- - `get(id: string): Promise<CheckoutType>` - Retrieve a checkout by ID
148
-
149
- #### `PolarProduct`
150
-
151
- Manage products via the Polar API.
152
-
153
- **Methods:**
154
- - `create(data: IProduct): Promise<Omit<IProduct, 'id'>>` - Create a product
155
- - `update(id: string, data: Partial<IProduct>): Promise<Omit<IProduct, 'id'>>` - Update a product
156
- - `remove(id: string): Promise<void>` - Archive a product
157
-
158
- #### `PolarCustomer`
159
-
160
- Manage customers via the Polar API.
161
-
162
- **Methods:**
163
- - `create(data: CustomerCreateType): Promise<CustomerType>` - Create a customer
164
- - `update(id: string, data: CustomerUpdateType): Promise<CustomerType>` - Update a customer
165
- - `get(id: string): Promise<CustomerType>` - Get a customer by ID
166
- - `list(options?: CustomerListOptionsType): Promise<CustomerListResultType>` - List customers
167
- - `remove(id: string): Promise<void>` - Delete a customer
168
-
169
- #### `PolarCustomerPortal`
170
-
171
- Create customer portal sessions for self-service management.
172
-
173
- #### `PolarDiscount`
174
-
175
- Create and manage discounts.
176
-
177
- #### `PolarAnalytics`
178
-
179
- Retrieve revenue and order analytics.
180
-
181
- ### Key Types
11
+ ## Documentation
182
12
 
183
- #### `IProduct`
184
-
185
- Product interface with name, description, prices, benefits, recurring interval, and metadata.
186
-
187
- #### `CheckoutCreateType`
188
-
189
- Checkout creation options including products, customer info, discount, and success URL.
190
-
191
- #### `IDiscount`
192
-
193
- Discount interface with type (percentage/fixed), duration, amount, and redemption limits.
194
-
195
- #### `ISubscription`
196
-
197
- Subscription interface with plans, credits, discounts, and billing dates.
198
-
199
- ### Enums
200
-
201
- | Enum | Values |
202
- |------|--------|
203
- | `EPriceType` | `FIXED`, `CUSTOM`, `FREE` |
204
- | `EDiscountType` | `PERCENTAGE`, `FIXED` |
205
- | `EDiscountDuration` | `ONCE`, `REPEATING`, `FOREVER` |
206
- | `ESubscriptionPeriod` | `MONTHLY`, `YEARLY`, `WEEKLY`, `DAILY` |
207
- | `EBenefitType` | `CREDITS`, `LICENSE_KEYS`, `FILE_DOWNLOADS`, `GITHUB_REPOSITORY_ACCESS`, `DISCORD_ACCESS`, `CUSTOM` |
208
- | `ECheckoutStatus` | `OPEN`, `EXPIRED`, `CONFIRMED`, `SUCCEEDED`, `FAILED` |
209
- | `EAnalyticsInterval` | `YEAR`, `MONTH`, `WEEK`, `DAY`, `HOUR` |
210
-
211
- ## Environment Variables
212
-
213
- - `POLAR_ACCESS_TOKEN` - Polar API access token (required)
214
- - `POLAR_ENVIRONMENT` - `"sandbox"` or `"production"` (default: `"production"`)
13
+ Read the full documentation at [docs.talosjs.com](https://docs.talosjs.com).
215
14
 
216
15
  ## License
217
16
 
218
- This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
219
-
220
- ## Contributing
221
-
222
- Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
223
-
224
- ### Development Setup
225
-
226
- 1. Clone the repository
227
- 2. Install dependencies: `bun install`
228
- 3. Run tests: `bun run test`
229
- 4. Build the project: `bun run build`
230
-
231
- ### Guidelines
232
-
233
- - Write tests for new features
234
- - Follow the existing code style
235
- - Update documentation for API changes
236
- - Ensure all tests pass before submitting PR
237
-
238
- ---
239
-
240
- Made with ❤️ by the Talos team
17
+ MIT
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@talosjs/payment",
3
3
  "description": "Payment and pricing type definitions with currency handling, product categorization, and billing metadata for e-commerce integrations",
4
- "version": "1.0.0",
4
+ "version": "1.1.1",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -23,19 +23,19 @@
23
23
  "license": "MIT",
24
24
  "scripts": {
25
25
  "build": "bunup",
26
- "lint": "tsgo --noEmit && bunx biome lint",
27
- "npm:publish": "bun publish --tolerate-republish --force --production --access public"
26
+ "fmt": "bunx biome check --write",
27
+ "lint": "tsgo --noEmit && bunx biome lint"
28
28
  },
29
29
  "dependencies": {
30
- "@talosjs/app-env": "^1.12.0",
31
- "@talosjs/container": "^1.5.1",
32
- "@talosjs/exception": "^1.2.10",
33
- "@talosjs/http-status": "^1.1.11",
30
+ "@talosjs/app-env": "^1.1.2",
31
+ "@talosjs/container": "^1.1.1",
32
+ "@talosjs/exception": "^1.1.1",
33
+ "@talosjs/http-status": "^1.1.1",
34
34
  "@polar-sh/sdk": "^0.30.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@talosjs/currencies": "^1.1.12",
38
- "@talosjs/types": "^1.3.7"
37
+ "@talosjs/currencies": "^1.1.1",
38
+ "@talosjs/types": "^1.1.1"
39
39
  },
40
40
  "keywords": [
41
41
  "billing",