recur-tw 0.8.4 → 0.8.5

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/dist/index.d.cts CHANGED
@@ -273,6 +273,8 @@ interface CheckoutResult {
273
273
  */
274
274
  checkout: {
275
275
  id: string;
276
+ /** Stripe-like client secret for secure status polling */
277
+ clientSecret: string;
276
278
  checkoutNumber: string;
277
279
  status: string;
278
280
  productId: string;
@@ -399,6 +401,31 @@ interface RecurContextValue {
399
401
  * Update configuration
400
402
  */
401
403
  updateConfig: (config: Partial<RecurConfig>) => void;
404
+ /**
405
+ * Get checkout status using client secret
406
+ * Used to poll payment status after 3D verification or async operations
407
+ */
408
+ getCheckoutStatus: (checkoutId: string, clientSecret: string) => Promise<CheckoutStatusResult>;
409
+ }
410
+ /**
411
+ * Checkout status result from polling
412
+ */
413
+ interface CheckoutStatusResult {
414
+ /** Checkout/PaymentIntent ID */
415
+ id: string;
416
+ /** Current status */
417
+ status: 'REQUIRES_PAYMENT_METHOD' | 'REQUIRES_CONFIRMATION' | 'REQUIRES_ACTION' | 'PROCESSING' | 'SUCCEEDED' | 'CANCELED';
418
+ /** Amount in smallest currency unit */
419
+ amount: number;
420
+ /** Currency code */
421
+ currency: string;
422
+ /** Last charge information */
423
+ lastCharge?: {
424
+ id: string;
425
+ status: string;
426
+ failureCode?: string;
427
+ failureMessage?: string;
428
+ };
402
429
  }
403
430
  /**
404
431
  * PAYUNi SDK types
package/dist/index.d.ts CHANGED
@@ -273,6 +273,8 @@ interface CheckoutResult {
273
273
  */
274
274
  checkout: {
275
275
  id: string;
276
+ /** Stripe-like client secret for secure status polling */
277
+ clientSecret: string;
276
278
  checkoutNumber: string;
277
279
  status: string;
278
280
  productId: string;
@@ -399,6 +401,31 @@ interface RecurContextValue {
399
401
  * Update configuration
400
402
  */
401
403
  updateConfig: (config: Partial<RecurConfig>) => void;
404
+ /**
405
+ * Get checkout status using client secret
406
+ * Used to poll payment status after 3D verification or async operations
407
+ */
408
+ getCheckoutStatus: (checkoutId: string, clientSecret: string) => Promise<CheckoutStatusResult>;
409
+ }
410
+ /**
411
+ * Checkout status result from polling
412
+ */
413
+ interface CheckoutStatusResult {
414
+ /** Checkout/PaymentIntent ID */
415
+ id: string;
416
+ /** Current status */
417
+ status: 'REQUIRES_PAYMENT_METHOD' | 'REQUIRES_CONFIRMATION' | 'REQUIRES_ACTION' | 'PROCESSING' | 'SUCCEEDED' | 'CANCELED';
418
+ /** Amount in smallest currency unit */
419
+ amount: number;
420
+ /** Currency code */
421
+ currency: string;
422
+ /** Last charge information */
423
+ lastCharge?: {
424
+ id: string;
425
+ status: string;
426
+ failureCode?: string;
427
+ failureMessage?: string;
428
+ };
402
429
  }
403
430
  /**
404
431
  * PAYUNi SDK types
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recur-tw",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "description": "React & Vanilla JS SDK for embedding subscription checkout flows (Taiwan / PAYUNi)",
5
5
  "type": "module",
6
6
  "private": false,
@@ -28,6 +28,14 @@
28
28
  "url": "https://github.com/kaikhq/recur.tw/issues"
29
29
  },
30
30
  "homepage": "https://github.com/kaikhq/recur.tw/tree/main/packages/recur-sdk#readme",
31
+ "scripts": {
32
+ "build": "tsup",
33
+ "dev": "tsup --watch",
34
+ "lint": "eslint .",
35
+ "lint:fix": "eslint . --fix",
36
+ "type-check": "tsc --noEmit",
37
+ "examples": "npx http-server examples -p 8080 -o"
38
+ },
31
39
  "main": "./dist/index.js",
32
40
  "module": "./dist/index.js",
33
41
  "types": "./dist/index.d.ts",
@@ -74,6 +82,7 @@
74
82
  "@types/node": "^20.19.9",
75
83
  "@types/react": "^19.1.9",
76
84
  "@types/react-dom": "^19.1.7",
85
+ "@workspace/typescript-config": "workspace:*",
77
86
  "autoprefixer": "^10.4.22",
78
87
  "eslint": "^9",
79
88
  "eslint-plugin-react": "^7.37.5",
@@ -84,15 +93,6 @@
84
93
  "tailwindcss": "^4.1.11",
85
94
  "tsup": "^8.3.5",
86
95
  "typescript": "^5.9.2",
87
- "typescript-eslint": "^8.47.0",
88
- "@workspace/typescript-config": "0.0.0"
89
- },
90
- "scripts": {
91
- "build": "tsup",
92
- "dev": "tsup --watch",
93
- "lint": "eslint .",
94
- "lint:fix": "eslint . --fix",
95
- "type-check": "tsc --noEmit",
96
- "examples": "npx http-server examples -p 8080 -o"
96
+ "typescript-eslint": "^8.47.0"
97
97
  }
98
- }
98
+ }
package/dist/server.d.cts DELETED
@@ -1,194 +0,0 @@
1
- /**
2
- * Recur Server SDK Types
3
- */
4
- interface RecurConfig {
5
- /**
6
- * Secret API key for authentication
7
- * Get this from your organization settings
8
- *
9
- * @example 'sk_test_abc123...' or 'sk_live_xyz789...'
10
- */
11
- secretKey: string;
12
- /**
13
- * Base URL for API calls
14
- * Defaults to 'https://api.recur.tw'
15
- */
16
- baseUrl?: string;
17
- }
18
- /**
19
- * Parameters for creating a portal session
20
- *
21
- * Customer Identification (at least one required):
22
- * - customer: Internal customer ID in Recur (highest priority)
23
- * - externalId: Customer's external ID from your system
24
- * - email: Customer's email address (lowest priority)
25
- */
26
- interface PortalSessionCreateParams {
27
- /**
28
- * The internal ID of the customer to create a portal session for
29
- * Takes highest priority when multiple identifiers are provided
30
- */
31
- customer?: string;
32
- /**
33
- * Customer's email address
34
- * Used to identify the customer if `customer` and `externalId` are not provided
35
- */
36
- email?: string;
37
- /**
38
- * Customer's external ID from your system
39
- * Used to identify the customer if `customer` is not provided
40
- */
41
- externalId?: string;
42
- /**
43
- * The URL to redirect the customer to when they exit the portal
44
- * If not provided, uses the default return URL from portal configuration
45
- */
46
- returnUrl?: string;
47
- /**
48
- * The ID of a specific portal configuration to use
49
- * If not provided, uses the default configuration
50
- */
51
- configuration?: string;
52
- /**
53
- * Preferred locale for the portal
54
- */
55
- locale?: 'zh-TW' | 'en';
56
- }
57
- interface PortalSession {
58
- /**
59
- * Unique identifier for the portal session
60
- */
61
- id: string;
62
- /**
63
- * String representing the object's type
64
- */
65
- object: 'portal.session';
66
- /**
67
- * The URL to redirect the customer to access the portal
68
- */
69
- url: string;
70
- /**
71
- * The ID of the customer for this session
72
- */
73
- customer: string;
74
- /**
75
- * The URL to redirect the customer when they exit the portal
76
- */
77
- returnUrl: string;
78
- /**
79
- * The status of the session
80
- */
81
- status: 'active' | 'expired';
82
- /**
83
- * Time at which the session expires (ISO 8601)
84
- */
85
- expiresAt: string;
86
- /**
87
- * Time at which the session was last accessed (ISO 8601), or null
88
- */
89
- accessedAt: string | null;
90
- /**
91
- * Time at which the session was created (ISO 8601)
92
- */
93
- createdAt: string;
94
- }
95
- interface RecurError {
96
- type: 'authentication_error' | 'invalid_request_error' | 'api_error';
97
- code: string;
98
- message: string;
99
- details?: unknown;
100
- }
101
- declare class RecurAPIError extends Error {
102
- readonly type: string;
103
- readonly code: string;
104
- readonly statusCode: number;
105
- constructor(error: RecurError, statusCode: number);
106
- }
107
-
108
- /**
109
- * Portal Sessions Resource
110
- *
111
- * Create portal sessions to allow customers to manage their subscriptions
112
- */
113
-
114
- declare class PortalSessions {
115
- private config;
116
- constructor(config: RecurConfig);
117
- /**
118
- * Create a portal session for a customer
119
- *
120
- * Customer can be identified using one of:
121
- * - `customer`: Internal customer ID (highest priority)
122
- * - `externalId`: External customer ID from your system
123
- * - `email`: Customer's email address (lowest priority)
124
- *
125
- * @param params - Portal session creation parameters
126
- * @returns The created portal session with URL
127
- *
128
- * @example
129
- * ```typescript
130
- * // By customer ID
131
- * const session = await recur.portal.sessions.create({
132
- * customer: 'cus_xxx',
133
- * returnUrl: 'https://myapp.com/account',
134
- * });
135
- *
136
- * // By email
137
- * const session = await recur.portal.sessions.create({
138
- * email: 'customer@example.com',
139
- * returnUrl: 'https://myapp.com/account',
140
- * });
141
- *
142
- * // By external ID
143
- * const session = await recur.portal.sessions.create({
144
- * externalId: 'user_123',
145
- * returnUrl: 'https://myapp.com/account',
146
- * });
147
- *
148
- * // Redirect the customer to the portal
149
- * redirect(session.url);
150
- * ```
151
- */
152
- create(params: PortalSessionCreateParams): Promise<PortalSession>;
153
- }
154
- declare class Portal {
155
- readonly sessions: PortalSessions;
156
- constructor(config: RecurConfig);
157
- }
158
-
159
- /**
160
- * Recur Server SDK
161
- *
162
- * Server-side SDK for interacting with the Recur API
163
- * Use this in your backend (API routes, server actions, etc.)
164
- *
165
- * @example
166
- * ```typescript
167
- * import { Recur } from 'recur-tw/server';
168
- *
169
- * const recur = new Recur(process.env.RECUR_SECRET_KEY!);
170
- *
171
- * // Create a portal session
172
- * const session = await recur.portal.sessions.create({
173
- * customer: 'cus_xxx',
174
- * returnUrl: 'https://myapp.com/account',
175
- * });
176
- * ```
177
- */
178
-
179
- declare class Recur {
180
- private config;
181
- /**
182
- * Portal resource for managing customer portal sessions
183
- */
184
- readonly portal: Portal;
185
- /**
186
- * Create a new Recur client
187
- *
188
- * @param secretKey - Your Recur secret API key (sk_test_xxx or sk_live_xxx)
189
- * @param options - Additional configuration options
190
- */
191
- constructor(secretKey: string, options?: Omit<RecurConfig, 'secretKey'>);
192
- }
193
-
194
- export { type PortalSession, type PortalSessionCreateParams, Recur, RecurAPIError, type RecurConfig, type RecurError };
package/dist/server.d.ts DELETED
@@ -1,194 +0,0 @@
1
- /**
2
- * Recur Server SDK Types
3
- */
4
- interface RecurConfig {
5
- /**
6
- * Secret API key for authentication
7
- * Get this from your organization settings
8
- *
9
- * @example 'sk_test_abc123...' or 'sk_live_xyz789...'
10
- */
11
- secretKey: string;
12
- /**
13
- * Base URL for API calls
14
- * Defaults to 'https://api.recur.tw'
15
- */
16
- baseUrl?: string;
17
- }
18
- /**
19
- * Parameters for creating a portal session
20
- *
21
- * Customer Identification (at least one required):
22
- * - customer: Internal customer ID in Recur (highest priority)
23
- * - externalId: Customer's external ID from your system
24
- * - email: Customer's email address (lowest priority)
25
- */
26
- interface PortalSessionCreateParams {
27
- /**
28
- * The internal ID of the customer to create a portal session for
29
- * Takes highest priority when multiple identifiers are provided
30
- */
31
- customer?: string;
32
- /**
33
- * Customer's email address
34
- * Used to identify the customer if `customer` and `externalId` are not provided
35
- */
36
- email?: string;
37
- /**
38
- * Customer's external ID from your system
39
- * Used to identify the customer if `customer` is not provided
40
- */
41
- externalId?: string;
42
- /**
43
- * The URL to redirect the customer to when they exit the portal
44
- * If not provided, uses the default return URL from portal configuration
45
- */
46
- returnUrl?: string;
47
- /**
48
- * The ID of a specific portal configuration to use
49
- * If not provided, uses the default configuration
50
- */
51
- configuration?: string;
52
- /**
53
- * Preferred locale for the portal
54
- */
55
- locale?: 'zh-TW' | 'en';
56
- }
57
- interface PortalSession {
58
- /**
59
- * Unique identifier for the portal session
60
- */
61
- id: string;
62
- /**
63
- * String representing the object's type
64
- */
65
- object: 'portal.session';
66
- /**
67
- * The URL to redirect the customer to access the portal
68
- */
69
- url: string;
70
- /**
71
- * The ID of the customer for this session
72
- */
73
- customer: string;
74
- /**
75
- * The URL to redirect the customer when they exit the portal
76
- */
77
- returnUrl: string;
78
- /**
79
- * The status of the session
80
- */
81
- status: 'active' | 'expired';
82
- /**
83
- * Time at which the session expires (ISO 8601)
84
- */
85
- expiresAt: string;
86
- /**
87
- * Time at which the session was last accessed (ISO 8601), or null
88
- */
89
- accessedAt: string | null;
90
- /**
91
- * Time at which the session was created (ISO 8601)
92
- */
93
- createdAt: string;
94
- }
95
- interface RecurError {
96
- type: 'authentication_error' | 'invalid_request_error' | 'api_error';
97
- code: string;
98
- message: string;
99
- details?: unknown;
100
- }
101
- declare class RecurAPIError extends Error {
102
- readonly type: string;
103
- readonly code: string;
104
- readonly statusCode: number;
105
- constructor(error: RecurError, statusCode: number);
106
- }
107
-
108
- /**
109
- * Portal Sessions Resource
110
- *
111
- * Create portal sessions to allow customers to manage their subscriptions
112
- */
113
-
114
- declare class PortalSessions {
115
- private config;
116
- constructor(config: RecurConfig);
117
- /**
118
- * Create a portal session for a customer
119
- *
120
- * Customer can be identified using one of:
121
- * - `customer`: Internal customer ID (highest priority)
122
- * - `externalId`: External customer ID from your system
123
- * - `email`: Customer's email address (lowest priority)
124
- *
125
- * @param params - Portal session creation parameters
126
- * @returns The created portal session with URL
127
- *
128
- * @example
129
- * ```typescript
130
- * // By customer ID
131
- * const session = await recur.portal.sessions.create({
132
- * customer: 'cus_xxx',
133
- * returnUrl: 'https://myapp.com/account',
134
- * });
135
- *
136
- * // By email
137
- * const session = await recur.portal.sessions.create({
138
- * email: 'customer@example.com',
139
- * returnUrl: 'https://myapp.com/account',
140
- * });
141
- *
142
- * // By external ID
143
- * const session = await recur.portal.sessions.create({
144
- * externalId: 'user_123',
145
- * returnUrl: 'https://myapp.com/account',
146
- * });
147
- *
148
- * // Redirect the customer to the portal
149
- * redirect(session.url);
150
- * ```
151
- */
152
- create(params: PortalSessionCreateParams): Promise<PortalSession>;
153
- }
154
- declare class Portal {
155
- readonly sessions: PortalSessions;
156
- constructor(config: RecurConfig);
157
- }
158
-
159
- /**
160
- * Recur Server SDK
161
- *
162
- * Server-side SDK for interacting with the Recur API
163
- * Use this in your backend (API routes, server actions, etc.)
164
- *
165
- * @example
166
- * ```typescript
167
- * import { Recur } from 'recur-tw/server';
168
- *
169
- * const recur = new Recur(process.env.RECUR_SECRET_KEY!);
170
- *
171
- * // Create a portal session
172
- * const session = await recur.portal.sessions.create({
173
- * customer: 'cus_xxx',
174
- * returnUrl: 'https://myapp.com/account',
175
- * });
176
- * ```
177
- */
178
-
179
- declare class Recur {
180
- private config;
181
- /**
182
- * Portal resource for managing customer portal sessions
183
- */
184
- readonly portal: Portal;
185
- /**
186
- * Create a new Recur client
187
- *
188
- * @param secretKey - Your Recur secret API key (sk_test_xxx or sk_live_xxx)
189
- * @param options - Additional configuration options
190
- */
191
- constructor(secretKey: string, options?: Omit<RecurConfig, 'secretKey'>);
192
- }
193
-
194
- export { type PortalSession, type PortalSessionCreateParams, Recur, RecurAPIError, type RecurConfig, type RecurError };