@plyaz/types 1.16.6 → 1.16.8

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.
@@ -6,3 +6,10 @@ export declare enum WITHDRAWAL_STATUS {
6
6
  Failed = "failed",
7
7
  Cancelled = "cancelled"
8
8
  }
9
+ export declare enum SUBSCRIPTION_STATUS {
10
+ ACTIVE = "active",
11
+ TRIALING = "trialing",
12
+ PAUSED = "paused",
13
+ CANCELED = "canceled",
14
+ EXPIRED = "expired"
15
+ }
@@ -1,7 +1,7 @@
1
1
  import type { CurrencyCode } from '../../../locale/types';
2
2
  import type { FeeBreakdown, Money } from '../../transaction';
3
3
  import type { PAYMENT_METHOD, PAYMENT_PROVIDER_TYPE, PAYMENT_STATUS } from '../provider-capability';
4
- import type { WITHDRAWAL_STATUS } from './enums';
4
+ import type { SUBSCRIPTION_STATUS, WITHDRAWAL_STATUS } from './enums';
5
5
  /**
6
6
  * Parameters required to initiate a refund.
7
7
  * Refunds can be full or partial.
@@ -353,26 +353,44 @@ export interface SavedPaymentMethod<TMetadata extends object = object> {
353
353
  export interface CreateSubscriptionParams<TMetadata extends object = object> {
354
354
  /** Plyaz user ID (Stripe customer ID or your internal user ID mapped to Stripe) */
355
355
  userId: string;
356
- /** Plan to subscribe the user to: 'standard' | 'pro' | 'enterprise' */
357
- plan: 'standard' | 'pro' | 'enterprise';
358
- /** Payment method to charge (Stripe payment method ID) */
359
- paymentMethodId: string;
356
+ paymentMethod: PAYMENT_METHOD;
357
+ /** Plan to subscribe the user to (internal plan name) */
358
+ plan: string;
360
359
  /** Optional trial period in days */
361
360
  trialDays?: number;
361
+ /** URL to redirect user after successful payment completion */
362
+ returnUrl?: string;
363
+ /** URL to redirect user after payment cancellation */
364
+ cancelUrl?: string;
365
+ /**
366
+ * Idempotency key to prevent duplicate payment processing
367
+ * Should be unique per payment attempt, recommended: UUID v4
368
+ */
369
+ idempotencyKey?: string;
362
370
  /** Optional metadata for additional info */
363
- metadata?: TMetadata;
371
+ metadata?: {
372
+ /** Geographic and device information */
373
+ geoInfo?: {
374
+ country: string;
375
+ region?: string;
376
+ city?: string;
377
+ timezone?: string;
378
+ };
379
+ /** Custom metadata fields */
380
+ custom?: TMetadata;
381
+ };
364
382
  }
365
383
  export interface SubscriptionResult<TMetadata extends object = object> {
366
- /** Internal subscription ID */
367
- subscriptionId: string;
368
- /** Provider subscription ID */
384
+ /** Checkout session URL for user to complete subscription */
385
+ checkoutUrl: string;
386
+ /** Optional: provider subscription ID (available after webhook confirmation) */
369
387
  providerSubscriptionId?: string;
370
388
  /** Status: active, trialing, paused, canceled, expired */
371
- status: 'active' | 'trialing' | 'paused' | 'canceled' | 'expired';
372
- /** Next billing date */
389
+ status?: SUBSCRIPTION_STATUS;
390
+ /** Next billing date (available after webhook) */
373
391
  nextBillingDate?: Date;
374
- /** Subscription start date */
375
- startedAt: Date;
392
+ /** Subscription start date (available after webhook) */
393
+ startedAt?: Date;
376
394
  /** Provider-specific metadata */
377
395
  metadata?: TMetadata;
378
396
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plyaz/types",
3
- "version": "1.16.6",
3
+ "version": "1.16.8",
4
4
  "author": "Redeemer Pace",
5
5
  "license": "ISC",
6
6
  "description": "Provides shared TypeScript types and schema utilities for validation and parsing in the @playz ecosystem.",