@pradip1995/segment-login-template 0.5.3 → 0.5.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pradip1995/segment-login-template",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -136,11 +136,22 @@ function parseBackendError(body: unknown, status: number): string {
136
136
  if (/^invalid request( data)?\.?$/i.test(primary)) {
137
137
  return "Invalid payment details. Check required fields and try again."
138
138
  }
139
- if (/payment details? with customer(_|\s)?id already exists/i.test(primary)) {
140
- return "Could not remove this payment method because of a conflict with your default method. Please set another method as default, then try again."
139
+ if (/^failed to set default payment detail\.?$/i.test(primary)) {
140
+ const detail =
141
+ typeof data.error === "string" && data.error.trim() ? data.error.trim() : ""
142
+ if (detail) {
143
+ if (/already exists|unique|duplicate/i.test(detail)) {
144
+ return "Could not update your default payment method. Please try again."
145
+ }
146
+ return detail
147
+ }
148
+ return "Could not update your default payment method. Please try again."
149
+ }
150
+ if (/payment details? with customer(_|\s)?id:?\s*.*already exists/i.test(primary)) {
151
+ return "Could not update your default payment method. Please try again."
141
152
  }
142
153
  if (/already exists/i.test(primary) && /customer/i.test(primary)) {
143
- return "Could not update your default payment method. Please try again, or set another method as default first."
154
+ return "Could not update your default payment method. Please try again."
144
155
  }
145
156
  if (/^failed to delete payment detail\.?$/i.test(primary)) {
146
157
  const detail =