@deiondz/better-auth-razorpay 2.0.8 → 2.0.10

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.
@@ -3,8 +3,8 @@ 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-C0_Sreb6.js';
7
- export { G as GetPlansResponse, i as RazorpayApiError, R as RazorpayApiResult, j as RazorpayClientActions } from '../types-C0_Sreb6.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-bkMGY9Jy.js';
7
+ export { G as GetPlansResponse, i as RazorpayApiError, R as RazorpayApiResult, j as RazorpayClientActions } from '../types-bkMGY9Jy.js';
8
8
  import 'razorpay';
9
9
 
10
10
  /** Context holding the Razorpay-capable auth client. Default is null. */
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { S as SubscriptionRecord } from './types-B25gyPpX.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-C0_Sreb6.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-bkMGY9Jy.js';
4
4
  import 'razorpay';
5
5
  import 'better-auth';
6
6
 
package/dist/index.js CHANGED
@@ -4077,14 +4077,20 @@ function handleRazorpayError(error) {
4077
4077
  }
4078
4078
  };
4079
4079
  }
4080
- if ("error" in errorObj) {
4081
- const razorpayError = errorObj;
4080
+ const axiosData = errorObj.response?.data;
4081
+ const directError = "error" in errorObj ? errorObj.error : null;
4082
+ const razorpayPayload = axiosData?.error ?? directError;
4083
+ if (razorpayPayload && typeof razorpayPayload === "object") {
4084
+ const rp = razorpayPayload;
4085
+ const code = rp?.code && String(rp.code).trim() ? rp.code : "RAZORPAY_ERROR";
4086
+ const desc = rp?.description && String(rp.description).trim();
4087
+ const field = rp?.field != null && String(rp.field).trim() ? rp.field : null;
4088
+ const reason = rp?.reason && String(rp.reason).trim() ? rp.reason : null;
4089
+ const step = rp?.step && String(rp.step).trim() ? rp.step : null;
4090
+ const description = desc || (field ? `Razorpay error: ${field}` : null) || (reason ? `Razorpay: ${reason}` : null) || (step ? `Razorpay error at step: ${step}` : null) || "Razorpay request failed";
4082
4091
  return {
4083
4092
  success: false,
4084
- error: {
4085
- code: razorpayError.error?.code || "RAZORPAY_ERROR",
4086
- description: razorpayError.error?.description || razorpayError.error?.field ? `Razorpay error: ${razorpayError.error.field}` : "Razorpay request failed"
4087
- }
4093
+ error: { code, description }
4088
4094
  };
4089
4095
  }
4090
4096
  if ("message" in errorObj && typeof errorObj.message === "string") {
@@ -4408,6 +4414,7 @@ var getPlans = (options) => createAuthEndpoint3("/razorpay/get-plans", { method:
4408
4414
  name: p.name,
4409
4415
  monthlyPlanId: p.monthlyPlanId,
4410
4416
  annualPlanId: p.annualPlanId,
4417
+ description: p.description,
4411
4418
  limits: p.limits,
4412
4419
  freeTrial: p.freeTrial ? { days: p.freeTrial.days } : void 0
4413
4420
  }))