@deiondz/better-auth-razorpay 2.0.14 → 2.0.15

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,10 +1,10 @@
1
- import { S as SubscriptionRecord } from '../types-3dNrA0qB.js';
1
+ import { S as SubscriptionRecord } from '../types-CpjgfbVJ.js';
2
2
  import * as _tanstack_react_query from '@tanstack/react-query';
3
3
  import { UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';
4
4
  import * as react from 'react';
5
5
  import { ReactNode } from 'react';
6
- import { c as RazorpayAuthClient, d as CancelSubscriptionResponse, a as CancelSubscriptionInput, e as CreateOrUpdateSubscriptionResponse, C as CreateOrUpdateSubscriptionInput, P as PlanSummary, f as RestoreSubscriptionResponse, b as RestoreSubscriptionInput, g as ListSubscriptionsResponse, h as VerifyPaymentResponse, V as VerifyPaymentInput, L as ListSubscriptionsInput } from '../types-CKR2ILS1.js';
7
- export { G as GetPlansResponse, i as RazorpayApiError, R as RazorpayApiResult, j as RazorpayClientActions } from '../types-CKR2ILS1.js';
6
+ import { c as RazorpayAuthClient, d as CancelSubscriptionResponse, a as CancelSubscriptionInput, e as CreateOrUpdateSubscriptionResponse, C as CreateOrUpdateSubscriptionInput, P as PlanSummary, f as RestoreSubscriptionResponse, b as RestoreSubscriptionInput, g as ListSubscriptionsResponse, h as VerifyPaymentResponse, V as VerifyPaymentInput, L as ListSubscriptionsInput } from '../types-I97EgC8r.js';
7
+ export { G as GetPlansResponse, i as RazorpayApiError, R as RazorpayApiResult, j as RazorpayClientActions } from '../types-I97EgC8r.js';
8
8
  import 'razorpay';
9
9
 
10
10
  /**
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { S as SubscriptionRecord } from './types-3dNrA0qB.js';
1
+ import { S as SubscriptionRecord } from './types-CpjgfbVJ.js';
2
2
  import { razorpayPlugin } from './index.js';
3
- import { R as RazorpayApiResult, P as PlanSummary, L as ListSubscriptionsInput, C as CreateOrUpdateSubscriptionInput, a as CancelSubscriptionInput, b as RestoreSubscriptionInput, V as VerifyPaymentInput } from './types-CKR2ILS1.js';
3
+ import { R as RazorpayApiResult, P as PlanSummary, L as ListSubscriptionsInput, C as CreateOrUpdateSubscriptionInput, a as CancelSubscriptionInput, b as RestoreSubscriptionInput, V as VerifyPaymentInput } from './types-I97EgC8r.js';
4
4
  import 'razorpay';
5
5
  import 'better-auth';
6
6
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { BetterAuthPlugin } from 'better-auth';
2
- import { R as RazorpayPluginOptions } from './types-3dNrA0qB.js';
3
- export { O as OnWebhookEventCallback, a as RazorpayApiResponse, b as RazorpayErrorResponse, c as RazorpayPlan, d as RazorpaySubscription, e as RazorpaySuccessResponse, f as RazorpayUserRecord, g as RazorpayWebhookContext, h as RazorpayWebhookEvent, i as RazorpayWebhookPayload, S as SubscriptionRecord, j as SubscriptionStatus } from './types-3dNrA0qB.js';
2
+ import { R as RazorpayPluginOptions } from './types-CpjgfbVJ.js';
3
+ export { O as OnWebhookEventCallback, a as RazorpayApiResponse, b as RazorpayErrorResponse, c as RazorpayPlan, d as RazorpaySubscription, e as RazorpaySuccessResponse, f as RazorpayUserRecord, g as RazorpayWebhookContext, h as RazorpayWebhookEvent, i as RazorpayWebhookPayload, S as SubscriptionRecord, j as SubscriptionStatus } from './types-CpjgfbVJ.js';
4
4
  import 'razorpay';
5
5
 
6
6
  interface WebhookResult {
package/dist/index.js CHANGED
@@ -4312,6 +4312,7 @@ var createOrUpdateSubscription = (razorpay, options) => createAuthEndpoint2(
4312
4312
  subscription: {
4313
4313
  id: existing.id,
4314
4314
  plan: existing.plan,
4315
+ planId: existing.planId ?? null,
4315
4316
  status: existing.status,
4316
4317
  razorpaySubscriptionId: existing.razorpaySubscriptionId ?? null,
4317
4318
  cancelAtPeriodEnd: existing.cancelAtPeriodEnd ?? false,
@@ -4363,6 +4364,7 @@ var createOrUpdateSubscription = (razorpay, options) => createAuthEndpoint2(
4363
4364
  const tempSub = {
4364
4365
  id: appTrialSub?.id ?? "",
4365
4366
  plan: plan.name,
4367
+ planId,
4366
4368
  referenceId: userId,
4367
4369
  status: "created",
4368
4370
  cancelAtPeriodEnd: false,
@@ -4396,6 +4398,7 @@ var createOrUpdateSubscription = (razorpay, options) => createAuthEndpoint2(
4396
4398
  update: {
4397
4399
  data: {
4398
4400
  plan: plan.name,
4401
+ planId,
4399
4402
  razorpaySubscriptionId: rpSubscription.id,
4400
4403
  status: newStatus,
4401
4404
  trialEnd: now,
@@ -4410,6 +4413,7 @@ var createOrUpdateSubscription = (razorpay, options) => createAuthEndpoint2(
4410
4413
  const updatedRecord = {
4411
4414
  ...appTrialSub,
4412
4415
  plan: plan.name,
4416
+ planId,
4413
4417
  razorpaySubscriptionId: rpSubscription.id,
4414
4418
  status: newStatus,
4415
4419
  trialEnd: now,
@@ -4436,6 +4440,7 @@ var createOrUpdateSubscription = (razorpay, options) => createAuthEndpoint2(
4436
4440
  const subscriptionRecord = {
4437
4441
  id: localId,
4438
4442
  plan: plan.name,
4443
+ planId,
4439
4444
  referenceId: userId,
4440
4445
  razorpayCustomerId: user.razorpayCustomerId ?? null,
4441
4446
  razorpaySubscriptionId: rpSubscription.id,
@@ -4735,18 +4740,19 @@ function toLocalStatus2(razorpayStatus) {
4735
4740
  };
4736
4741
  return map[razorpayStatus] ?? "pending";
4737
4742
  }
4738
- var updateSubscriptionRecord = async (adapter, razorpaySubscriptionId, data) => {
4743
+ var updateSubscriptionRecord = async (adapter, subscriptionRecordId, data) => {
4739
4744
  await adapter.update({
4740
4745
  model: "subscription",
4741
- where: [{ field: "razorpaySubscriptionId", value: razorpaySubscriptionId }],
4746
+ where: [{ field: "id", value: subscriptionRecordId }],
4742
4747
  update: { data: { ...data, updatedAt: /* @__PURE__ */ new Date() } }
4743
4748
  });
4744
4749
  };
4745
- var createStatusHandler = (status, extraFields) => async (adapter, razorpaySubscriptionId, record, subscription) => {
4750
+ var createStatusHandler = (status, extraFields) => async (adapter, _razorpaySubscriptionId, record, subscription) => {
4746
4751
  const periodStart = subscription.current_start ? new Date(subscription.current_start * 1e3) : null;
4747
4752
  const periodEnd = subscription.current_end ? new Date(subscription.current_end * 1e3) : null;
4748
- await updateSubscriptionRecord(adapter, razorpaySubscriptionId, {
4753
+ await updateSubscriptionRecord(adapter, record.id, {
4749
4754
  status,
4755
+ planId: subscription.plan_id,
4750
4756
  ...periodStart !== null && { periodStart },
4751
4757
  ...periodEnd !== null && { periodEnd },
4752
4758
  ...extraFields?.(subscription) ?? {}