969 lines
57 KiB
TypeScript
969 lines
57 KiB
TypeScript
import { HttpErrorResponse } from "@angular/common/http"
|
|
import { Card, Status } from "@app/domain/models/subscription.model"
|
|
import { errorHandler } from "@app/shared/global"
|
|
import { of } from "rxjs"
|
|
import { ApplyDiscountPreviewFailed, CreatePaymentMethodFailed, CreateSubscriptionIntentFailed, LoadStripeFailed, UpdateSubscriptionIntentStatus, UpdateSubscriptionStatus, UpdateUnpaid } from "@app/actions/subscription.actions"
|
|
import { FetchError } from "./actions/payment.action"
|
|
import { FetchUsageFailed } from "./actions/usage.actions"
|
|
import { FetchSubPlansFailed } from "@app/actions/sub-plans.actions"
|
|
|
|
export const DELAY = 1000;
|
|
export const TAKE = 3;
|
|
export enum InvType { CHARGE = 'charge', INVOICE = 'invoice' };
|
|
export enum SubType { PACKAGE = 'package', ADDON = 'addon' };
|
|
export enum SubKeys { ESS_1 = 'ess_1', ESS_1_1 = 'ess_1_1', ESS_2 = 'ess_2', ESS_3 = 'ess_3', ESS_4 = 'ess_4', ESS_5 = 'ess_5', ENT_1 = 'ent_1', ENT_2 = 'ent_2', ENT_3 = 'ent_3', ENT_4 = 'ent_4', ENT_5 = 'ent_5', TRACKING = 'addon_1' };
|
|
export enum Mode { REGULAR, TRIALING, CONTINUE_TRIAL, UPDATE_BIL_ADR, UNPAID };
|
|
export const ACTIVE = 'active';
|
|
export const PACKAGE_ACTIVE = 'pkgActive';
|
|
export const TRACKING = 'tracking';
|
|
export const STRIPE_ELT_STYLE = {
|
|
base: {
|
|
fontSize: '14px',
|
|
color: '#212121',
|
|
fontFamily: 'Roboto, "Helvetica Neue", sans-serif',
|
|
fontSmoothing: 'antialiased',
|
|
'::placeholder': { color: '#212121' },
|
|
padding: '0.5rem'
|
|
},
|
|
invalid: {
|
|
fontSize: '14px',
|
|
fontFamily: 'Roboto, "Helvetica Neue", sans-serif',
|
|
fontSmoothing: 'antialiased',
|
|
color: 'red',
|
|
'::placeholder': { color: '#212121' },
|
|
padding: '0.5rem'
|
|
}
|
|
}
|
|
|
|
export const STRIPE_BIL_ADDR_STYLE = {
|
|
variables: { borderRadius: '1px', fontFamily: 'Roboto, "Helvetica Neue", sans-serif', colorText: '#000000', colorPrimary: '#4CAF50' }
|
|
}
|
|
|
|
// Promo Translation Keys
|
|
export const PromoLabels = {
|
|
// Package Promos
|
|
PROMO_ESS_FREE: $localize`:Promo name@@PROMO_ESS_FREE:Essential Free Trial`,
|
|
PROMO_ESS_FREE_DESC: $localize`:Promo desc@@PROMO_ESS_FREE_DESC:Get Essential tier free until specified date`,
|
|
PROMO_ENT_FREE: $localize`:Promo name@@PROMO_ENT_FREE:Enterprise Free Trial`,
|
|
PROMO_ENT_FREE_DESC: $localize`:Promo desc@@PROMO_ENT_FREE_DESC:Get Enterprise tier free until specified date`,
|
|
|
|
// Addon Promos
|
|
PROMO_ADDON_FREE: $localize`:Promo name@@PROMO_ADDON_FREE:Addon Free Until April`,
|
|
PROMO_ADDON_FREE_DESC: $localize`:Promo desc@@PROMO_ADDON_FREE_DESC:Get addon features free until April 2026`,
|
|
|
|
// Generic fallbacks
|
|
PROMO_GENERIC_FREE: $localize`:Promo name@@PROMO_GENERIC_FREE:Free Promotion`,
|
|
PROMO_GENERIC_FREE_DESC: $localize`:Promo desc@@PROMO_GENERIC_FREE_DESC:Limited time free access`,
|
|
};
|
|
|
|
/**
|
|
* Promo Error Messages (Admin-facing)
|
|
* Used in: subscription-mgt.component.ts (admin promo management UI)
|
|
* Backend error types defined in: server/helpers/constants.js lines 142-150
|
|
* Backend thrown in: server/controllers/main.js lines 535, 547, 690, 695
|
|
*/
|
|
export const PromoErrors = {
|
|
/**
|
|
* Error: Promo not found during lookup
|
|
* Backend error type: PROMO_NOT_FOUND
|
|
* Thrown in: server/controllers/main.js lines 690, 695
|
|
*/
|
|
PROMO_NOT_FOUND: $localize`:Admin error - promo not found@@promoNotFound:Promotion not found. Please verify the promotion ID and try again.`,
|
|
|
|
/**
|
|
* Error: Active promo already exists for this package/addon combination
|
|
* Backend error type: PROMO_DUPLICATE_TYPE_PRICEKEY
|
|
* Thrown in: server/controllers/main.js line 535
|
|
*/
|
|
PROMO_DUPLICATE_TYPE_PRICEKEY: $localize`:Admin error - duplicate promo type/price@@promoDupTypePriceKey:A promotion already exists for this package/addon combination. Please update the existing promotion or disable it before creating a new one.`,
|
|
|
|
/**
|
|
* Error: This coupon is already used by another active promo
|
|
* Backend error type: PROMO_DUPLICATE_COUPON
|
|
* Thrown in: server/controllers/main.js line 547
|
|
*/
|
|
PROMO_DUPLICATE_COUPON: $localize`:Admin error - duplicate coupon@@promoDupCoupon:This Stripe coupon is already used by another active promotion. Each coupon can only be used in one promotion at a time.`,
|
|
|
|
/**
|
|
* Error: Date ranges overlap with existing promo
|
|
* Backend error type: PROMO_OVERLAPPING_DATES
|
|
* Note: Not yet implemented in backend r955 (reserved for future use)
|
|
*/
|
|
PROMO_OVERLAPPING_DATES: $localize`:Admin error - overlapping dates@@promoOverlapDates:Promotion dates overlap with an existing promotion. Please adjust the valid date range.`,
|
|
|
|
/**
|
|
* Error: Stripe coupon lookup failed
|
|
* Backend error type: PROMO_COUPON_NOT_FOUND
|
|
* Note: Not yet implemented in backend r955 (reserved for future use)
|
|
*/
|
|
PROMO_COUPON_NOT_FOUND: $localize`:Admin error - Stripe coupon not found@@promoCouponNotFound:Stripe coupon not found. Please verify the coupon ID exists in Stripe dashboard.`,
|
|
|
|
/**
|
|
* Generic promo error (fallback for unknown error types)
|
|
*/
|
|
PROMO_GENERIC_ERROR: $localize`:Admin error - generic promo error@@promoGenericError:Failed to manage promotion. Please check the error details and try again.`,
|
|
|
|
/**
|
|
* Error: Invalid coupon or promotion code (user-facing)
|
|
* Backend error type: PROMO_INVALID_COUPON (NEW in r959)
|
|
* Thrown in: server/controllers/subscription.js (resolveCouponCode, getCoupon_get)
|
|
* Use case: User enters invalid/restricted coupon at checkout
|
|
*/
|
|
PROMO_INVALID_COUPON: $localize`:User error - invalid coupon@@promoInvalidCoupon:Invalid promotion code. Please check and try again.`,
|
|
|
|
/**
|
|
* Error: Coupon restricted to specific customers
|
|
* Backend error type: PROMO_INVALID_COUPON (customer restriction variant)
|
|
*/
|
|
PROMO_RESTRICTED_CUSTOMER: $localize`:User error - customer restriction@@promoRestrictedCustomer:This promotion is not available for your account.`,
|
|
|
|
/**
|
|
* Error: Coupon doesn't apply to selected products
|
|
* Backend error type: PROMO_INVALID_COUPON (product restriction variant)
|
|
*/
|
|
PROMO_RESTRICTED_PRODUCT: $localize`:User error - product restriction@@promoRestrictedProduct:This promotion does not apply to the selected package.`,
|
|
|
|
/**
|
|
* Error: Coupon restricted to first-time customers only
|
|
* Backend error type: PROMO_INVALID_COUPON (first-time transaction restriction)
|
|
*/
|
|
PROMO_FIRST_TIME_ONLY: $localize`:User error - first time only@@promoFirstTimeOnly:This promotion is only available for first-time customers.`,
|
|
|
|
/**
|
|
* Error: Coupon has expired
|
|
* Backend error type: PROMO_INVALID_COUPON (expired variant)
|
|
* Thrown in: server/controllers/subscription.js (resolveCouponCode)
|
|
*/
|
|
PROMO_EXPIRED: $localize`:User error - coupon expired@@promoExpired:This promotion has expired.`,
|
|
|
|
/**
|
|
* Error: Coupon reached maximum redemption limit
|
|
* Backend error type: PROMO_INVALID_COUPON (max redemptions variant)
|
|
* Thrown in: server/controllers/subscription.js (resolveCouponCode)
|
|
*/
|
|
PROMO_MAX_REDEMPTIONS: $localize`:User error - max redemptions@@promoMaxRedemptions:This promotion has reached its maximum usage limit.`
|
|
};
|
|
|
|
// Application errors
|
|
export const SubAppErr = Object.freeze({
|
|
BIL_ADDR_ERR: 'subMsgBillAddrErr',
|
|
CANCEL_ERR: 'subMsgCancelErr',
|
|
CONF_ERR: 'subMsgConfErr',
|
|
CRT_PM_ERR: 'subMsgCrtPmErr',
|
|
COMP_ACT_ERR: 'subMsgCompActErr',
|
|
START_BIL_INFO_ERR: 'subMsgStartBilInfoErr',
|
|
CHKOUT_ERR: 'subMsgChkoutErr',
|
|
CHKOUT_REV_ERR: 'subMsgChkoutRevErr',
|
|
CHKOUT_CONF_ERR: 'subMsgChkoutConfErr',
|
|
MGE_SERV_ERR: 'subMsgManageServErr',
|
|
MGE_SUB_ERR: 'subMsgManageSubErr',
|
|
PAY_UNPAID_ERR: 'subMsgPayUnpaidErr',
|
|
PAY_UNPAID_CARD_ERR: 'subMsgPayUnpaidCardErr',
|
|
POLL_ERR: 'subMsgPollingErr',
|
|
PM_DETAIL_ERR: 'subMsgPmDetailErr',
|
|
PM_LIST_ERR: 'subMsgPmListErr',
|
|
FETCH_PMT_ERR: 'subMsgFetchPmtErr',
|
|
FETCH_SUB_ERR: 'subMsgFetchSubErr',
|
|
FETCH_USAGE_ERR: 'subMsgFetchUsageErr',
|
|
START_CHECKOUT_ERR: 'subMsgStartChkoutErr',
|
|
CHECKOUT_TRIAL_ERR: 'subMsgChkoutTrialErr',
|
|
CHECKOUT_CONT_TRIAL_ERR: 'subMsgChkoutContTrialErr',
|
|
UPDATE_SUB_ERR: 'subMsgUpdateSubErr',
|
|
UPDATE_PM_ERR: 'subMsgUpdatePmErr',
|
|
UNPAID_ERR: 'subMsgUnpaidErr',
|
|
STRIPE_ERR: 'subMsgStripeErr',
|
|
REFUND_ERR: 'subMsgRefundErr',
|
|
REFRESH_ERR: 'subMsgRefreshErr',
|
|
RES_UNPAID_ERR: 'subMsgResumeUnpaidErr',
|
|
RES_ERR: 'subMsgResErr',
|
|
_500_ERR: 'subMsg500Err',
|
|
RES_SUB_ERR: 'subMsgResSubErr',
|
|
RES_SUB_ERR_NO_CARD: 'subMsgResSubErrNoCard',
|
|
NO_SUBS_ERR: 'subMsgNoSubErr',
|
|
NO_INVOICES_ERR: 'subMsgNoInvoiceErr',
|
|
NO_ACTIONS_ERR: 'subMsgNoActionErr',
|
|
INC_ADDR_ERR: 'subMsgIncAddrErr',
|
|
INC_CARD_ERR: 'subMsgIncCardErr',
|
|
USAGE_DETAIL_ERR: 'subMsgUsageDetailErr',
|
|
FETCH_SUB_PLANS_ERR: 'subMsgFetchSubPlansErr',
|
|
LOAD_STRIPE_ERR: 'subMsgLoadStripeErr',
|
|
APP_DISCOUNT_PREVIEW_ERR: 'subMsgAppDisPrevErr',
|
|
FETCH_DEFAULT_PM_ERR: 'subFetchDefaultPmErr',
|
|
FETCH_PM_ERR: 'subFetchPmErr',
|
|
PMT_METHOD_LIST_ERR: 'subPmtMethodListErr',
|
|
EDIT_PM_ERR: 'subEditPMErr',
|
|
ADD_PM_ERR: 'subAddPMErr',
|
|
DELETE_PM_ERR: 'subDeletePMErr',
|
|
CHANGE_PM_ERR: 'subChangePMErr',
|
|
INVALID_DATE: 'subInvalidDateErr',
|
|
AC_LIST_ERR: 'subAcListErr',
|
|
APP_VENDOR_NOT_FOUND: 'app_vendor_not_found',
|
|
LOCAL_VENDOR_NOT_FOUND: 'local_vendor_not_found',
|
|
PROMO_NOT_FOUND_ERR: 'subMsgPromoNotFoundErr',
|
|
PROMO_DUPLICATE_TYPE_PRICEKEY_ERR: 'subMsgPromoDupTypePriceKeyErr',
|
|
PROMO_DUPLICATE_COUPON_ERR: 'subMsgPromoDupCouponErr',
|
|
PROMO_OVERLAPPING_DATES_ERR: 'subMsgPromoOverlapDatesErr',
|
|
PROMO_COUPON_NOT_FOUND_ERR: 'subMsgPromoCouponNotFoundErr'
|
|
});
|
|
|
|
// Stripe specific constants
|
|
export const SubStripe = Object.freeze({
|
|
PI_AUTH_FAILURE: 'payment_intent_authentication_failure',
|
|
PI_IMCOMPAT_PM: 'payment_intent_incompatible_payment_method',
|
|
CARD_DECLINED: 'card_declined',
|
|
INSUFFICIENT_FUNDS: 'insufficient_funds',
|
|
STOLEN_CARD: 'stolen_card',
|
|
LOST_CARD: 'lost_card',
|
|
EXPIRED_CARD: 'expired_card',
|
|
INCORRECT_CVC: 'incorrect_cvc',
|
|
PROC_ERR: 'processing_error',
|
|
EXCEEDED_VELOCITY: 'card_velocity_exceeded',
|
|
REQUIRE_ACTION: 'requires_action',
|
|
REQUIRE_PAYMENT_METHOD: 'requires_payment_method',
|
|
ACTIVE: 'active',
|
|
INCOMPLETE: 'incomplete',
|
|
PAST_DUE: 'past_due',
|
|
OVERDUE: 'overdue',
|
|
UNPAID: 'unpaid',
|
|
OPEN: 'open',
|
|
CANCELED: 'canceled',
|
|
REQ_LOC_INPUT: 'requires_location_inputs',
|
|
TRIALING: 'trialing'
|
|
});
|
|
|
|
// Subscription constants
|
|
export const SUB = Object.freeze({
|
|
BILL_ADR: 'billing-address',
|
|
BILL_ADR_LIST: 'billing-address-list',
|
|
BILL: 'bill',
|
|
BILL_OVEVIEW: 'billing-overview',
|
|
CHKOUT: 'checkout',
|
|
CHKOUT_CONF: 'checkout-confirm',
|
|
CHKOUT_REV: 'checkout-review',
|
|
HOME: 'home',
|
|
MY_SERVICES: 'myservices',
|
|
PM_HISTORY: 'payment-history',
|
|
PM_DETAIL: 'payment-detail',
|
|
PROFILE: 'profile',
|
|
SERVICES: 'services',
|
|
REFUND: 'refund',
|
|
UNPAID_SUB: 'unpaid-sub',
|
|
UPDATE_DEF_PM: 'textUpdateDefPm',
|
|
POLLING: 'textPolling',
|
|
USAGE_DETAIL: 'usage-detail',
|
|
PM_LIST: 'payment-method-list',
|
|
AC_REVIEW: 'acReview',
|
|
TRACKING_REVIEW: 'trackingReview',
|
|
ACTIVE_AC_REVIEW: 'activeAcReview',
|
|
TRACKING_AND_ACTIVE_AC_REVIEW: 'trkAndActiveAcReview',
|
|
CONTACT: 'contact',
|
|
});
|
|
|
|
// Subscription texts (translatable);
|
|
export const SubTexts: any = Object.freeze({
|
|
textCancel: $localize`:@@textCancel:Thank you. We hope to see you subscribe again in the future.`,
|
|
textConfirm: $localize`:@@textConfirm:We've sent a confirmation to #user#. If this is not your correct email address, please update your profile.`,
|
|
textProceed: $localize`:@@textProceed:Click <b>Confirm</b> to procceed to payment.`,
|
|
textBackPm: $localize`:@@textBackPm:Use the <b>Back</b> button to change your payment method.`,
|
|
textBackSub: $localize`:@@textBackSub:Use the <b>Back</b> button to go to my subscriptions.`,
|
|
textEdit: $localize`:@@textEdit:Use the <b>Edit</b> button to make changes.`,
|
|
textThank: $localize`:@@textThank:Thank you. We have received your payment.`,
|
|
textReview: $localize`:@@textReview:Review the details below and click <b>Submit</b> to finalize your payment.`,
|
|
textRefund: $localize`:@@textRefund:Your refund will be processed to the original card used for payment.`,
|
|
textRefProc: $localize`:@@textRefProc:Procceed to payment review.`,
|
|
textResUnpaid: $localize`:@@textResUnpaid:Please address the outstanding payments for your subscriptions.`,
|
|
textPastdue: $localize`:@@textPastdue:Status: You have an overdue payment`,
|
|
textUnpaid: $localize`:@@textUnpaid:Status: Your account is currently locked because of unpaid dues`,
|
|
textInc: $localize`:@@textInc:Status: Your subscription is incomplete`,
|
|
textCanceled: $localize`:@@textCanceled:Status: Your subscription is canceled`,
|
|
textActive: $localize`:@@textActive:Status: Active`,
|
|
textChangeSub: $localize`:@@textChangeSub:Your subscriptions have been modified. Would you like to continue?`,
|
|
textChangeTrial: $localize`:@@textChangeTrial:Your trial subscriptions have been modified. Would you like to continue?`,
|
|
|
|
textCancelConf: $localize`:@@textCancelConf:Do you want to cancel all your current subscriptions?`,
|
|
textPolling: $localize`:@@textPolling:Resolving issue with unpaid subscription. Please wait...`,
|
|
textUpdateDefPm: $localize`:@@textUpdateDefPm:Your default payment method is being updated. Please wait...`,
|
|
textReq3ds: $localize`:@@textReq3ds:To complete your payment, 3DS verification is required. Click [Update Payment Information] to continue with the verification process.`,
|
|
textUpgradeSub: $localize`:@@upgradeSub:Upgrade Subscription.`,
|
|
textUpgradeSubMsg: $localize`:@@upgradeSubMsg:Upgrade your subscription to access more features.`,
|
|
textInvalidTime: $localize`:@@invalidTime:Package upgrades are not available within 24 hours of the last change. Please contact support for assistance.`,
|
|
textTrial: $localize`:@@textThank:Thank you for subscribing to our trial. Welcome aboard!`,
|
|
textContTrial: $localize`:@@textThank:Your subscriptions will automatically renew and be charged at the end of the trial period.`,
|
|
textIncCard: $localize`:@@textIncCard:Please complete the #field# field on your card.`,
|
|
textAddPMSuccess: $localize`:@@textAddPMSuccess:Payment method added successfully.`,
|
|
textEditPMSuccess: $localize`:@@textAddPMSuccess:Your payment method has been successfully updated to #card#.`,
|
|
textDeletePM: $localize`:@@textDeletePM:You are about to delete the payment method #card#. Do you wish to continue?`,
|
|
textPromoApplied: $localize`:@@textPromoApplied:Promotional pricing has been applied to your subscription. See details below.`,
|
|
textDeletePMSuccess: $localize`:@@textDeletePMSuccess:Successfully deleted your default payment method #card#.`,
|
|
textDeletePMFailed: $localize`:@@textDeletePMFailed:Removal of #card# as your default payment method was unsuccessful. Please contact support for help.`,
|
|
textChangePMSuccess: $localize`:@@textChangePMSuccess:Successfully changed your default payment method to #card#`,
|
|
textChangePMFailed: $localize`:@@textChangePMFailed:We couldn't update your default payment method to #card#. Please reach out to support for assistance.`,
|
|
contactSupport: $localize`:@@contactSupport:Please contact support for further assistance.`,
|
|
|
|
textPkgChng: $localize`:@@textPkgChng:Your package is now #pkg#, allowing for up to #maxAC# aircraft. Please review your active aircraft selections.`,
|
|
textTrkChng: $localize`:@@textTrkChng:The quantity of your tracked aircraft has changed to #quantity#. Please review your selections.`,
|
|
textPkgTrkChng: $localize`:@@textPkgTrkChng:Your package has been upgraded to #pkg#, allowing a maximum of #maxAC# aircraft. The tracking quantity has been adjusted to #quantity#. Please review your active and tracked aircraft selections.`,
|
|
|
|
textReviewAC: $localize`:@@textReviewAC:Verify aircraft selections and click Update to apply changes.`,
|
|
textUpdateAC: $localize`:@@textUpdateAC:Confirm the update to your aircraft service selections. Click [Yes] to continue.`,
|
|
|
|
textNewPkg: $localize`:@@textNewPkg:You have selected a new package #pkg# allowing up to #maxAC# aircraft. Please review your active aircraft selections.`,
|
|
textNewTrk: $localize`:@@textNewTrk:You have added a new tracking quantity #quantity#. Please review your selections.`,
|
|
textNewPkgTrk: $localize`:@@textNewPkgTrk:You have selected a new package #pkg# allowing up to #maxAC# aircraft and added a new tracking quantity #quantity#. Please review your active and tracked aircraft selections.`,
|
|
|
|
labelBack: $localize`:@@labelBack:Back`,
|
|
labelConf: $localize`:@@labelConf:Confirm`,
|
|
labelContRev: $localize`:@@labelContRev:Proceed to Review`,
|
|
labelContPmt: $localize`:@@labelContPmt:Proceed to Payment`,
|
|
labelCrtPm: $localize`:@@labelCrtPm:Create new Payment Method`,
|
|
labelStreetAdr: $localize`:@@labelStreetAdr:Your Street Address`,
|
|
labelSrvOverview: $localize`:@@labelSrvOverview:Services Overview`,
|
|
labelSubmit: $localize`:@@labelSubmit:Submit`,
|
|
labelUsePm: $localize`:@@labelUsePm:Use this card as default payment method`,
|
|
labelReset: $localize`:@@labelReset:Reset`,
|
|
labelResolvePmt: $localize`:@@labelResolvePmt:Update Payment Information`,
|
|
labelCreateSub: $localize`:@@labelCreateSub:Create New Subscription Plan`,
|
|
labelCreateTrialSub: $localize`:@@labelCreateTrialSub:Create Trial Subscription Plan`,
|
|
labelChngSub: $localize`:@@labelChngSub:Modify Your Subscription Plan`,
|
|
labelChngTrial: $localize`:@@labelChngTrial:Modify Your Trial Plan`,
|
|
labelUpdateAddr: $localize`:@@labelUpdateAddr:Update Address`,
|
|
labelContTrial: $localize`:@@labelContTrial:Continue Subscription After Trial`,
|
|
labelAutoRenew: $localize`:@@labelAutoRenew:Auto Renew`,
|
|
labelEdit: $localize`:@@labelEdit:Edit`,
|
|
labelChange: $localize`:@@labelEdit:Change`,
|
|
labeAddCC: $localize`:@@labeAddCC:Add a credit card`,
|
|
labelSave: $localize`:@@labelSave:Save`,
|
|
labelCancel: $localize`:@@labelCancel:Cancel`,
|
|
labelResolvePM: $localize`:@@labelResolvePM:Please update your payment method.`,
|
|
labelApply: $localize`:@@labelApply:Apply`,
|
|
labelSub: $localize`:@@labelSub:Subscription`,
|
|
labelChngBilAddr: $localize`:@@labelChngBilAdr:Change Billing Address`,
|
|
|
|
unlimited: $localize`:@@unlimited:Unlimited`,
|
|
contact: $localize`:@@contact:contact`,
|
|
yearly: $localize`:@@yearly:Yearly`,
|
|
monthly: $localize`:@@monthly:Monthly`,
|
|
priceYearly: $localize`:@@priceYearly:(at #price# / year)`,
|
|
priceMonthly: $localize`:@@priceMonthly:(at #price# / month)`,
|
|
ending: $localize`:@@ending:ending with`,
|
|
agmEss: $localize`:@@agmEss:AgMission Essentials`,
|
|
agmEnt: $localize`:@@agmEnt:AgMission Enterprise`,
|
|
code: $localize`:@@code:Code`,
|
|
off: $localize`:@@off:off`,
|
|
dollar: $localize`:@@dollar:Dollar`,
|
|
chargesToday: $localize`:@@chargesToday:Charges Today`,
|
|
added: $localize`:@@added:Added`,
|
|
planRefund: $localize`:@@planRefund:Plan Refund`,
|
|
removed: $localize`:@@removed:Removed`,
|
|
removedAndRefunding: $localize`:@@removedAndRefunding:Removed (and Refunding)`,
|
|
removedRefunding: $localize`:@@removedRefunding:Removed (Refunding)`,
|
|
refunding: $localize`:@@refunding:Refunding`,
|
|
trial: $localize`:@@trial:Trial`,
|
|
paid: $localize`:@@paid:Paid`,
|
|
lastTrial: $localize`:@@lastTrial:Last Trial`,
|
|
startDate: $localize`:@@startDate:Start Date`,
|
|
endDate: $localize`:@@endDate:End Date`,
|
|
lastStartDate: $localize`:@@lastStartDate:Last Start Date`,
|
|
lastEndDate: $localize`:@@lastEndDate:Last End Date`,
|
|
card: $localize`:@@card:Card`,
|
|
|
|
incomplete_number: $localize`:@@incNum:Your card number is incomplete.`,
|
|
invalid_number: $localize`:@@invNum:Your card number is invalid.`,
|
|
incomplete_expiry: $localize`:@@incExp:Your card's expiration date is incomplete.`,
|
|
invalid_expiry_month_past: $localize`:@@invMonthPast:Your card's expiration date is in the past.`,
|
|
invalid_expiry_year_past: $localize`:@@invYearPast:Your card's expiration year is in the past.`,
|
|
incomplete_cvc: $localize`:@@incCvc:Your card's security code is incomplete.`,
|
|
|
|
freeTrialUntil: $localize`:@@freeTrialUntil:Free trial until`,
|
|
freeTrial: $localize`:@@freeTrial:Free trial`,
|
|
freeTrialFor: $localize`:@@freeTrialFor:Free trial for`,
|
|
day: $localize`:@@day:day`,
|
|
days: $localize`:@@days:days`,
|
|
to: $localize`:@@to:to`,
|
|
month: $localize`:@@month:month`,
|
|
year: $localize`:@@year:year`,
|
|
at: $localize`:@@at:at`
|
|
});
|
|
|
|
export const SUB_NAME = Object.freeze({
|
|
[SubKeys.ESS_1]: `${SubTexts.agmEss} 1`,
|
|
[SubKeys.ESS_1_1]: `${SubTexts.agmEss} 1 Plus`,
|
|
[SubKeys.ESS_2]: `${SubTexts.agmEss} 2`,
|
|
[SubKeys.ESS_3]: `${SubTexts.agmEss} 3`,
|
|
[SubKeys.ESS_4]: `${SubTexts.agmEss} 4`,
|
|
[SubKeys.ESS_5]: `${SubTexts.agmEss} 5`,
|
|
[SubKeys.ENT_1]: `${SubTexts.agmEnt} 1`,
|
|
[SubKeys.ENT_2]: `${SubTexts.agmEnt} 2`,
|
|
[SubKeys.ENT_3]: `${SubTexts.agmEnt} 3`,
|
|
[SubKeys.ENT_4]: `${SubTexts.agmEnt} 4`,
|
|
[SubKeys.ENT_5]: `${SubTexts.agmEnt} 5`,
|
|
[SubKeys.TRACKING]: $localize`:@@addon1:Aircraft Tracking`,
|
|
});
|
|
|
|
export enum SERVICE_TYPE { ESS = 'essential', ENT = 'enterprise', ADDON = 'addon' };
|
|
const X1 = '1 x';
|
|
export const UNLIMITED = $localize`:@@unlimted:Unlimited`;
|
|
export const EMPTY = '';
|
|
const TEN_PLUS = '10+';
|
|
export const subPlans = {
|
|
[SubKeys.ESS_1]: {
|
|
priceId: 1, maxVehicles: 1, maxAcres: '50000', desc: `${X1} ${SUB_NAME[SubKeys.ESS_1]} ${SubTexts.priceYearly}`, name: SUB_NAME[SubKeys.ESS_1], price: 99500, level: 1, Vehicles: EMPTY, type: SERVICE_TYPE.ESS, lookupKey: SubKeys.ESS_1, interval: 'year'
|
|
},
|
|
[SubKeys.ESS_1_1]: {
|
|
priceId: 1.1, maxVehicles: 1, maxAcres: null, desc: `${X1} ${SUB_NAME[SubKeys.ESS_1_1]} ${SubTexts.priceYearly}`, name: SUB_NAME[SubKeys.ESS_1_1], price: 139500, level: 1, Vehicles: EMPTY, type: SERVICE_TYPE.ESS, lookupKey: SubKeys.ESS_1_1, interval: 'year'
|
|
},
|
|
[SubKeys.ESS_2]: {
|
|
priceId: 2, maxVehicles: 2, maxAcres: UNLIMITED, desc: `${X1} ${SUB_NAME[SubKeys.ESS_2]} ${SubTexts.priceYearly}`, name: SUB_NAME[SubKeys.ESS_2], price: 249500, level: 2, Vehicles: EMPTY, type: SERVICE_TYPE.ESS, lookupKey: SubKeys.ESS_2, interval: 'year'
|
|
},
|
|
[SubKeys.ESS_3]: {
|
|
priceId: 3, maxVehicles: 5, maxAcres: UNLIMITED, desc: `${X1} ${SUB_NAME[SubKeys.ESS_3]} ${SubTexts.priceYearly}`, name: SUB_NAME[SubKeys.ESS_3], price: 349500, level: 3, Vehicles: EMPTY, type: SERVICE_TYPE.ESS, lookupKey: SubKeys.ESS_3, interval: 'year'
|
|
},
|
|
[SubKeys.ESS_4]: {
|
|
priceId: 4, maxVehicles: 10, maxAcres: UNLIMITED, desc: `${X1} ${SUB_NAME[SubKeys.ESS_4]} ${SubTexts.priceYearly}`, name: SUB_NAME[SubKeys.ESS_4], price: 449500, level: 4, Vehicles: EMPTY, type: SERVICE_TYPE.ESS, lookupKey: SubKeys.ESS_4, interval: 'year'
|
|
},
|
|
[SubKeys.ESS_5]: {
|
|
priceId: 5, maxVehicles: UNLIMITED, maxAcres: SubTexts.unlimited, desc: `${X1} ${SUB_NAME[SubKeys.ESS_5]} ${SubTexts.priceYearly}`, name: SUB_NAME[SubKeys.ESS_5], price: 899000, level: 5, Vehicles: EMPTY, type: SERVICE_TYPE.ESS, lookupKey: SubKeys.ESS_5, interval: 'year'
|
|
},
|
|
[SubKeys.ENT_1]: {
|
|
priceId: 6, maxVehicles: 1, maxAcres: UNLIMITED, desc: `${X1} ${SUB_NAME[SubKeys.ENT_1]} ${SubTexts.priceYearly}`, name: SUB_NAME[SubKeys.ENT_1], price: 149500, level: 11, Vehicles: EMPTY, type: SERVICE_TYPE.ENT, lookupKey: SubKeys.ENT_1, interval: 'year'
|
|
},
|
|
[SubKeys.ENT_2]: {
|
|
priceId: 7, maxVehicles: 1, maxAcres: UNLIMITED, desc: `${X1} ${SUB_NAME[SubKeys.ENT_2]} ${SubTexts.priceYearly}`, name: SUB_NAME[SubKeys.ENT_2], price: 249500, level: 12, Vehicles: EMPTY, type: SERVICE_TYPE.ENT, lookupKey: SubKeys.ENT_2, interval: 'year'
|
|
},
|
|
[SubKeys.ENT_3]: {
|
|
priceId: 8, maxVehicles: 5, maxAcres: UNLIMITED, desc: `${X1} ${SUB_NAME[SubKeys.ENT_3]} ${SubTexts.priceYearly}`, name: SUB_NAME[SubKeys.ENT_3], price: 499500, level: 13, Vehicles: EMPTY, type: SERVICE_TYPE.ENT, lookupKey: SubKeys.ENT_3, interval: 'year'
|
|
},
|
|
[SubKeys.ENT_4]: {
|
|
priceId: 9, maxVehicles: 10, maxAcres: UNLIMITED, desc: `${X1} ${SUB_NAME[SubKeys.ENT_4]} ${SubTexts.priceYearly}`, name: SUB_NAME[SubKeys.ENT_4], price: 499500, level: 14, Vehicles: EMPTY, type: SERVICE_TYPE.ENT, lookupKey: SubKeys.ENT_4, interval: 'year'
|
|
},
|
|
[SubKeys.ENT_5]: {
|
|
priceId: 10, maxVehicles: UNLIMITED, maxAcres: SubTexts.unlimited, desc: `${X1} ${SUB_NAME[SubKeys.ENT_5]} ${SubTexts.priceYearly}`, name: SUB_NAME[SubKeys.ENT_5], price: SubTexts.contact, Vehicles: TEN_PLUS, type: SERVICE_TYPE.ENT, lookupKey: SubKeys.ENT_5, interval: 'year'
|
|
|
|
},
|
|
[SubKeys.TRACKING]: {
|
|
priceId: 1, desc: `${SUB_NAME[SubKeys.TRACKING]} ${SubTexts.priceMonthly}`, name: SUB_NAME[SubKeys.TRACKING], price: 4995, level: 0, type: SERVICE_TYPE.ADDON, lookupKey: SubKeys.TRACKING, interval: 'month'
|
|
},
|
|
}
|
|
|
|
/**
|
|
* Get descriptive package name from lookup key
|
|
* @param lookupKey - Package lookup key (e.g., 'ess_1', 'ent_2')
|
|
* @returns Descriptive name (e.g., 'AgMission Essentials 1', 'AgMission Enterprise 2')
|
|
*/
|
|
export function getPackageDisplayName(lookupKey: string): string {
|
|
if (!lookupKey) {
|
|
return '';
|
|
}
|
|
|
|
// Convert to lowercase to match SubKeys enum values (which are lowercase)
|
|
const key = lookupKey.toLowerCase();
|
|
|
|
// Check if key exists in subPlans
|
|
if (subPlans[key]) {
|
|
return subPlans[key].name;
|
|
}
|
|
|
|
// Fallback: Format the key (e.g., unknown_key -> Unknown Key)
|
|
return lookupKey
|
|
.replace(/_/g, ' ')
|
|
.split(' ')
|
|
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
.join(' ');
|
|
}
|
|
|
|
|
|
export const SubErrMsgs = {}
|
|
// stripe errors
|
|
SubErrMsgs[SubStripe.REQUIRE_ACTION] = $localize`:@@subMsgReqAction:Please verify your card (#card#) for 3DS authentication. Click 'Submit' to confirm.`;
|
|
SubErrMsgs[SubStripe.REQUIRE_PAYMENT_METHOD] = $localize`:@@subMsgReqPm:Your recent invoice couldn't be processed as the card (#card#) is invalid. Please attempt once more with this card, or use a different valid card.`;
|
|
SubErrMsgs[SubStripe.PAST_DUE] = $localize`:@@subMsgPastDue:Processing for #card# failed due to overdue account. Please retry with this card once more, or opt for an alternative valid card.`;
|
|
SubErrMsgs[SubStripe.UNPAID] = $localize`:@@textUnpaid:Processing of unpaid invoices with #card# was unsuccessful. Please reach out to support for assistance.`;
|
|
SubErrMsgs[SubStripe.PI_AUTH_FAILURE] = $localize`:@@subMsgPiAuthFail:Failed to process #card# due to 3DS authentication error. Please click 'Back' to choose a different card or enter a new valid one.`;
|
|
SubErrMsgs[SubStripe.PI_IMCOMPAT_PM] = $localize`:@@subMsgPiIncompat:Unable to process #card# as the payment method is incompatible. Please click 'Back' to choose a different card or enter a new valid one.`;
|
|
SubErrMsgs[SubStripe.CARD_DECLINED] = $localize`:@@subMsgCardDecline:#card# declined. Please use a different, valid card.`;
|
|
SubErrMsgs[SubStripe.INSUFFICIENT_FUNDS] = $localize`:@@subMsgInfFund:#card# has insufficient funds. Please use an alternative card with available balance.`;
|
|
SubErrMsgs[SubStripe.STOLEN_CARD] = $localize`:@@subMsgStolenCard:#card# reported as stolen. Please use a different, valid card.`;
|
|
SubErrMsgs[SubStripe.LOST_CARD] = $localize`:@@subMsgLostCard:#card# reported as lost. Please use a different, valid card.`;
|
|
SubErrMsgs[SubStripe.EXPIRED_CARD] = $localize`:@@subMsgExpCard:#card# is expired. Please use a different, valid card.`;
|
|
SubErrMsgs[SubStripe.INCORRECT_CVC] = $localize`:@@subMsgIncorrectCard:#card# has Incorrect CVC. Please verify or use a different, valid card.`;
|
|
SubErrMsgs[SubStripe.PROC_ERR] = $localize`:@@subMsgProcErr:#card# could not be completed due to a processing error. Please verify or use a different, valid card.`;
|
|
SubErrMsgs[SubStripe.EXCEEDED_VELOCITY] = $localize`:@@subMsgExceededVel:#card# was declined for making repeated attempts too frequently or exceeding its amount limit.`;
|
|
SubErrMsgs[SubStripe.REQ_LOC_INPUT] = $localize`:@@subMsgReqLoc:Tax location not recognized. Please click [Update Address] to correct your address details.`;
|
|
|
|
// effects errors
|
|
SubErrMsgs[SubAppErr.NO_SUBS_ERR] = $localize`:@@subMsgNoSubErr:Your subscriptions are currently not visible. For assistance, please reach out to support.`;
|
|
SubErrMsgs[SubAppErr.NO_INVOICES_ERR] = $localize`:@@subMsgNoInvoiceErr:Invoices not found. Please reach out to support for help.`;
|
|
SubErrMsgs[SubAppErr.NO_ACTIONS_ERR] = $localize`:@@subMsgNoActionErr:Your recent subscription issue cannot be resolved automatically. Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.RES_SUB_ERR] = $localize`:@@subMsgResSubErr:Payment for your recent invoice via #card# was unsuccessful. Please click [Update Payment Information] to settle the outstanding balance.`;
|
|
SubErrMsgs[SubAppErr.RES_SUB_ERR_NO_CARD] = $localize`:@@subMsgResSubErrNoCard:Payment for your recent invoice could not be processed due to an unrecognized card. Please click [Update Payment Information] to clear the outstanding balance.`;
|
|
SubErrMsgs[SubAppErr.UPDATE_PM_ERR] = $localize`:@@subMsgUpdatePmErr:Updating your payment method was unsuccessful. For assistance, please contact support.`;
|
|
SubErrMsgs[SubAppErr.CRT_PM_ERR] = $localize`:@@subMsgCrtPmErr:Creation of payment method card failed. Please reach out to support for help.`;
|
|
SubErrMsgs[SubAppErr.CONF_ERR] = $localize`:@@subMsgConfErr:Confirmation of your subscription payment was unsuccessful. Please reach out to support for assistance.`
|
|
SubErrMsgs[SubAppErr.CANCEL_ERR] = $localize`:@@subMsgCancelErr:Cancellation of your subscription could not be processed. For assistance, please contact support.`;
|
|
SubErrMsgs[SubAppErr.REFUND_ERR] = $localize`:@@subMsgRefundErr:Refund for your subscription could not be processed. Please reach out to support for assistance.`;
|
|
SubErrMsgs[SubAppErr.REFRESH_ERR] = $localize`:@@subMsgRefreshErr:Reinitialization of your subscription status was unsuccessful. Please contact support for further assistance.`;
|
|
SubErrMsgs[SubAppErr.RES_UNPAID_ERR] = $localize`:@@subMsgResumeUnpaidErr:Resuming your unpaid subscription was not possible. Please reach out to support for assistance.`;
|
|
SubErrMsgs[SubAppErr.FETCH_SUB_ERR] = $localize`:@@subMsgFetchSubErr:Retrieving your subscription details was unsuccessful. For assistance, please contact support.`;
|
|
SubErrMsgs[SubAppErr.FETCH_PMT_ERR] = $localize`:@@subMsgFetchPmtErr:Fetching your payment invoices was unsuccessful. Please reach out to support for help.`;
|
|
SubErrMsgs[SubAppErr.FETCH_USAGE_ERR] = $localize`:@@subMsgFetchUsageErr:Retrieving your usage details was unsuccessful. Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.FETCH_SUB_PLANS_ERR] = $localize`:@@subMsgFetchSubPlansErr:Fetching subscription plans was unsuccessful. For assistance, please contact support.`;
|
|
|
|
SubErrMsgs[SubAppErr.START_BIL_INFO_ERR] = $localize`:@@subMsgStartBilInfoErr:Initialization of Billing Information failed. Please reach out to support for assistance.`;
|
|
SubErrMsgs[SubAppErr.START_CHECKOUT_ERR] = $localize`:@@subMsgStartChkoutErr:Checkout process initialization failed. Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.CHECKOUT_TRIAL_ERR] = $localize`:@@subMsgChkoutTrialErr:Starting your trial subscription was unsuccessful. Please reach out to support for help.`;
|
|
SubErrMsgs[SubAppErr.UPDATE_SUB_ERR] = $localize`:@@subMsgUpdateSubErr:Subscription update failed. Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.POLL_ERR] = $localize`:@@subMsgPollingErr:Monitoring your unpaid subscription was unsuccessful. Please reach out to support for assistance.`;
|
|
SubErrMsgs[SubAppErr.PAY_UNPAID_ERR] = $localize`:@@subMsgPayUnpaidErr:Payment for your outstanding subscription could not be processed. Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.PAY_UNPAID_CARD_ERR] = $localize`:@@subMsgPayUnpaidCardErr:Payment for your subscription using #card# was unsuccessful. Please choose a different card from your available payment options.`;
|
|
SubErrMsgs[SubAppErr.COMP_ACT_ERR] = $localize`:@@subMsgCompActErr:Execution of multiple actions at once was unsuccessful. For assistance, please contact support.`
|
|
SubErrMsgs[SubAppErr.APP_DISCOUNT_PREVIEW_ERR] = $localize`:@@subMsgAppDisPrevErr:Invalid discount code. Please check and try again.`
|
|
SubErrMsgs[SubAppErr.CHECKOUT_CONT_TRIAL_ERR] = $localize`:@@subMsgChkoutContTrialErr:Extending your trial subscription was unsuccessful. Please reach out to support for assistance.`
|
|
|
|
// payment method errors
|
|
SubErrMsgs[SubAppErr.FETCH_PM_ERR] = $localize`:@@subFetchPmErr:Unable to retrieve your payment methods. Please contact support for assistance.`
|
|
SubErrMsgs[SubAppErr.FETCH_DEFAULT_PM_ERR] = $localize`:@@subFetchDefaultPmErr:Trouble identifying your default subscription payment method. Please update it for continued service.`
|
|
SubErrMsgs[SubAppErr.EDIT_PM_ERR] = $localize`:@@subEditPMErr:Editing your payment method was unsuccessful. For assistance, please contact support.`
|
|
SubErrMsgs[SubAppErr.ADD_PM_ERR] = $localize`:@@subAddPMErr:Adding your payment method failed. Please reach out to support for help.`
|
|
SubErrMsgs[SubAppErr.DELETE_PM_ERR] = $localize`:@@subDeletePMErr:Deletion of your payment method was unsuccessful. Please contact support for assistance.`
|
|
SubErrMsgs[SubAppErr.CHANGE_PM_ERR] = $localize`:@@subChangePMErr:Changing your default payment method was unsuccessful. Please reach out to support for assistance.`
|
|
|
|
// component errors
|
|
SubErrMsgs[SubAppErr.MGE_SERV_ERR] = $localize`:@@subMsgManageServErr:Issue encountered during service management. Please contact support for resolution.`;
|
|
SubErrMsgs[SubAppErr.BIL_ADDR_ERR] = $localize`:@@subMsgBillAddrErr:Issue with billing address verification. Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.CHKOUT_ERR] = $localize`:@@subMsgChkoutErr:Issue encountered at checkout. Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.CHKOUT_REV_ERR] = $localize`:@@subMsgChkoutRevErr:Issue during checkout review. Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.CHKOUT_CONF_ERR] = $localize`:@@subMsgChkoutConfErr:Issue during checkout confirmation. Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.MGE_SUB_ERR] = $localize`:@@subMsgManageSubErr:Issue managing subscriptions. Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.PM_LIST_ERR] = $localize`:@@subMsgPmListErr:Issue with payment list retrieval. Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.PM_DETAIL_ERR] = $localize`:@@subMsgPmDetailErr:Issue accessing payment details. Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.UNPAID_ERR] = $localize`:@@subMsgUnpaidErr:Issue encountered on the unpaid page. Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.INC_ADDR_ERR] = $localize`:@@subMsgIncAddrErr:Please complete all address fields.`;
|
|
SubErrMsgs[SubAppErr.INC_CARD_ERR] = $localize`:@@subMsgIncCardErr:Please complete all card information fields.`;
|
|
SubErrMsgs[SubAppErr.USAGE_DETAIL_ERR] = $localize`:@@subMsgUsageDetailErr:Issue accessing usage details. Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.PMT_METHOD_LIST_ERR] = $localize`:@@subPmtMethodListErr:Issue retrieving payment method list. Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.INVALID_DATE] = $localize`:@@subInvalidDateErr:Please enter a valid date.`;
|
|
SubErrMsgs[SubAppErr.AC_LIST_ERR] = $localize`:@@subAcListErr:Issue retrieving aircraft list. Please contact support for assistance.`;
|
|
|
|
// stripe errors
|
|
SubErrMsgs[SubAppErr.LOAD_STRIPE_ERR] = $localize`:@@subMsgLoadStripeErr:Issue loading Stripe system detected. Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.STRIPE_ERR] = $localize`:@@subMsgStripeErr:Connection issue with our payment system detected. Please contact support for assistance.`;
|
|
|
|
// critical errors
|
|
SubErrMsgs[SubAppErr._500_ERR] = $localize`:@@subMsg500Err:Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.RES_ERR] = $localize`:@@subMsgResErr:Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.APP_VENDOR_NOT_FOUND] = $localize`:@@subMsgAppVendorNotFound:Application vendor not found. Please contact support for assistance.`;
|
|
SubErrMsgs[SubAppErr.LOCAL_VENDOR_NOT_FOUND] = $localize`:@@subMsgLocalVendorNotFound:Local vendor not found. Please contact support for assistance.`;
|
|
|
|
export const signupCode = Object.freeze({
|
|
userExist: 'user_exist',
|
|
signupFailed: 'signupFailed',
|
|
invalidAccountErr: 'invalid_account',
|
|
activeAccountErr: 'active_account',
|
|
invalidTokenErr: 'invalid_token',
|
|
unknownErr: 'unknown_error',
|
|
signupLoadingError: 'signupLoadingError',
|
|
emailError: 'email_error',
|
|
verificationCodeExpired: 'verification_code_expired',
|
|
invalidVerificationCode: 'invalid_verification_code',
|
|
alreadySignedUp: 'already_signed_up',
|
|
});
|
|
|
|
export const signupMsg: any = Object.freeze({
|
|
userExist: $localize`:@@userExist:User already exists`,
|
|
unknownErr: $localize`:@@unknownErr:An unexpected error occurred during signup. Please try again later or contact support for assistance.`,
|
|
activeAccountErr: $localize`:@@activeAccountErr:Account already active. Please login to continue.`,
|
|
invalidAccountErr: $localize`:@@invalidAccountErr:Invalid account. Please check your contact email account and try again.`,
|
|
invalidTokenErr: $localize`:@@invalidTokenErr:The verification link is invalid or expired. A new email has been sent to your registered address. Please check your inbox.`,
|
|
signupLoadingError: $localize`:@@signupLoadingError:An error occurred while loading the signup page. Please try again later or contact support for assistance.`,
|
|
emailMsg: $localize`:@@emailMsg:Your email helps us identify you and keep in touch about your account.`,
|
|
reValidateMsg: $localize`:@@revalidateMsg:Your email address has been updated. Please verify your new email to keep your account secure.`,
|
|
emailError: $localize`:@@emailError:Invalid email address. Please enter a valid email address and re-submit.`,
|
|
verificationCodeExpired: $localize`:@@verificationCodeExpired:Your verification code has expired. Please re-verify your email address to receive a new code.`,
|
|
invalidVerificationCode: $localize`:@@invalidVerificationCode:Invalid verification code. Please check your email and try again.`,
|
|
alreadySignedUp: $localize`:@@alreadySignedUp:You have already signed up with #email#. Please login to continue or Verify with another email.`,
|
|
})
|
|
|
|
// ============================================================================
|
|
// PARTNER INTEGRATION ERROR CODES & MESSAGES
|
|
// ============================================================================
|
|
|
|
/**
|
|
* Partner integration error codes returned from backend API.
|
|
* These codes are used to identify specific partner system errors.
|
|
* Matches server-side constants in server/helpers/constants.js
|
|
*
|
|
* More error codes will be added as backend implementation expands.
|
|
*/
|
|
export const partnerErrorCode = Object.freeze({
|
|
// Current backend error codes (as of 2025-10-10)
|
|
partnerServiceUnavailable: 'partner_service_unavailable',
|
|
invalidAssignment: 'invalid_assignment',
|
|
wrongCredential: 'wrong_credential',
|
|
|
|
// Default fallback for unmapped errors
|
|
unknownError: 'unknown_error'
|
|
});
|
|
|
|
/**
|
|
* User-facing error messages for partner integration errors.
|
|
* Mapped to partner error codes for consistent UX.
|
|
* Matches server-side error codes in server/helpers/constants.js
|
|
*/
|
|
export const partnerErrorMsg: any = Object.freeze({
|
|
// Current backend error messages (as of 2025-10-10)
|
|
partnerServiceUnavailable: $localize`:@@partnerServiceUnavailable:Partner system is currently unavailable. Please try again later.`,
|
|
invalidAssignment: $localize`:@@partnerInvalidAssignment:Invalid partner assignment. Please verify your configuration.`,
|
|
wrongCredential: $localize`:@@partnerWrongCredential:Invalid username or password. Please check your credentials and try again.`,
|
|
|
|
// Default fallback message
|
|
unknownError: $localize`:@@partnerUnknownError:An unexpected error occurred with partner system. Please contact support for assistance.`
|
|
});
|
|
|
|
/**
|
|
* Generic error handler for user and subscription-related operations.
|
|
*
|
|
* This function processes errors from API calls and transforms them into appropriate
|
|
* typed responses based on the error context. It delegates error handling to the
|
|
* middleware function `handleSubErr` which will identify the error type and return
|
|
* the appropriate response (typically an Observable with an error action).
|
|
*
|
|
* @template T - The return type of the error handler (usually an Observable with an error action)
|
|
* @param {any} err - The error object to process, typically from an HTTP request
|
|
* @returns {T} A typed response containing the appropriate error action based on the error context
|
|
*
|
|
* @example
|
|
* // Handle error in an effect
|
|
* catchError(err => handleErr<Observable<Action>>(err))
|
|
*
|
|
* @example
|
|
* // Handle error with specific error type
|
|
* catchError(err => handleErr<Observable<UpdateSubscriptionStatus>>(err))
|
|
*/
|
|
export const handleErr = <T>(err): T => {
|
|
return errorHandler(err, handleSubErr);
|
|
}
|
|
|
|
export const handleSubErr = (params: { error, opt?}) => {
|
|
if (params?.error instanceof HttpErrorResponse) {
|
|
const tag = params?.error?.error?.['.tag'] || params?.error?.error?.error?.['.tag'];
|
|
if (tag) {
|
|
if (params?.opt?.extra == signupCode.signupFailed) {
|
|
return handleSignupErr({ error: params.error, opt: { ...params.opt, tag } });
|
|
}
|
|
if (hasVendorErr(tag)) {
|
|
return handleVendorErr({ error: params.error, opt: { ...params.opt, tag } });
|
|
}
|
|
// Preserve custom message if provided, only use tag as fallback
|
|
return handleAppErr({ error: params.error, opt: { ...params.opt, msg: params?.opt?.msg || tag } });
|
|
} else {
|
|
return handleAppErr(params);
|
|
}
|
|
} else {
|
|
return handleAppErr(params);
|
|
}
|
|
}
|
|
|
|
export const handleSignupErr = (params: { error, opt?}) => {
|
|
const tag = params?.opt?.tag;
|
|
switch (tag) {
|
|
case signupCode.userExist:
|
|
return { code: signupCode.userExist, message: signupMsg.userExist };
|
|
case signupCode.activeAccountErr:
|
|
return { code: signupCode.activeAccountErr, message: signupMsg.activeAccountErr };
|
|
case signupCode.invalidAccountErr:
|
|
return { code: signupCode.invalidAccountErr, message: signupMsg.invalidAccountErr };
|
|
case signupCode.invalidTokenErr:
|
|
return { code: signupCode.invalidTokenErr, message: signupMsg.invalidTokenErr };
|
|
case signupCode.signupLoadingError:
|
|
return { code: signupCode.signupLoadingError, message: signupMsg.signupLoadingError };
|
|
case signupCode.emailError:
|
|
return { code: signupCode.emailError, message: signupMsg.emailError };
|
|
case signupCode.verificationCodeExpired:
|
|
return { code: signupCode.verificationCodeExpired, message: signupMsg.verificationCodeExpired };
|
|
case signupCode.invalidVerificationCode:
|
|
return { code: signupCode.invalidVerificationCode, message: signupMsg.invalidVerificationCode };
|
|
case signupCode.alreadySignedUp:
|
|
return { code: signupCode.alreadySignedUp, message: signupMsg.alreadySignedUp.replace('#email#', params?.opt?.email || '') };
|
|
default:
|
|
return { code: signupCode.unknownErr, message: signupMsg.unknownErr };
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Partner integration error handler (standalone function).
|
|
* Can be used directly in components or through the middleware chain.
|
|
* Extracts .tag from error response and maps to user-facing error messages.
|
|
*
|
|
* @param {any} error - HttpErrorResponse or error object from API
|
|
* @returns {object} Object with code and message properties
|
|
*
|
|
* @example
|
|
* // Direct usage in components
|
|
* catchError(err => {
|
|
* const errorResult = handlePartnerErr(err);
|
|
* this.satlocError = errorResult.message;
|
|
* return of(null);
|
|
* })
|
|
*
|
|
* @example
|
|
* // Backend returns: { error: { '.tag': 'invalid_credentials' } }
|
|
* // Returns: { code: 'invalid_credentials', message: 'Invalid username or password...' }
|
|
*/
|
|
export const handlePartnerErr = (error: any): { code: string, message: string } => {
|
|
// Extract .tag from error response (supports multiple nesting patterns)
|
|
// Backend structure: HttpErrorResponse.error = { error: { ".tag": "...", "message": "..." } }
|
|
let tag: string | null = null;
|
|
|
|
if (error instanceof HttpErrorResponse) {
|
|
// Try deeper nesting first (error.error.error['.tag']), then fallback to error.error['.tag']
|
|
tag = error?.error?.error?.['.tag'] || error?.error?.['.tag'];
|
|
} else if (error?.error) {
|
|
// For non-HttpErrorResponse objects (e.g., success response with error property)
|
|
tag = error?.error?.error?.['.tag'] || error?.error?.['.tag'];
|
|
}
|
|
|
|
// Map tag to error code and message
|
|
// More cases will be added as backend implementation expands
|
|
switch (tag) {
|
|
// Current backend error codes (as of 2025-10-10)
|
|
case partnerErrorCode.partnerServiceUnavailable:
|
|
return { code: partnerErrorCode.partnerServiceUnavailable, message: partnerErrorMsg.partnerServiceUnavailable };
|
|
case partnerErrorCode.invalidAssignment:
|
|
return { code: partnerErrorCode.invalidAssignment, message: partnerErrorMsg.invalidAssignment };
|
|
case partnerErrorCode.wrongCredential:
|
|
return { code: partnerErrorCode.wrongCredential, message: partnerErrorMsg.wrongCredential };
|
|
|
|
// Default fallback for unmapped errors
|
|
default:
|
|
return { code: partnerErrorCode.unknownError, message: partnerErrorMsg.unknownError };
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Check if error tag is a partner integration error.
|
|
* Used by middleware chain to route to handlePartnerErr.
|
|
*/
|
|
export const hasPartnerErr = (tag: string): boolean => {
|
|
return Object.values(partnerErrorCode).includes(tag as any);
|
|
}
|
|
|
|
const handleVendorErr = (params: { error, opt?}) => {
|
|
const tag = params?.opt?.tag == SubAppErr.APP_VENDOR_NOT_FOUND ? SubAppErr.APP_VENDOR_NOT_FOUND : SubAppErr.LOCAL_VENDOR_NOT_FOUND;
|
|
const code = params?.opt?.extra;
|
|
const message = SubErrMsgs[tag];
|
|
|
|
if (isSubscriptionIntentStatus(code)) {
|
|
return of(new UpdateSubscriptionIntentStatus({ code: tag, message }));
|
|
} else if (isSubscriptionStatus(code)) {
|
|
return of(new UpdateSubscriptionStatus({ code: tag, message }));
|
|
}
|
|
|
|
switch (code) {
|
|
case SubAppErr.FETCH_PMT_ERR:
|
|
return of(new FetchError({ code: tag, message }));
|
|
case SubAppErr.FETCH_USAGE_ERR:
|
|
return of(new FetchUsageFailed({ code: tag, message }));
|
|
case SubAppErr.FETCH_SUB_PLANS_ERR:
|
|
return of(new FetchSubPlansFailed({ code: tag, message }));
|
|
default:
|
|
return of(new UpdateSubscriptionStatus({ code: tag, message }));
|
|
}
|
|
}
|
|
|
|
const isSubscriptionIntentStatus = (code): boolean => {
|
|
return [
|
|
SubAppErr.CRT_PM_ERR,
|
|
SubAppErr.START_BIL_INFO_ERR,
|
|
SubAppErr.START_CHECKOUT_ERR,
|
|
SubAppErr.CHECKOUT_TRIAL_ERR,
|
|
SubAppErr.CHECKOUT_CONT_TRIAL_ERR,
|
|
SubAppErr.CANCEL_ERR,
|
|
SubAppErr.REFUND_ERR,
|
|
SubAppErr.RES_UNPAID_ERR,
|
|
SubAppErr.COMP_ACT_ERR,
|
|
SubAppErr.STRIPE_ERR,
|
|
SubAppErr.LOAD_STRIPE_ERR,
|
|
SubAppErr.APP_DISCOUNT_PREVIEW_ERR
|
|
].includes(code);
|
|
};
|
|
|
|
const isSubscriptionStatus = (code): boolean => {
|
|
return [
|
|
SubAppErr.REFRESH_ERR,
|
|
SubAppErr.UPDATE_SUB_ERR,
|
|
SubAppErr.FETCH_SUB_ERR,
|
|
SubAppErr.POLL_ERR,
|
|
SubAppErr.CONF_ERR,
|
|
SubAppErr.PAY_UNPAID_ERR,
|
|
SubAppErr.NO_INVOICES_ERR,
|
|
SubAppErr.NO_SUBS_ERR,
|
|
SubAppErr.NO_ACTIONS_ERR,
|
|
SubAppErr.ADD_PM_ERR,
|
|
SubAppErr.EDIT_PM_ERR,
|
|
SubAppErr.DELETE_PM_ERR,
|
|
SubAppErr.CHANGE_PM_ERR
|
|
].includes(code);
|
|
};
|
|
|
|
export const hasVendorErr = (code): boolean => {
|
|
return code == SubAppErr.APP_VENDOR_NOT_FOUND || code == SubAppErr.LOCAL_VENDOR_NOT_FOUND;
|
|
}
|
|
|
|
const handleAppErr = (params: { error, opt?}) => {
|
|
// Handle card-specific errors first (unpaid and decline errors)
|
|
const isStripeCardErr = !!params?.opt?.card;
|
|
if (isStripeCardErr) {
|
|
const declineErr = params?.error?.error?.decline_code || params?.error?.error?.code;
|
|
const isUnpaidCardErr = params?.opt?.msg === SubAppErr.PAY_UNPAID_CARD_ERR;
|
|
if (isUnpaidCardErr) {
|
|
return of(new UpdateUnpaid({ invoices: params?.opt?.extra?.invoices, numOfRetries: 1 }), new UpdateSubscriptionStatus({ code: SubStripe.UNPAID, message: SubErrMsgs[SubAppErr.PAY_UNPAID_CARD_ERR]?.replace('#card#', `${params?.opt?.card?.brand} ${SubTexts.ending} **** ${params?.opt?.card?.last4}`) || '' }));
|
|
} else if (declineErr) {
|
|
return of(new UpdateSubscriptionStatus({ code: SubStripe.CARD_DECLINED, message: SubErrMsgs[declineErr]?.replace('#card#', `${params?.opt?.card?.brand} ${SubTexts.ending} **** ${params?.opt?.card?.last4}`) || SubErrMsgs[SubStripe.CARD_DECLINED]?.replace('#card#', `${params?.opt?.card?.brand} ${SubTexts.ending} **** ${params?.opt?.card?.last4}`) || '' }));
|
|
}
|
|
// No decline error - fall through to errTag handling below
|
|
}
|
|
|
|
// Handle errors by errTag (applies to both card and non-card errors)
|
|
const errTag = params?.opt?.extra;
|
|
|
|
// subscription intent error status
|
|
if (errTag == SubAppErr.CRT_PM_ERR || SubAppErr.CHECKOUT_TRIAL_ERR) {
|
|
const declineErr = params?.error?.error?.decline_code || params?.error?.error?.code;
|
|
if (errTag == SubAppErr.CRT_PM_ERR) {
|
|
return of(new CreatePaymentMethodFailed({ code: SubAppErr.CRT_PM_ERR, message: SubErrMsgs[declineErr]?.replace('#card#', SubTexts.card) || params?.opt?.msg || SubErrMsgs[SubAppErr.CRT_PM_ERR] }));
|
|
} else if (errTag == SubAppErr.CHECKOUT_TRIAL_ERR) {
|
|
return of(new CreateSubscriptionIntentFailed({ code: SubAppErr.CHECKOUT_TRIAL_ERR, message: SubErrMsgs[declineErr]?.replace('#card#', SubTexts.card) || params?.opt?.msg || SubErrMsgs[SubAppErr.CHECKOUT_TRIAL_ERR] }));
|
|
}
|
|
}
|
|
|
|
switch (errTag) {
|
|
|
|
// subscription intent error status
|
|
case SubAppErr.START_BIL_INFO_ERR:
|
|
return of(new CreateSubscriptionIntentFailed({ code: SubAppErr.START_BIL_INFO_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.START_BIL_INFO_ERR] }));
|
|
case SubAppErr.START_CHECKOUT_ERR:
|
|
return of(new CreateSubscriptionIntentFailed({ code: SubAppErr.START_CHECKOUT_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.START_CHECKOUT_ERR] }));
|
|
case SubAppErr.CHECKOUT_CONT_TRIAL_ERR:
|
|
return of(new CreateSubscriptionIntentFailed({ code: SubAppErr.CHECKOUT_CONT_TRIAL_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.CHECKOUT_CONT_TRIAL_ERR] }));
|
|
case SubAppErr.CANCEL_ERR:
|
|
return of(new CreateSubscriptionIntentFailed({ code: SubAppErr.CANCEL_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.CANCEL_ERR] }));
|
|
case SubAppErr.REFUND_ERR:
|
|
return of(new CreateSubscriptionIntentFailed({ code: SubAppErr.REFUND_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.REFUND_ERR] }));
|
|
case SubAppErr.RES_UNPAID_ERR:
|
|
return of(new CreateSubscriptionIntentFailed({ code: SubAppErr.RES_UNPAID_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.RES_UNPAID_ERR] }));
|
|
case SubAppErr.COMP_ACT_ERR:
|
|
return of(new UpdateSubscriptionIntentStatus({ code: SubAppErr.COMP_ACT_ERR, message: SubErrMsgs[SubAppErr.COMP_ACT_ERR] }));
|
|
case SubAppErr.STRIPE_ERR:
|
|
return of(new UpdateSubscriptionIntentStatus({ code: SubAppErr.STRIPE_ERR, message: SubErrMsgs[SubAppErr.STRIPE_ERR] }));
|
|
case SubAppErr.LOAD_STRIPE_ERR:
|
|
return of(new LoadStripeFailed({ code: SubAppErr.LOAD_STRIPE_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.LOAD_STRIPE_ERR] }));
|
|
case SubAppErr.APP_DISCOUNT_PREVIEW_ERR:
|
|
return of(new ApplyDiscountPreviewFailed({ code: SubAppErr.APP_DISCOUNT_PREVIEW_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.APP_DISCOUNT_PREVIEW_ERR] }));
|
|
|
|
// subscription error status
|
|
case SubAppErr.REFRESH_ERR:
|
|
return of(new UpdateSubscriptionStatus({ code: SubAppErr.REFRESH_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.REFRESH_ERR] }));
|
|
case SubAppErr.UPDATE_SUB_ERR:
|
|
return of(new UpdateSubscriptionStatus({ code: SubAppErr.UPDATE_SUB_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.UPDATE_SUB_ERR] }));
|
|
case SubAppErr.FETCH_SUB_ERR:
|
|
return of(new UpdateSubscriptionStatus({ code: SubAppErr.FETCH_SUB_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.FETCH_SUB_ERR] }));
|
|
case SubAppErr.POLL_ERR:
|
|
return of(new UpdateSubscriptionStatus({ code: SubAppErr.POLL_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.POLL_ERR] }));
|
|
case SubAppErr.CONF_ERR:
|
|
return of(new UpdateSubscriptionStatus({ code: SubAppErr.CONF_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.CONF_ERR] }));
|
|
case SubAppErr.PAY_UNPAID_ERR:
|
|
return of(new UpdateSubscriptionStatus({ code: SubAppErr.PAY_UNPAID_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.PAY_UNPAID_ERR] }));
|
|
case SubAppErr.NO_INVOICES_ERR:
|
|
return of(new UpdateSubscriptionStatus({ code: SubAppErr.NO_INVOICES_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.NO_INVOICES_ERR] }));
|
|
case SubAppErr.NO_SUBS_ERR:
|
|
return of(new UpdateSubscriptionStatus({ code: SubAppErr.NO_SUBS_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.NO_SUBS_ERR] }));
|
|
case SubAppErr.NO_ACTIONS_ERR:
|
|
return of(new UpdateSubscriptionStatus({ code: SubAppErr.NO_ACTIONS_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.NO_ACTIONS_ERR] }));
|
|
case SubAppErr.ADD_PM_ERR:
|
|
return of(new UpdateSubscriptionStatus({ code: SubAppErr.ADD_PM_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.ADD_PM_ERR] }));
|
|
case SubAppErr.EDIT_PM_ERR:
|
|
return of(new UpdateSubscriptionStatus({ code: SubAppErr.EDIT_PM_ERR, message: SubErrMsgs[SubAppErr.EDIT_PM_ERR] }));
|
|
case SubAppErr.DELETE_PM_ERR:
|
|
return of(new UpdateSubscriptionStatus({ code: SubAppErr.DELETE_PM_ERR, message: SubErrMsgs[SubAppErr.DELETE_PM_ERR] }));
|
|
case SubAppErr.CHANGE_PM_ERR:
|
|
return of(new UpdateSubscriptionStatus({ code: SubAppErr.CHANGE_PM_ERR, message: SubErrMsgs[SubAppErr.CHANGE_PM_ERR] }));
|
|
|
|
// payment method error status
|
|
case SubAppErr.FETCH_PMT_ERR:
|
|
return of(new FetchError({ code: SubAppErr.FETCH_PMT_ERR, message: SubErrMsgs[SubAppErr.FETCH_PMT_ERR] }));
|
|
|
|
// usage error status
|
|
case SubAppErr.FETCH_USAGE_ERR:
|
|
return of(new FetchUsageFailed({ code: SubAppErr.FETCH_USAGE_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.FETCH_USAGE_ERR] }));
|
|
|
|
// subplan error status
|
|
case SubAppErr.FETCH_SUB_PLANS_ERR:
|
|
return of(new FetchSubPlansFailed({ code: SubAppErr.FETCH_SUB_PLANS_ERR, message: params?.opt?.msg || SubErrMsgs[SubAppErr.FETCH_SUB_PLANS_ERR] }));
|
|
|
|
// default error status
|
|
default:
|
|
return of(new UpdateSubscriptionStatus({ code: SubAppErr._500_ERR, message: SubErrMsgs[SubAppErr._500_ERR] }));
|
|
}
|
|
}
|
|
|
|
export const createSubStatus = (code: string, opt?: { card?: Card, extra?: any, msg?: string }): Status => {
|
|
switch (code) {
|
|
case SubStripe.REQUIRE_ACTION:
|
|
return { code: SubStripe.REQUIRE_ACTION, message: opt?.card ? SubErrMsgs[SubStripe.REQUIRE_ACTION]?.replace('#card#', `${opt?.card?.brand} ${SubTexts.ending} **** ${opt?.card?.last4}`) : SubErrMsgs[SubTexts.textReq3ds] };
|
|
case SubStripe.REQUIRE_PAYMENT_METHOD:
|
|
return { code: SubStripe.REQUIRE_PAYMENT_METHOD, message: SubErrMsgs[SubStripe.REQUIRE_PAYMENT_METHOD]?.replace('#card#', `${opt?.card?.brand} ${SubTexts.ending} **** ${opt?.card?.last4}`) || '' };
|
|
case SubStripe.CANCELED:
|
|
return { code: SubStripe.CANCELED, message: '' };
|
|
case SubStripe.PAST_DUE:
|
|
return { code: SubStripe.PAST_DUE, message: SubErrMsgs[SubStripe.PAST_DUE]?.replace('#card#', `${opt?.card?.brand} ${SubTexts.ending} **** ${opt?.card?.last4}`) || '' }
|
|
case SubStripe.REQ_LOC_INPUT:
|
|
return { code: SubStripe.REQ_LOC_INPUT, message: SubErrMsgs[SubStripe.REQ_LOC_INPUT] };
|
|
case SUB.UPDATE_DEF_PM:
|
|
return { code: SUB.UPDATE_DEF_PM, message: SubTexts.textUpdateDefPm };
|
|
case SUB.POLLING:
|
|
return { code: SUB.POLLING, message: SubTexts.textPolling };
|
|
case SUB.POLLING:
|
|
return { code: SUB.POLLING, message: SubTexts.textPolling };
|
|
case SubAppErr.NO_INVOICES_ERR:
|
|
return { code: SubAppErr.NO_INVOICES_ERR, message: SubErrMsgs[SubAppErr.NO_INVOICES_ERR] };
|
|
case SubAppErr.CONF_ERR:
|
|
return { code: SubAppErr.CONF_ERR, message: opt?.extra?.decline_code ? SubErrMsgs[opt?.extra?.decline_code]?.replace('#card#', `${opt?.card?.brand} ${SubTexts.ending} **** ${opt?.card?.last4}`) : opt?.extra?.code ? SubErrMsgs[opt?.extra?.code]?.replace('#card#', `${opt?.card?.brand} ${SubTexts.ending} **** ${opt?.card?.last4}`) : SubErrMsgs[SubAppErr.CONF_ERR] };
|
|
case SubAppErr.MGE_SERV_ERR:
|
|
return { code: SubAppErr.MGE_SERV_ERR, message: SubErrMsgs[SubAppErr.MGE_SERV_ERR] };
|
|
case SubAppErr.BIL_ADDR_ERR:
|
|
return { code: SubAppErr.BIL_ADDR_ERR, message: SubErrMsgs[SubAppErr.BIL_ADDR_ERR] };
|
|
case SubAppErr.CHKOUT_ERR:
|
|
return { code: SubAppErr.CHKOUT_ERR, message: SubErrMsgs[SubAppErr.CHKOUT_ERR] };
|
|
case SubAppErr.CHKOUT_REV_ERR:
|
|
return { code: SubAppErr.CHKOUT_REV_ERR, message: SubErrMsgs[SubAppErr.CHKOUT_REV_ERR] };
|
|
case SubAppErr.CHKOUT_CONF_ERR:
|
|
return { code: SubAppErr.CHKOUT_CONF_ERR, message: SubErrMsgs[SubAppErr.CHKOUT_CONF_ERR] };
|
|
case SubAppErr.MGE_SUB_ERR:
|
|
return { code: SubAppErr.MGE_SUB_ERR, message: SubErrMsgs[SubAppErr.MGE_SUB_ERR] };
|
|
case SubAppErr.PM_LIST_ERR:
|
|
return { code: SubAppErr.PM_LIST_ERR, message: SubErrMsgs[SubAppErr.PM_LIST_ERR] };
|
|
case SubAppErr.PM_DETAIL_ERR:
|
|
return { code: SubAppErr.PM_DETAIL_ERR, message: SubErrMsgs[SubAppErr.PM_DETAIL_ERR] };
|
|
case SubAppErr.UNPAID_ERR:
|
|
return { code: SubAppErr.UNPAID_ERR, message: SubErrMsgs[SubAppErr.UNPAID_ERR] };
|
|
case SubAppErr.RES_SUB_ERR:
|
|
return { code: opt?.extra || SubAppErr.RES_SUB_ERR, message: opt?.card ? SubErrMsgs[SubAppErr.RES_SUB_ERR]?.replace('#card#', `${opt?.card?.brand} ${SubTexts.ending} **** ${opt?.card?.last4}`) : SubErrMsgs[SubAppErr.RES_SUB_ERR_NO_CARD] };
|
|
case SubAppErr.PMT_METHOD_LIST_ERR:
|
|
return { code: SubAppErr.PMT_METHOD_LIST_ERR, message: SubErrMsgs[SubAppErr.PMT_METHOD_LIST_ERR] };
|
|
case SubAppErr.INC_ADDR_ERR:
|
|
return { code: SubAppErr.INC_ADDR_ERR, message: SubErrMsgs[SubAppErr.INC_ADDR_ERR] };
|
|
case SubAppErr.FETCH_DEFAULT_PM_ERR:
|
|
return { code: SubAppErr.FETCH_DEFAULT_PM_ERR, message: SubErrMsgs[SubAppErr.FETCH_DEFAULT_PM_ERR] };
|
|
case SubAppErr.FETCH_PM_ERR:
|
|
return { code: SubAppErr.FETCH_PM_ERR, message: SubErrMsgs[SubAppErr.FETCH_PM_ERR] };
|
|
case SUB.AC_REVIEW:
|
|
return { code: SUB.AC_REVIEW, message: opt?.msg || SubTexts.textReviewAC };
|
|
case SubAppErr.INC_CARD_ERR:
|
|
return { code: SubAppErr.INC_CARD_ERR, message: SubErrMsgs[SubAppErr.INC_CARD_ERR] };
|
|
case SubAppErr.AC_LIST_ERR:
|
|
return { code: SubAppErr.AC_LIST_ERR, message: SubErrMsgs[SubAppErr.AC_LIST_ERR] };
|
|
default:
|
|
return { code: SubAppErr._500_ERR, message: SubErrMsgs[SubAppErr._500_ERR] };
|
|
}
|
|
}
|