@deiondz/better-auth-razorpay 2.0.12 → 2.0.14

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.
@@ -61,6 +61,16 @@ interface PlanFreeTrial {
61
61
  subscription: SubscriptionRecord;
62
62
  }) => Promise<void>;
63
63
  }
64
+ /** Price details for a plan variant (from Razorpay Plan API). Amount is in smallest currency unit (e.g. paise, cents). */
65
+ interface PlanPriceDetail {
66
+ /** Amount in smallest currency unit (e.g. 89900 = ₹899.00, 1000 = $10.00). */
67
+ amount: number;
68
+ currency: string;
69
+ /** Billing period: daily | weekly | monthly | quarterly | yearly. */
70
+ period: string;
71
+ /** Billing interval (e.g. 1 for every 1 month, 2 for every 2 months). */
72
+ interval?: number;
73
+ }
64
74
  /** Named plan with monthly/annual Razorpay plan IDs and optional trial. */
65
75
  interface RazorpayPlan {
66
76
  name: string;
@@ -168,6 +178,16 @@ interface RazorpayPluginOptions {
168
178
  razorpayWebhookSecret?: string;
169
179
  /** Create Razorpay customer when user signs up. Default: false. */
170
180
  createCustomerOnSignUp?: boolean;
181
+ /**
182
+ * Optional. When set with createCustomerOnSignUp, creates an app-level trial subscription at sign-up (no Razorpay subscription until user subscribes).
183
+ * Omit for no sign-up trial. Only applies when both createCustomerOnSignUp and trialOnSignUp are set.
184
+ * @property days - Trial length in days (e.g. 7, 14, 30). Required when trialOnSignUp is set.
185
+ * @property planName - Display name for the trial in the subscription list (e.g. "Trial", "Free trial"). Default: "Trial".
186
+ */
187
+ trialOnSignUp?: {
188
+ days: number;
189
+ planName?: string;
190
+ };
171
191
  /** Called after a Razorpay customer is created. */
172
192
  onCustomerCreate?: (args: {
173
193
  user: RazorpayUserRecord;
@@ -207,4 +227,4 @@ interface RazorpayErrorResponse {
207
227
  }
208
228
  type RazorpayApiResponse<T = unknown> = RazorpaySuccessResponse<T> | RazorpayErrorResponse;
209
229
 
210
- export type { OnWebhookEventCallback as O, RazorpayPluginOptions as R, SubscriptionRecord as S, RazorpayApiResponse as a, RazorpayErrorResponse as b, RazorpayPlan as c, RazorpaySubscription as d, RazorpaySuccessResponse as e, RazorpayUserRecord as f, RazorpayWebhookContext as g, RazorpayWebhookEvent as h, RazorpayWebhookPayload as i, SubscriptionStatus as j };
230
+ export type { OnWebhookEventCallback as O, PlanPriceDetail as P, RazorpayPluginOptions as R, SubscriptionRecord as S, RazorpayApiResponse as a, RazorpayErrorResponse as b, RazorpayPlan as c, RazorpaySubscription as d, RazorpaySuccessResponse as e, RazorpayUserRecord as f, RazorpayWebhookContext as g, RazorpayWebhookEvent as h, RazorpayWebhookPayload as i, SubscriptionStatus as j };
@@ -1,4 +1,4 @@
1
- import { S as SubscriptionRecord } from './types-VZW_XCzQ.js';
1
+ import { P as PlanPriceDetail, S as SubscriptionRecord } from './types-3dNrA0qB.js';
2
2
 
3
3
  /**
4
4
  * Client-side types for Razorpay plugin hooks and API responses.
@@ -14,6 +14,10 @@ interface PlanSummary {
14
14
  freeTrial?: {
15
15
  days: number;
16
16
  };
17
+ /** Price for monthly plan (from Razorpay). Omitted if fetch failed or unavailable. */
18
+ monthly?: PlanPriceDetail;
19
+ /** Price for annual plan (from Razorpay). Omitted if not configured or fetch failed. */
20
+ annual?: PlanPriceDetail;
17
21
  }
18
22
  /** Response shape for get-plans (success). */
19
23
  interface GetPlansResponse {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deiondz/better-auth-razorpay",
3
- "version": "2.0.12",
3
+ "version": "2.0.14",
4
4
  "description": "Better Auth plugin for Razorpay subscriptions and payments",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",