@insforge/sdk 1.3.0 → 1.3.2-razorpay.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.
@@ -1,4 +1,4 @@
1
- import { UserSchema, ErrorCode, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, OAuthProvidersSchema, RefreshSessionResponse, GetProfileResponse, SendVerificationEmailRequest, VerifyEmailRequest, VerifyEmailResponse, SendResetPasswordEmailRequest, ExchangeResetPasswordTokenRequest, ExchangeResetPasswordTokenResponse, ResetPasswordResponse, GetPublicAuthConfigResponse, StorageFileSchema, ListObjectsResponseSchema, ChatCompletionRequest, ImageGenerationRequest, EmbeddingsRequest, SubscribeResponse, SocketMessage, SendRawEmailRequest, SendEmailResponse, StripeEnvironment, CreateCheckoutSessionBody, CreateCheckoutSessionResponse, CreateCustomerPortalSessionBody, CreateCustomerPortalSessionResponse } from '@insforge/shared-schemas';
1
+ import { UserSchema, ErrorCode, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, OAuthProvidersSchema, RefreshSessionResponse, GetProfileResponse, SendVerificationEmailRequest, VerifyEmailRequest, VerifyEmailResponse, SendResetPasswordEmailRequest, ExchangeResetPasswordTokenRequest, ExchangeResetPasswordTokenResponse, ResetPasswordResponse, GetPublicAuthConfigResponse, StorageFileSchema, ListObjectsResponseSchema, ChatCompletionRequest, ImageGenerationRequest, EmbeddingsRequest, SubscribeResponse, SocketMessage, SendRawEmailRequest, SendEmailResponse, StripeEnvironment, CreateCheckoutSessionBody, CreateCheckoutSessionResponse, CreateCustomerPortalSessionBody, CreateCustomerPortalSessionResponse, RazorpayEnvironment, CreateRazorpayOrderBody, CreateRazorpayOrderResponse, VerifyRazorpayOrderBody, VerifyRazorpayOrderResponse, CreateRazorpaySubscriptionBody, CreateRazorpaySubscriptionResponse, VerifyRazorpaySubscriptionBody, VerifyRazorpaySubscriptionResponse, cancelRazorpaySubscriptionBodySchema, CancelRazorpaySubscriptionResponse, PauseRazorpaySubscriptionResponse, ResumeRazorpaySubscriptionResponse } from '@insforge/shared-schemas';
2
2
  import * as _supabase_postgrest_js from '@supabase/postgrest-js';
3
3
 
4
4
  /**
@@ -312,6 +312,14 @@ declare class HttpClient {
312
312
  interface AuthOptions {
313
313
  isServerMode?: boolean;
314
314
  }
315
+ type OAuthSignInOptions = {
316
+ redirectTo: string;
317
+ additionalParams?: Record<string, string>;
318
+ skipBrowserRedirect?: boolean;
319
+ };
320
+ type OAuthSignInLegacyOptions = OAuthSignInOptions & {
321
+ provider: OAuthProvidersSchema | string;
322
+ };
315
323
  declare class Auth {
316
324
  private http;
317
325
  private tokenManager;
@@ -343,11 +351,18 @@ declare class Auth {
343
351
  /**
344
352
  * Sign in with OAuth provider using PKCE flow
345
353
  */
346
- signInWithOAuth(options: {
347
- provider: OAuthProvidersSchema | string;
348
- redirectTo?: string;
349
- skipBrowserRedirect?: boolean;
350
- }): Promise<{
354
+ signInWithOAuth(provider: OAuthProvidersSchema | string, options: OAuthSignInOptions): Promise<{
355
+ data: {
356
+ url?: string;
357
+ provider?: string;
358
+ codeVerifier?: string;
359
+ };
360
+ error: InsForgeError | null;
361
+ }>;
362
+ /**
363
+ * @deprecated Use signInWithOAuth(provider, { redirectTo, additionalParams, skipBrowserRedirect }).
364
+ */
365
+ signInWithOAuth(options: OAuthSignInLegacyOptions): Promise<{
351
366
  data: {
352
367
  url?: string;
353
368
  provider?: string;
@@ -743,7 +758,7 @@ declare class Images {
743
758
  * model: 'dall-e-3',
744
759
  * prompt: 'A sunset over mountains',
745
760
  * });
746
- * console.log(response.images[0].url);
761
+ * console.log(response.data[0].b64_json);
747
762
  *
748
763
  * // Image-to-image (with input images)
749
764
  * const response = await client.ai.images.generate({
@@ -998,14 +1013,15 @@ interface PaymentsResponse<T> {
998
1013
  data: T | null;
999
1014
  error: InsForgeError | null;
1000
1015
  }
1016
+ type CancelRazorpaySubscriptionBodyInput = (typeof cancelRazorpaySubscriptionBodySchema)["_input"];
1001
1017
  /**
1002
- * Payments client for runtime Stripe payment flows.
1018
+ * Stripe runtime payment flows.
1003
1019
  *
1004
1020
  * These methods are safe to call from generated app frontends with the current
1005
1021
  * user token or anon key. Admin-only Stripe key/catalog APIs are intentionally
1006
1022
  * not exposed here.
1007
1023
  */
1008
- declare class Payments {
1024
+ declare class StripePayments {
1009
1025
  private http;
1010
1026
  constructor(http: HttpClient);
1011
1027
  /**
@@ -1013,9 +1029,9 @@ declare class Payments {
1013
1029
  *
1014
1030
  * @example
1015
1031
  * ```typescript
1016
- * const { data, error } = await client.payments.createCheckoutSession('test', {
1032
+ * const { data, error } = await client.payments.stripe.createCheckoutSession('test', {
1017
1033
  * mode: 'payment',
1018
- * lineItems: [{ stripePriceId: 'price_123', quantity: 1 }],
1034
+ * lineItems: [{ priceId: 'price_123', quantity: 1 }],
1019
1035
  * successUrl: `${window.location.origin}/success`,
1020
1036
  * cancelUrl: `${window.location.origin}/pricing`
1021
1037
  * });
@@ -1031,6 +1047,32 @@ declare class Payments {
1031
1047
  */
1032
1048
  createCustomerPortalSession(environment: StripeEnvironment, request: CreateCustomerPortalSessionBody): Promise<PaymentsResponse<CreateCustomerPortalSessionResponse>>;
1033
1049
  }
1050
+ /**
1051
+ * Razorpay runtime payment flows.
1052
+ *
1053
+ * Razorpay Checkout is client-rendered: create an order or subscription here,
1054
+ * pass the returned checkoutOptions to Razorpay Checkout.js, then verify the
1055
+ * signed payment response with the matching verify method.
1056
+ */
1057
+ declare class RazorpayPayments {
1058
+ private http;
1059
+ constructor(http: HttpClient);
1060
+ createOrder(environment: RazorpayEnvironment, request: CreateRazorpayOrderBody): Promise<PaymentsResponse<CreateRazorpayOrderResponse>>;
1061
+ verifyOrder(environment: RazorpayEnvironment, request: VerifyRazorpayOrderBody): Promise<PaymentsResponse<VerifyRazorpayOrderResponse>>;
1062
+ createSubscription(environment: RazorpayEnvironment, request: CreateRazorpaySubscriptionBody): Promise<PaymentsResponse<CreateRazorpaySubscriptionResponse>>;
1063
+ verifySubscription(environment: RazorpayEnvironment, request: VerifyRazorpaySubscriptionBody): Promise<PaymentsResponse<VerifyRazorpaySubscriptionResponse>>;
1064
+ cancelSubscription(environment: RazorpayEnvironment, subscriptionId: string, request?: CancelRazorpaySubscriptionBodyInput): Promise<PaymentsResponse<CancelRazorpaySubscriptionResponse>>;
1065
+ pauseSubscription(environment: RazorpayEnvironment, subscriptionId: string): Promise<PaymentsResponse<PauseRazorpaySubscriptionResponse>>;
1066
+ resumeSubscription(environment: RazorpayEnvironment, subscriptionId: string): Promise<PaymentsResponse<ResumeRazorpaySubscriptionResponse>>;
1067
+ }
1068
+ /**
1069
+ * Provider-scoped payments client.
1070
+ */
1071
+ declare class Payments {
1072
+ readonly stripe: StripePayments;
1073
+ readonly razorpay: RazorpayPayments;
1074
+ constructor(http: HttpClient);
1075
+ }
1034
1076
 
1035
1077
  /**
1036
1078
  * Main InsForge SDK Client
@@ -1,4 +1,4 @@
1
- import { UserSchema, ErrorCode, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, OAuthProvidersSchema, RefreshSessionResponse, GetProfileResponse, SendVerificationEmailRequest, VerifyEmailRequest, VerifyEmailResponse, SendResetPasswordEmailRequest, ExchangeResetPasswordTokenRequest, ExchangeResetPasswordTokenResponse, ResetPasswordResponse, GetPublicAuthConfigResponse, StorageFileSchema, ListObjectsResponseSchema, ChatCompletionRequest, ImageGenerationRequest, EmbeddingsRequest, SubscribeResponse, SocketMessage, SendRawEmailRequest, SendEmailResponse, StripeEnvironment, CreateCheckoutSessionBody, CreateCheckoutSessionResponse, CreateCustomerPortalSessionBody, CreateCustomerPortalSessionResponse } from '@insforge/shared-schemas';
1
+ import { UserSchema, ErrorCode, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, OAuthProvidersSchema, RefreshSessionResponse, GetProfileResponse, SendVerificationEmailRequest, VerifyEmailRequest, VerifyEmailResponse, SendResetPasswordEmailRequest, ExchangeResetPasswordTokenRequest, ExchangeResetPasswordTokenResponse, ResetPasswordResponse, GetPublicAuthConfigResponse, StorageFileSchema, ListObjectsResponseSchema, ChatCompletionRequest, ImageGenerationRequest, EmbeddingsRequest, SubscribeResponse, SocketMessage, SendRawEmailRequest, SendEmailResponse, StripeEnvironment, CreateCheckoutSessionBody, CreateCheckoutSessionResponse, CreateCustomerPortalSessionBody, CreateCustomerPortalSessionResponse, RazorpayEnvironment, CreateRazorpayOrderBody, CreateRazorpayOrderResponse, VerifyRazorpayOrderBody, VerifyRazorpayOrderResponse, CreateRazorpaySubscriptionBody, CreateRazorpaySubscriptionResponse, VerifyRazorpaySubscriptionBody, VerifyRazorpaySubscriptionResponse, cancelRazorpaySubscriptionBodySchema, CancelRazorpaySubscriptionResponse, PauseRazorpaySubscriptionResponse, ResumeRazorpaySubscriptionResponse } from '@insforge/shared-schemas';
2
2
  import * as _supabase_postgrest_js from '@supabase/postgrest-js';
3
3
 
4
4
  /**
@@ -312,6 +312,14 @@ declare class HttpClient {
312
312
  interface AuthOptions {
313
313
  isServerMode?: boolean;
314
314
  }
315
+ type OAuthSignInOptions = {
316
+ redirectTo: string;
317
+ additionalParams?: Record<string, string>;
318
+ skipBrowserRedirect?: boolean;
319
+ };
320
+ type OAuthSignInLegacyOptions = OAuthSignInOptions & {
321
+ provider: OAuthProvidersSchema | string;
322
+ };
315
323
  declare class Auth {
316
324
  private http;
317
325
  private tokenManager;
@@ -343,11 +351,18 @@ declare class Auth {
343
351
  /**
344
352
  * Sign in with OAuth provider using PKCE flow
345
353
  */
346
- signInWithOAuth(options: {
347
- provider: OAuthProvidersSchema | string;
348
- redirectTo?: string;
349
- skipBrowserRedirect?: boolean;
350
- }): Promise<{
354
+ signInWithOAuth(provider: OAuthProvidersSchema | string, options: OAuthSignInOptions): Promise<{
355
+ data: {
356
+ url?: string;
357
+ provider?: string;
358
+ codeVerifier?: string;
359
+ };
360
+ error: InsForgeError | null;
361
+ }>;
362
+ /**
363
+ * @deprecated Use signInWithOAuth(provider, { redirectTo, additionalParams, skipBrowserRedirect }).
364
+ */
365
+ signInWithOAuth(options: OAuthSignInLegacyOptions): Promise<{
351
366
  data: {
352
367
  url?: string;
353
368
  provider?: string;
@@ -743,7 +758,7 @@ declare class Images {
743
758
  * model: 'dall-e-3',
744
759
  * prompt: 'A sunset over mountains',
745
760
  * });
746
- * console.log(response.images[0].url);
761
+ * console.log(response.data[0].b64_json);
747
762
  *
748
763
  * // Image-to-image (with input images)
749
764
  * const response = await client.ai.images.generate({
@@ -998,14 +1013,15 @@ interface PaymentsResponse<T> {
998
1013
  data: T | null;
999
1014
  error: InsForgeError | null;
1000
1015
  }
1016
+ type CancelRazorpaySubscriptionBodyInput = (typeof cancelRazorpaySubscriptionBodySchema)["_input"];
1001
1017
  /**
1002
- * Payments client for runtime Stripe payment flows.
1018
+ * Stripe runtime payment flows.
1003
1019
  *
1004
1020
  * These methods are safe to call from generated app frontends with the current
1005
1021
  * user token or anon key. Admin-only Stripe key/catalog APIs are intentionally
1006
1022
  * not exposed here.
1007
1023
  */
1008
- declare class Payments {
1024
+ declare class StripePayments {
1009
1025
  private http;
1010
1026
  constructor(http: HttpClient);
1011
1027
  /**
@@ -1013,9 +1029,9 @@ declare class Payments {
1013
1029
  *
1014
1030
  * @example
1015
1031
  * ```typescript
1016
- * const { data, error } = await client.payments.createCheckoutSession('test', {
1032
+ * const { data, error } = await client.payments.stripe.createCheckoutSession('test', {
1017
1033
  * mode: 'payment',
1018
- * lineItems: [{ stripePriceId: 'price_123', quantity: 1 }],
1034
+ * lineItems: [{ priceId: 'price_123', quantity: 1 }],
1019
1035
  * successUrl: `${window.location.origin}/success`,
1020
1036
  * cancelUrl: `${window.location.origin}/pricing`
1021
1037
  * });
@@ -1031,6 +1047,32 @@ declare class Payments {
1031
1047
  */
1032
1048
  createCustomerPortalSession(environment: StripeEnvironment, request: CreateCustomerPortalSessionBody): Promise<PaymentsResponse<CreateCustomerPortalSessionResponse>>;
1033
1049
  }
1050
+ /**
1051
+ * Razorpay runtime payment flows.
1052
+ *
1053
+ * Razorpay Checkout is client-rendered: create an order or subscription here,
1054
+ * pass the returned checkoutOptions to Razorpay Checkout.js, then verify the
1055
+ * signed payment response with the matching verify method.
1056
+ */
1057
+ declare class RazorpayPayments {
1058
+ private http;
1059
+ constructor(http: HttpClient);
1060
+ createOrder(environment: RazorpayEnvironment, request: CreateRazorpayOrderBody): Promise<PaymentsResponse<CreateRazorpayOrderResponse>>;
1061
+ verifyOrder(environment: RazorpayEnvironment, request: VerifyRazorpayOrderBody): Promise<PaymentsResponse<VerifyRazorpayOrderResponse>>;
1062
+ createSubscription(environment: RazorpayEnvironment, request: CreateRazorpaySubscriptionBody): Promise<PaymentsResponse<CreateRazorpaySubscriptionResponse>>;
1063
+ verifySubscription(environment: RazorpayEnvironment, request: VerifyRazorpaySubscriptionBody): Promise<PaymentsResponse<VerifyRazorpaySubscriptionResponse>>;
1064
+ cancelSubscription(environment: RazorpayEnvironment, subscriptionId: string, request?: CancelRazorpaySubscriptionBodyInput): Promise<PaymentsResponse<CancelRazorpaySubscriptionResponse>>;
1065
+ pauseSubscription(environment: RazorpayEnvironment, subscriptionId: string): Promise<PaymentsResponse<PauseRazorpaySubscriptionResponse>>;
1066
+ resumeSubscription(environment: RazorpayEnvironment, subscriptionId: string): Promise<PaymentsResponse<ResumeRazorpaySubscriptionResponse>>;
1067
+ }
1068
+ /**
1069
+ * Provider-scoped payments client.
1070
+ */
1071
+ declare class Payments {
1072
+ readonly stripe: StripePayments;
1073
+ readonly razorpay: RazorpayPayments;
1074
+ constructor(http: HttpClient);
1075
+ }
1034
1076
 
1035
1077
  /**
1036
1078
  * Main InsForge SDK Client
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as InsForgeClient, a as InsForgeConfig, b as InsForgeAdminConfig } from './client-CQfw9UsO.mjs';
2
- export { i as AI, c as ApiError, f as Auth, A as AuthSession, C as ConnectionState, D as Database, E as Emails, l as EventCallback, j as FunctionInvokeOptions, F as Functions, H as HttpClient, e as InsForgeError, d as InsForgeErrorCode, L as Logger, P as Payments, k as PaymentsResponse, R as Realtime, S as Storage, g as StorageBucket, h as StorageResponse, T as TokenManager } from './client-CQfw9UsO.mjs';
1
+ import { I as InsForgeClient, a as InsForgeConfig, b as InsForgeAdminConfig } from './client-Co8KxT-n.mjs';
2
+ export { i as AI, c as ApiError, f as Auth, A as AuthSession, C as ConnectionState, D as Database, E as Emails, l as EventCallback, j as FunctionInvokeOptions, F as Functions, H as HttpClient, e as InsForgeError, d as InsForgeErrorCode, L as Logger, P as Payments, k as PaymentsResponse, R as Realtime, S as Storage, g as StorageBucket, h as StorageResponse, T as TokenManager } from './client-Co8KxT-n.mjs';
3
3
  export { AuthErrorResponse, CreateSessionRequest, CreateUserRequest, RealtimeErrorPayload, SendRawEmailRequest as SendEmailOptions, SendEmailResponse, SocketMessage, SubscribeResponse, UserSchema } from '@insforge/shared-schemas';
4
4
  import '@supabase/postgrest-js';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as InsForgeClient, a as InsForgeConfig, b as InsForgeAdminConfig } from './client-CQfw9UsO.js';
2
- export { i as AI, c as ApiError, f as Auth, A as AuthSession, C as ConnectionState, D as Database, E as Emails, l as EventCallback, j as FunctionInvokeOptions, F as Functions, H as HttpClient, e as InsForgeError, d as InsForgeErrorCode, L as Logger, P as Payments, k as PaymentsResponse, R as Realtime, S as Storage, g as StorageBucket, h as StorageResponse, T as TokenManager } from './client-CQfw9UsO.js';
1
+ import { I as InsForgeClient, a as InsForgeConfig, b as InsForgeAdminConfig } from './client-Co8KxT-n.js';
2
+ export { i as AI, c as ApiError, f as Auth, A as AuthSession, C as ConnectionState, D as Database, E as Emails, l as EventCallback, j as FunctionInvokeOptions, F as Functions, H as HttpClient, e as InsForgeError, d as InsForgeErrorCode, L as Logger, P as Payments, k as PaymentsResponse, R as Realtime, S as Storage, g as StorageBucket, h as StorageResponse, T as TokenManager } from './client-Co8KxT-n.js';
3
3
  export { AuthErrorResponse, CreateSessionRequest, CreateUserRequest, RealtimeErrorPayload, SendRawEmailRequest as SendEmailOptions, SendEmailResponse, SocketMessage, SubscribeResponse, UserSchema } from '@insforge/shared-schemas';
4
4
  import '@supabase/postgrest-js';
5
5
 
package/dist/index.js CHANGED
@@ -1061,21 +1061,43 @@ var Auth = class {
1061
1061
  };
1062
1062
  }
1063
1063
  }
1064
- // ============================================================================
1065
- // OAuth Authentication
1066
- // ============================================================================
1067
- /**
1068
- * Sign in with OAuth provider using PKCE flow
1069
- */
1070
- async signInWithOAuth(options) {
1064
+ async signInWithOAuth(providerOrOptions, options) {
1071
1065
  try {
1072
- const { provider, redirectTo, skipBrowserRedirect } = options;
1066
+ let signInOptions;
1067
+ if (typeof providerOrOptions === "object") {
1068
+ signInOptions = providerOrOptions;
1069
+ } else if (options) {
1070
+ signInOptions = { provider: providerOrOptions, ...options };
1071
+ } else {
1072
+ return {
1073
+ data: {},
1074
+ error: new InsForgeError(
1075
+ "OAuth sign-in options are required",
1076
+ 400,
1077
+ import_shared_schemas.ERROR_CODES.INVALID_INPUT
1078
+ )
1079
+ };
1080
+ }
1081
+ if (!signInOptions || !signInOptions.redirectTo) {
1082
+ return {
1083
+ data: {},
1084
+ error: new InsForgeError(
1085
+ "Redirect URI is required",
1086
+ 400,
1087
+ import_shared_schemas.ERROR_CODES.INVALID_INPUT
1088
+ )
1089
+ };
1090
+ }
1091
+ const { provider } = signInOptions;
1073
1092
  const providerKey = encodeURIComponent(provider.toLowerCase());
1074
1093
  const codeVerifier = generateCodeVerifier();
1075
1094
  const codeChallenge = await generateCodeChallenge(codeVerifier);
1076
1095
  storePkceVerifier(codeVerifier);
1077
- const params = { code_challenge: codeChallenge };
1078
- if (redirectTo) params.redirect_uri = redirectTo;
1096
+ const params = {
1097
+ ...signInOptions.additionalParams ?? {},
1098
+ redirect_uri: signInOptions.redirectTo,
1099
+ code_challenge: codeChallenge
1100
+ };
1079
1101
  const isBuiltInProvider = import_shared_schemas.oAuthProvidersSchema.options.includes(
1080
1102
  providerKey
1081
1103
  );
@@ -1084,7 +1106,7 @@ var Auth = class {
1084
1106
  params,
1085
1107
  skipAuthRefresh: true
1086
1108
  });
1087
- if (!this.isServerMode() && typeof window !== "undefined" && !skipBrowserRedirect) {
1109
+ if (!this.isServerMode() && typeof window !== "undefined" && !signInOptions.skipBrowserRedirect) {
1088
1110
  window.location.href = response.authUrl;
1089
1111
  return { data: {}, error: null };
1090
1112
  }
@@ -2074,7 +2096,7 @@ var Images = class {
2074
2096
  * model: 'dall-e-3',
2075
2097
  * prompt: 'A sunset over mountains',
2076
2098
  * });
2077
- * console.log(response.images[0].url);
2099
+ * console.log(response.data[0].b64_json);
2078
2100
  *
2079
2101
  * // Image-to-image (with input images)
2080
2102
  * const response = await client.ai.images.generate({
@@ -2515,7 +2537,10 @@ var Emails = class {
2515
2537
  };
2516
2538
 
2517
2539
  // src/modules/payments.ts
2518
- var Payments = class {
2540
+ function providerEnvironmentPath(provider, environment) {
2541
+ return `/api/payments/${provider}/${encodeURIComponent(environment)}`;
2542
+ }
2543
+ var StripePayments = class {
2519
2544
  constructor(http) {
2520
2545
  this.http = http;
2521
2546
  }
@@ -2524,9 +2549,9 @@ var Payments = class {
2524
2549
  *
2525
2550
  * @example
2526
2551
  * ```typescript
2527
- * const { data, error } = await client.payments.createCheckoutSession('test', {
2552
+ * const { data, error } = await client.payments.stripe.createCheckoutSession('test', {
2528
2553
  * mode: 'payment',
2529
- * lineItems: [{ stripePriceId: 'price_123', quantity: 1 }],
2554
+ * lineItems: [{ priceId: 'price_123', quantity: 1 }],
2530
2555
  * successUrl: `${window.location.origin}/success`,
2531
2556
  * cancelUrl: `${window.location.origin}/pricing`
2532
2557
  * });
@@ -2539,7 +2564,7 @@ var Payments = class {
2539
2564
  async createCheckoutSession(environment, request) {
2540
2565
  try {
2541
2566
  const data = await this.http.post(
2542
- `/api/payments/${encodeURIComponent(environment)}/checkout-sessions`,
2567
+ `${providerEnvironmentPath("stripe", environment)}/checkout-sessions`,
2543
2568
  request,
2544
2569
  { idempotent: !!request.idempotencyKey }
2545
2570
  );
@@ -2547,7 +2572,7 @@ var Payments = class {
2547
2572
  } catch (error) {
2548
2573
  return wrapError(
2549
2574
  error,
2550
- "Checkout session creation failed"
2575
+ "Stripe checkout session creation failed"
2551
2576
  );
2552
2577
  }
2553
2578
  }
@@ -2557,17 +2582,132 @@ var Payments = class {
2557
2582
  async createCustomerPortalSession(environment, request) {
2558
2583
  try {
2559
2584
  const data = await this.http.post(
2560
- `/api/payments/${encodeURIComponent(environment)}/customer-portal-sessions`,
2585
+ `${providerEnvironmentPath("stripe", environment)}/customer-portal-sessions`,
2586
+ request
2587
+ );
2588
+ return { data, error: null };
2589
+ } catch (error) {
2590
+ return wrapError(
2591
+ error,
2592
+ "Stripe customer portal session creation failed"
2593
+ );
2594
+ }
2595
+ }
2596
+ };
2597
+ var RazorpayPayments = class {
2598
+ constructor(http) {
2599
+ this.http = http;
2600
+ }
2601
+ async createOrder(environment, request) {
2602
+ try {
2603
+ const data = await this.http.post(
2604
+ `${providerEnvironmentPath("razorpay", environment)}/orders`,
2605
+ request
2606
+ );
2607
+ return { data, error: null };
2608
+ } catch (error) {
2609
+ return wrapError(
2610
+ error,
2611
+ "Razorpay order creation failed"
2612
+ );
2613
+ }
2614
+ }
2615
+ async verifyOrder(environment, request) {
2616
+ try {
2617
+ const data = await this.http.post(
2618
+ `${providerEnvironmentPath("razorpay", environment)}/orders/verify`,
2561
2619
  request
2562
2620
  );
2563
2621
  return { data, error: null };
2564
2622
  } catch (error) {
2565
2623
  return wrapError(
2566
2624
  error,
2567
- "Customer portal session creation failed"
2625
+ "Razorpay order verification failed"
2568
2626
  );
2569
2627
  }
2570
2628
  }
2629
+ async createSubscription(environment, request) {
2630
+ try {
2631
+ const data = await this.http.post(
2632
+ `${providerEnvironmentPath("razorpay", environment)}/subscriptions`,
2633
+ request
2634
+ );
2635
+ return { data, error: null };
2636
+ } catch (error) {
2637
+ return wrapError(
2638
+ error,
2639
+ "Razorpay subscription creation failed"
2640
+ );
2641
+ }
2642
+ }
2643
+ async verifySubscription(environment, request) {
2644
+ try {
2645
+ const data = await this.http.post(
2646
+ `${providerEnvironmentPath("razorpay", environment)}/subscriptions/verify`,
2647
+ request
2648
+ );
2649
+ return { data, error: null };
2650
+ } catch (error) {
2651
+ return wrapError(
2652
+ error,
2653
+ "Razorpay subscription verification failed"
2654
+ );
2655
+ }
2656
+ }
2657
+ async cancelSubscription(environment, subscriptionId, request = {}) {
2658
+ try {
2659
+ const data = await this.http.post(
2660
+ `${providerEnvironmentPath("razorpay", environment)}/subscriptions/${encodeURIComponent(
2661
+ subscriptionId
2662
+ )}/cancel`,
2663
+ request
2664
+ );
2665
+ return { data, error: null };
2666
+ } catch (error) {
2667
+ return wrapError(
2668
+ error,
2669
+ "Razorpay subscription cancellation failed"
2670
+ );
2671
+ }
2672
+ }
2673
+ async pauseSubscription(environment, subscriptionId) {
2674
+ try {
2675
+ const data = await this.http.post(
2676
+ `${providerEnvironmentPath("razorpay", environment)}/subscriptions/${encodeURIComponent(
2677
+ subscriptionId
2678
+ )}/pause`,
2679
+ {}
2680
+ );
2681
+ return { data, error: null };
2682
+ } catch (error) {
2683
+ return wrapError(
2684
+ error,
2685
+ "Razorpay subscription pause failed"
2686
+ );
2687
+ }
2688
+ }
2689
+ async resumeSubscription(environment, subscriptionId) {
2690
+ try {
2691
+ const data = await this.http.post(
2692
+ `${providerEnvironmentPath("razorpay", environment)}/subscriptions/${encodeURIComponent(
2693
+ subscriptionId
2694
+ )}/resume`,
2695
+ {}
2696
+ );
2697
+ return { data, error: null };
2698
+ } catch (error) {
2699
+ return wrapError(
2700
+ error,
2701
+ "Razorpay subscription resume failed"
2702
+ );
2703
+ }
2704
+ }
2705
+ };
2706
+ var Payments = class {
2707
+ constructor(http) {
2708
+ this.stripe = new StripePayments(http);
2709
+ this.razorpay = new RazorpayPayments(http);
2710
+ }
2571
2711
  };
2572
2712
 
2573
2713
  // src/client.ts