@seaverse/payment-sdk 0.1.0 → 0.2.0

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/README.md CHANGED
@@ -8,15 +8,18 @@ SeaVerse Payment SDK - Credit management and payment checkout for SeaVerse appli
8
8
  - **Payment Checkout** - Show payment modal for one-time purchases and subscriptions
9
9
  - **Multi-tenant Support** - Isolated credit accounts per application
10
10
  - **TypeScript** - Full type definitions included
11
+ - **Web Component** - Uses `@seaart/payment-component` for payment UI
11
12
 
12
13
  ## Installation
13
14
 
14
15
  ```bash
15
- npm install @seaverse/payment-sdk
16
+ npm install @seaverse/payment-sdk @seaart/payment-component
16
17
  # or
17
- pnpm add @seaverse/payment-sdk
18
+ pnpm add @seaverse/payment-sdk @seaart/payment-component
18
19
  ```
19
20
 
21
+ > **Important**: You must also install `@seaart/payment-component` as it's a peer dependency.
22
+
20
23
  ## Quick Start
21
24
 
22
25
  ### Credit Query
@@ -49,15 +52,17 @@ Show payment modal for purchases:
49
52
 
50
53
  ```typescript
51
54
  import { PaymentCheckoutClient } from '@seaverse/payment-sdk';
55
+ // Import the Web Component styles
56
+ import '@seaart/payment-component/style.css';
52
57
 
53
58
  const checkoutClient = new PaymentCheckoutClient({
54
59
  apiHost: 'https://payment.sg.seaverse.dev',
55
60
  authToken: 'your-jwt-token',
56
- environment: 'develop',
61
+ environment: 'development', // or 'production'
57
62
  debug: true,
58
63
  });
59
64
 
60
- // Initialize (loads SeaArtPay SDK)
65
+ // Initialize (loads Web Component)
61
66
  await checkoutClient.init();
62
67
 
63
68
  // One-time purchase
@@ -93,7 +98,7 @@ await checkoutClient.subscribe({
93
98
 
94
99
  | Method | Description |
95
100
  |--------|-------------|
96
- | `init()` | Initialize and load SeaArtPay SDK |
101
+ | `init()` | Initialize and load Web Component |
97
102
  | `checkout(options)` | One-time purchase with payment modal |
98
103
  | `subscribe(options)` | Subscription purchase with payment modal |
99
104
  | `showPayment(options)` | Show payment modal with existing transactionId |
@@ -131,16 +136,129 @@ interface PaymentClientOptions {
131
136
 
132
137
  ```typescript
133
138
  interface CheckoutClientConfig {
134
- apiHost: string; // Payment gateway API URL
135
- authToken?: string; // Static JWT token
136
- getAuthToken?: () => string; // Dynamic token getter
137
- environment?: 'develop' | 'release';
138
- debug?: boolean;
139
- sdkCdnUrl?: string; // Custom SDK CDN URL
140
- sdkTimeout?: number; // SDK load timeout in ms
139
+ apiHost: string; // Payment gateway API URL
140
+ authToken?: string; // Static JWT token
141
+ getAuthToken?: () => string; // Dynamic token getter
142
+ environment?: 'development' | 'production'; // Environment
143
+ debug?: boolean; // Debug mode
144
+ componentTimeout?: number; // Web Component load timeout in ms
141
145
  }
142
146
  ```
143
147
 
148
+ ### Environment Configuration
149
+
150
+ | Environment | API Host |
151
+ |-------------|----------|
152
+ | `development` | `https://aiart-openresty.dev.seaart.dev` |
153
+ | `production` | `https://www.seaart.ai` |
154
+
155
+ ## Usage with Frameworks
156
+
157
+ ### Vue 3
158
+
159
+ ```vue
160
+ <script setup lang="ts">
161
+ import { ref, onMounted } from 'vue';
162
+ import { PaymentCheckoutClient } from '@seaverse/payment-sdk';
163
+ import '@seaart/payment-component/style.css';
164
+
165
+ const checkoutClient = ref<PaymentCheckoutClient | null>(null);
166
+
167
+ onMounted(async () => {
168
+ checkoutClient.value = new PaymentCheckoutClient({
169
+ apiHost: 'https://payment.sg.seaverse.dev',
170
+ authToken: 'your-token',
171
+ environment: import.meta.env.DEV ? 'development' : 'production',
172
+ });
173
+ await checkoutClient.value.init();
174
+ });
175
+
176
+ async function handlePurchase() {
177
+ await checkoutClient.value?.checkout({
178
+ productId: 'pkg_starter',
179
+ onSuccess: (res) => console.log('Success:', res),
180
+ });
181
+ }
182
+ </script>
183
+ ```
184
+
185
+ ### React
186
+
187
+ ```tsx
188
+ import { useEffect, useRef } from 'react';
189
+ import { PaymentCheckoutClient } from '@seaverse/payment-sdk';
190
+ import '@seaart/payment-component/style.css';
191
+
192
+ function PaymentPage() {
193
+ const clientRef = useRef<PaymentCheckoutClient | null>(null);
194
+
195
+ useEffect(() => {
196
+ const init = async () => {
197
+ clientRef.current = new PaymentCheckoutClient({
198
+ apiHost: 'https://payment.sg.seaverse.dev',
199
+ authToken: 'your-token',
200
+ environment: process.env.NODE_ENV === 'development' ? 'development' : 'production',
201
+ });
202
+ await clientRef.current.init();
203
+ };
204
+ init();
205
+ }, []);
206
+
207
+ const handlePurchase = async () => {
208
+ await clientRef.current?.checkout({
209
+ productId: 'pkg_starter',
210
+ onSuccess: (res) => console.log('Success:', res),
211
+ });
212
+ };
213
+
214
+ return <button onClick={handlePurchase}>Purchase</button>;
215
+ }
216
+ ```
217
+
218
+ ## Migration from v0.1.x
219
+
220
+ ### Breaking Changes
221
+
222
+ 1. **Environment naming changed:**
223
+ - `'develop'` → `'development'`
224
+ - `'release'` → `'production'`
225
+
226
+ 2. **New peer dependency required:**
227
+ ```bash
228
+ npm install @seaart/payment-component
229
+ ```
230
+
231
+ 3. **Import CSS file:**
232
+ ```typescript
233
+ import '@seaart/payment-component/style.css';
234
+ ```
235
+
236
+ 4. **Configuration options renamed:**
237
+ - `sdkCdnUrl` removed (no longer uses CDN)
238
+ - `sdkTimeout` → `componentTimeout`
239
+
240
+ ### Before (v0.1.x)
241
+
242
+ ```typescript
243
+ const client = new PaymentCheckoutClient({
244
+ apiHost: 'https://payment.sg.seaverse.dev',
245
+ authToken: 'token',
246
+ environment: 'develop', // Old naming
247
+ });
248
+ ```
249
+
250
+ ### After (v0.2.x)
251
+
252
+ ```typescript
253
+ import '@seaart/payment-component/style.css'; // Required!
254
+
255
+ const client = new PaymentCheckoutClient({
256
+ apiHost: 'https://payment.sg.seaverse.dev',
257
+ authToken: 'token',
258
+ environment: 'development', // New naming
259
+ });
260
+ ```
261
+
144
262
  ## Test Cards (Development)
145
263
 
146
264
  | Field | Value |
@@ -153,4 +271,3 @@ interface CheckoutClientConfig {
153
271
  ## License
154
272
 
155
273
  MIT
156
-