@deiondz/better-auth-razorpay 2.0.8 → 2.0.9
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.
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4077,14 +4077,20 @@ function handleRazorpayError(error) {
|
|
|
4077
4077
|
}
|
|
4078
4078
|
};
|
|
4079
4079
|
}
|
|
4080
|
-
|
|
4081
|
-
|
|
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") {
|