{"version":3,"sources":["constants/payment-information.constants.ts","component/reusables/formControls/token/token.tsx","models/promoCode-validation.model.ts","component/routes/enrollnow/payment-information/token-redemption/token-redemption.tsx","component/routes/enrollnow/payment-information/pidl/pidl.tsx","component/routes/enrollnow/payment-information/pidl/manage-pi-custom.tsx","component/routes/enrollnow/payment-information/pidl/handle-challenge.tsx","component/routes/enrollnow/payment-information/payment-information.tsx"],"names":["PAYMENT_OPTIONS","value","labelKey","PAYMENT_INFORMATION","HandlePaymentChallengeHeaders","HandlePaymentChallengeTestHeaders","AllowedPaymentMethods","PidlConfig","ManagePaymentInstrumentCustomConstants","errorMessages","pattern","FormControlToken","React","Component","constructor","arguments","_tokenRef","createRef","onValueChanged","event","target","this","props","onChange","getRef","current","render","showError","_jsx","TextBox","id","required","minLength","maxLength","REGEX_PATTERN","Token","placeholder","ref","errorKey","showErrorOn","undefined","TokenRedemptionResult","TokenRedemptionComponent","token","setToken","useState","isValidatingToken","setIsValidatingToken","isValidToken","setIsValidToken","validationMessage","setValidationMessage","_jsxs","_Fragment","children","Pipe","ResourcePipe","className","style","flex","tokenValue","Button","onClick","validatePromoCode","ProgramService","sellerId","programName","pipe","catchError","of","finalize","subscribe","tokenValidationResponse","isValid","getMessage","key","DistributorNotSupportedInCountry","DistributorNotSupportedForNonstudentAccount","DistributorNotSupportedForNonVerifiedStudentAccount","DistributorNotSupportedForVerificationMethod","tokenRedemptionResult","Loader","Verified","message","AlertError","defaultState","paymentFamily","paymentType","paymentInstrumentId","currentView","AllowedViews","SelectPaymentInstrument","showLoader","ManagePiCustomComponent","state","SelectPaymentInstrumentRef","isCreditCardExpired","pi","_window","window","pidlResourceHelpers","pidl","internal","utils","getFunctionExecutionResult","functionName","ResourceHelpersConstants","contextData","onFailure","errorObject","AppInsightUtility","logCustomEvent","IEventType","METHOD_CALL_END","onEditPiSuccess","paymentSession","setState","onAddPiCancel","setPaymentInstrumentId","paymentInstrument","onPiAddedHandler","onAddPiSuccess","params","addedPi","response","err","onSelectPISuccess","_params$paymentMethod","_params$paymentMethod2","resourceActionContext","action","SelectPaymentMethod","paymentMethodFamily","paymentMethodType","AddPaymentInstrument","resource","paymentMethod","EditPaymentInstrument","instance","onSelectPiEvent","eventName","parameters","_parameters$value","constants","eventNames","partnerAction","displayId","selectionChanged","propertyName","propertyValue","resourceSelected","resourceName","_parameters$value2","onSelectPaymentMethodSuccess","testHeaders","pidlData","country","partner","env","language","locale","authToken","busyBlockElement","size","fullScreen","elementFactory","prefillData","prefilledAddress","showSubmitBlock","headers","isProdEnvironment","telemetryOptions","pidlTelemetryOptions","billableAccountId","concat","allowedPaymentMethods","onSuccess","onEvent","completePrerequisites","onCancel","currentStep","HandleChallengeComponent","onSuccessHandlePaymentChallenge","challengeStatus","handleChallengeCompletedHandler","onFailureHandlePaymentChallenge","_errorObject$error","_serverError$InnerErr","_serverError$InnerErr2","serverError","error","innererror","displayErrorMessage","InnerError","Message","userMessage","UserDisplayMessage","onGoHomeHandlePaymentChallenge","handleChallengeReturnOptions","callbacks","failure","success","gohome","handleChallengeDisplayOptionsSelector","containerId","showPlaceholderInTextbox","HandlePaymentChallenge","paymentSessionOrData","piid","amount","currency","isLegacy","challengeScenario","challengeWindowSize","piCid","userContext","userId","additionalHeaders","returnOptions","displayOptions","windowsElementFactory","FluentUIElementFactory","Divider","createScope","reactInstance","theme","partnerCenterTheme","forReact","divider","PaymentInformationComponent","_ServerData$debugInfo","_ServerData$debugInfo2","PathUtility","getQueryParamByName","toLowerCase","authType","AccountUtility","isMsaAccount","AuthType","MSA","AAD","unsubscribe","Subject","setShowLoader","setCountry","accountType","setAccountType","setSellerId","setPaymentType","purchaseSubscriptionLoader","setPurchaseSubscriptionLoader","errorMessage","setErrorMessage","showWorkflowAcceptedMessage","setShowWorkflowAcceptedMessage","pidlAuthToken","setPidlAuthToken","isPaymentInstumentIdValid","setPaymentInstumentIdValid","paymentInstumentId","address","setAddress","handlePaymentChallenge","setHandlePaymentChallenge","setAmount","setCurrency","setBillableAccountId","correlationId","sessionTransactionId","referenceId","includes","IErrorCode","BILLING_E_PAYMENT_PROVIDER_DECLINE","TransformPipe","partnerName","sessionId","ServerData","debugInfo","cvInitValue","onPaymentModeChange","onTokenValidated","onPiSelected","isValidRequest","getWorkflowStatus","count","interval","switchMap","UnifiedEnrollmentService","takeWhile","wf","workflowStatus","WORKFLOW_STATUS_TYPE","Completed","location","href","EXTERNAL_ROUTES","DASHBOARD_HOME","Failed","lastErrorMessage","tap","useEffect","hasFlight","FLIGHT_NAME","EnableRpsLoginRedirect","rpsToken","fetchDelegateRpsToken","currentUrl","delegateRPSToken","url","urlParts","split","length","queryParams","i","indexOf","param","fetchDelegateRpsTokenFromUrl","updatedRedirectionUrl","rpsRedirectUrl","replace","encodeURIComponent","initializeResources","ProgramsUtility","isProgramFlightEnabled","forkJoin","SellerAccountService","getDeveloperProgramPreEnrollInfo","takeUntil","errorCode","details","_ref","accountInfo","workflowInfo","account","_accountInfo$account$","_accountInfo$account$2","_accountInfo$account$3","_accountInfo$commerce","_accountInfo$commerce2","_accountInfo$account$4","_accountInfo$account$5","_accountInfo$account$6","_accountInfo$account$7","_accountInfo$account$8","_accountInfo$account$9","_accountInfo$account$10","_accountInfo$account$11","_accountInfo$account$12","_accountInfo$account$13","_accountInfo$account$14","_accountInfo$account$15","_accountInfo$account$16","_accountInfo$account$17","identity","vettedAddress","countryCode","sellerCountryIsoCode","isPaymentSupported","commerceAccount","cpAccountId","first_name","vettedName","firstName","last_name","lastName","address_line1","addressLine1","address_line2","addressLine2","city","region","stateOrProvince","postal_code","postalCode","workflowSubStatus","WaitingForPayment","Navigation","navigate","INTERNAL_ROUTES","NOT_AUTHORIZED","next","complete","blockOperation","FlexPageWrapper","Header","title","Tooltip","showInfoIcon","tooltipText","role","map","option","index","Radio","checked","Switch","expression","cases","SwitchCaseModel","pidlEnvironment","EnvironmentUtility","RegistrationPrice","onPriceCalculated","price","totalPrice","onHandleChallengeCompleted","isFailure","MessageBar","messageBarType","MessageBarType","isM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AAgBC,IAAehN,QAC/BiN,aAAa,EAAKpW,SAEjBC,YAAKC,IAALD,CAAmB,4CAIzBkM,GAA8B7N,cAACqD,IAAM,IACtCrD,cAAA,UACE6B,UAAU,kBACVK,QA5Oe6V,KACvBjI,MACF9B,EAAgB,IAChBF,GAA8B,GAC9BqC,IAAyB4H,qBACvBzV,EACAvB,EACAwN,IAEChM,KACCC,YAAYyD,IACV+H,EACElL,GAAWmD,EAAI2M,UAAW3M,EAAI8I,cAAe9I,EAAI4M,QAAQ,KAE3D/E,GAA8B,GACvBrL,YAAG,SAGbE,UAAWqD,KACE,OAARA,QAAQ,IAARA,OAAQ,EAARA,EAAUiJ,cACZc,GAAkB,EAAW,OAAR/J,QAAQ,IAARA,OAAQ,EAARA,EAAUiJ,aAE1BjJ,KAGXgI,EAAgBrM,YAAKC,IAALD,CAAmB,wBAoNzBqW,SAAUnK,IAA+BiC,KAAiBpO,SAEzDC,YAAKC,IAALD,CAAmB,mDAUrBsW,mBAAWxL,K","file":"en-us/dashboard/account/exp/staticres/static/js/12.a2174da6.chunk.js","sourcesContent":["/**\r\n * @description the payment information component constants\r\n */\r\nimport { Dictionary } from \"../models/dictionary.model\";\r\n\r\nexport const PAYMENT_OPTIONS: Dictionary<string>[] = [\r\n { value: \"promo\", labelKey: \"Promo_Code_Title\" },\r\n { value: \"pidl\", labelKey: \"DebitOrCreditCard_Title\" },\r\n];\r\n\r\nexport const PAYMENT_INFORMATION = {\r\n TOKEN_PATTERN: \"XXXXX-XXXXX-XXXXX-XXXXX-XXXXX\",\r\n};\r\n\r\nexport const HandlePaymentChallengeHeaders = {\r\n \"x-ms-flight\": \"EnableThreeDSOne\",\r\n \"x-ms-test\": \"px-service-psd2-e2e-emulator\",\r\n}\r\n\r\nexport const HandlePaymentChallengeTestHeaders = {\r\n \"x-ms-flight\": \"EnableThreeDSOne\",\r\n \"x-ms-test\": \"px-service-psd2-e2e-emulator\",\r\n}\r\n\r\nexport const AllowedPaymentMethods: string[] =\r\n [\r\n \"credit_card.visa\",\r\n \"credit_card.mc\",\r\n ];\r\n\r\nexport const PidlConfig = {\r\n Resource_Type_PI: \"PaymentInstrument\",\r\n PIDL_Partner: \"payin\",\r\n Handle_Challenge_Scenario_Payment: \"PaymentTransaction\",\r\n Handle_Challenge_Scenario_Add_Card: \"AddCard\",\r\n Handle_Challenge_Window_Size_04: \"04\"\r\n}\r\n\r\nexport const ManagePaymentInstrumentCustomConstants = {\r\n NewPaymentMethodLink: \"newPaymentMethodLink\",\r\n PartnerAction: \"partnerAction\",\r\n HandleChallenge: \"handle-challenge-container\"\r\n}\r\n\r\nexport enum AllowedViews {\r\n SelectPaymentInstrument,\r\n SelectPaymentMethod,\r\n AddPaymentInstrument,\r\n EditPaymentInstrument,\r\n}","import React from \"react\";\r\nimport { REGEX_PATTERN } from \"../../../../constants\";\r\nimport { TextBox } from \"../../formElements\";\r\nimport { PAYMENT_INFORMATION } from \"../../../../constants/payment-information.constants\";\r\n\r\n/**\r\n * Props\r\n */\r\n\r\ntype IPropType = {\r\n onChange?: (value: string) => void;\r\n showError?: boolean;\r\n};\r\n\r\n/**\r\n * Error message\r\n */\r\nconst errorMessages = {\r\n pattern: \"CommonValidationError_InvalidToken\",\r\n};\r\n\r\nexport class FormControlToken extends React.Component<IPropType> {\r\n private _tokenRef: React.RefObject<TextBox> = React.createRef<TextBox>();\r\n\r\n private onValueChanged = (\r\n event?: React.ChangeEvent<HTMLInputElement>\r\n ): void => {\r\n if (!!event?.target.value && this.props.onChange) {\r\n this.props.onChange(event.target.value);\r\n }\r\n };\r\n\r\n render() {\r\n const { onChange, showError, ...props } = this.props;\r\n return (\r\n <TextBox\r\n id=\"token\"\r\n required={true}\r\n minLength={1}\r\n maxLength={29}\r\n pattern={REGEX_PATTERN.Token}\r\n placeholder={PAYMENT_INFORMATION.TOKEN_PATTERN}\r\n {...props}\r\n ref={this._tokenRef}\r\n errorKey={errorMessages}\r\n onChange={this.onValueChanged}\r\n showErrorOn={this.props.showError ? \"initial\" : undefined}\r\n ></TextBox>\r\n );\r\n }\r\n\r\n public getRef = (): TextBox | null => {\r\n return this._tokenRef.current;\r\n };\r\n}\r\n","export interface PromoCodeValidationRequest {\r\n sellerId: number;\r\n token: string;\r\n programName: string;\r\n}\r\n\r\nexport interface PromoCodeValidationResponse {\r\n isValid: boolean;\r\n tokenRedemptionResult: TokenRedemptionResult;\r\n validationMessage: string;\r\n}\r\n\r\nexport enum TokenRedemptionResult {\r\n Success,\r\n RedeemFailure,\r\n SellerStatusInvalid,\r\n SetPermissionFailure,\r\n TokenInvalid,\r\n TokenStateInvalid,\r\n UnexpectedOffers,\r\n Unknown,\r\n WriteTokenFailure,\r\n RolesAlreadyAppliedToSeller,\r\n RedeemedBySellerAlready,\r\n DistributorNotSupportedInCountry,\r\n DistributorNotSupportedForNonstudentAccount,\r\n DistributorNotSupportedForNonVerifiedStudentAccount,\r\n DistributorNotSupportedForVerificationMethod,\r\n}\r\n","import React, { useState } from \"react\";\r\nimport { catchError, finalize, of } from \"rxjs\";\r\nimport { Loader, Button, AlertError, Verified } from \"src/component/reusables\";\r\nimport { FormControlToken } from \"src/component/reusables/formControls/token\";\r\nimport { Pipe, ResourcePipe } from \"src/pipes\";\r\nimport { ProgramService } from \"src/services\";\r\nimport { TokenRedemptionResult } from \"../../../../../models/promoCode-validation.model\";\r\n\r\ntype IPropType = {\r\n sellerId: number;\r\n programName: string;\r\n onChange: (isValid: boolean, value: string) => void;\r\n};\r\n\r\nexport const TokenRedemptionComponent: React.FC<IPropType> = (props) => {\r\n const [token, setToken] = useState(\"\");\r\n const [isValidatingToken, setIsValidatingToken] = useState(false);\r\n const [isValidToken, setIsValidToken] = useState<boolean | null>(null);\r\n const [validationMessage, setValidationMessage] = useState<\r\n string | undefined\r\n >(undefined);\r\n\r\n const getMessage = (\r\n isValid: boolean,\r\n key: TokenRedemptionResult | undefined\r\n ) => {\r\n if (isValid === true) {\r\n return Pipe(ResourcePipe)(\"ValidToken\");\r\n } else {\r\n if (key !== undefined) {\r\n if (key === TokenRedemptionResult.DistributorNotSupportedInCountry) {\r\n return Pipe(ResourcePipe)(\"TokenInvalidCountryDistributor\");\r\n } else if (\r\n key ===\r\n TokenRedemptionResult.DistributorNotSupportedForNonstudentAccount\r\n ) {\r\n return Pipe(ResourcePipe)(\"TokenProgramNotVerified\");\r\n } else if (\r\n key ===\r\n TokenRedemptionResult.DistributorNotSupportedForNonVerifiedStudentAccount\r\n ) {\r\n return Pipe(ResourcePipe)(\"TokenProgramNotVerified\");\r\n } else if (\r\n key ===\r\n TokenRedemptionResult.DistributorNotSupportedForVerificationMethod\r\n ) {\r\n return (\r\n Pipe(ResourcePipe)(\"TokenVerificationMethodNotSupported\") +\r\n '<a target=\"_blank\" href=\"https://go.microsoft.com/fwlink/?linkid=826373\">' +\r\n Pipe(ResourcePipe)(\"Common_LearnMore\") +\r\n \"</a>\"\r\n );\r\n }\r\n }\r\n\r\n return Pipe(ResourcePipe)(\"Default_InvalidToken\");\r\n }\r\n };\r\n\r\n const updateTokenValue = (tokenValue: string) => {\r\n setToken(tokenValue);\r\n };\r\n\r\n const isValidRequest = () => {\r\n if (!!token) {\r\n return true;\r\n }\r\n return false;\r\n };\r\n\r\n const validatePromoCode = () => {\r\n if (isValidRequest()) {\r\n setIsValidToken(null);\r\n setIsValidatingToken(true);\r\n\r\n ProgramService.validatePromoCode(props.sellerId, token, props.programName)\r\n .pipe(\r\n catchError(() => of(null)),\r\n finalize(() => setIsValidatingToken(false))\r\n )\r\n .subscribe((tokenValidationResponse) => {\r\n var isValid =\r\n tokenValidationResponse == null\r\n ? false\r\n : tokenValidationResponse.isValid;\r\n setIsValidToken(isValid);\r\n setValidationMessage(\r\n getMessage(isValid, tokenValidationResponse?.tokenRedemptionResult)\r\n );\r\n props.onChange(isValid, token);\r\n });\r\n }\r\n };\r\n\r\n return (\r\n <>\r\n <h4>{Pipe(ResourcePipe)(\"Promo_Code_Title\")}</h4>\r\n <p>{Pipe(ResourcePipe)(\"Promo_Code_Subtitle\")}</p>\r\n <div className=\"flex-space-between\">\r\n <div style={{ flex: 0.9 }}>\r\n <FormControlToken onChange={updateTokenValue} />\r\n </div>\r\n <Button\r\n className=\"btn btn-texticon form-group\"\r\n onClick={validatePromoCode}\r\n >\r\n {Pipe(ResourcePipe)(\"Promo_Code_Apply\")}\r\n </Button>\r\n </div>\r\n {isValidatingToken && <Loader />}\r\n {isValidToken === true && <Verified message={validationMessage} />}\r\n {isValidToken === false && (\r\n <AlertError key={validationMessage}>{validationMessage}</AlertError>\r\n )}\r\n </>\r\n );\r\n};\r\n","import React from \"react\";\r\nimport { Switch, SwitchCaseModel, TestAttribute } from \"src/component/hoc\";\r\nimport { FlexCardContent, FlexCardView, FlexCardWrapper, Header, Loader } from \"src/component/reusables\";\r\nimport { Dictionary } from \"src/models\";\r\nimport { Pipe, ResourcePipe } from \"src/pipes\";\r\nimport { pidl, ManagePaymentInstrument, IManagePaymentInstrumentProps, ManagePiSuccessResponse, AddPaymentInstrument, SelectPaymentInstrument, SelectPaymentMethod, IElementFactory } from \"@cspayments/pidl-react\";\r\nimport { AllowedPaymentMethods, ManagePaymentInstrumentCustomConstants, PidlConfig } from \"../../../../../constants/payment-information.constants\";\r\nimport { initializeResources } from \"@cspayments/pidl-resource-helpers\";\r\nimport \"./pidl.module.scss\";\r\n\r\ntype IPropType = {\r\n country: any;\r\n locale: any;\r\n authToken: any;\r\n env: any;\r\n billableAccountId: any;\r\n prefilledAddress: any;\r\n elementFactory: IElementFactory;\r\n onPiAddedHandler: (isValid: boolean, value: string) => void;\r\n};\r\n\r\nconst defaultState = {\r\n currentStep: 0,\r\n showLoader: false,\r\n};\r\n\r\nlet selectedPi: any;\r\n\r\n\r\nconst testHeaders: any = {\r\n \"x-ms-flight\": \"UpdateNewPaymentMethodLinkActionContext\"\r\n};\r\n\r\nexport class PidlComponent extends React.Component<\r\n IPropType,\r\n typeof defaultState\r\n> { \r\n\r\n state = defaultState;\r\n\r\n private onPaymentInstrumentSelectedHandler = (show: any) => {\r\n console.log(\"onPaymentInstrumentSelectedHandler: \", show);\r\n }\r\n\r\n private onEventHandler = (show: any, parameters: any) => {\r\n console.log(\"onEventHandler: \", show, parameters);\r\n }\r\n\r\n private onFailureManagePIHandler = (errorObject: any) => {\r\n console.log(\"onFailureManagePIHandler: \", errorObject);\r\n }\r\n\r\n private onSuccessManagePIHandler = (paymentSession: any) => {\r\n selectedPi = paymentSession;\r\n console.log(\"onSuccessManagePIHandler:\", selectedPi);\r\n }\r\n\r\n baseStyleOverrides = {\r\n dropdown: {\r\n fontSize: 72,\r\n lineHeight: 200,\r\n height: 150,\r\n paddingVertical: 24,\r\n paddingHorizontal: 32,\r\n marginRight: 0,\r\n marginTop: 8,\r\n backgroundColor: \"rgba(45,49,51,0.96)\",\r\n color: \"rgba(255,255,255,0.64)\",\r\n fontWeight: \"bold\",\r\n shadowColor: \"rgba(0,0,0,0.25)\",\r\n shadowRadius: 6,\r\n shadowOffset: {\r\n width: 0,\r\n height: 2,\r\n },\r\n borderRadius: 8,\r\n borderWidth: 0,\r\n },\r\n };\r\n\r\n useEffect() {\r\n console.log(\"initializing pidl resources...\")\r\n initializeResources();\r\n console.log(\"initialized pidl resources\")\r\n }\r\n\r\n render() {\r\n return (\r\n <ManagePaymentInstrument\r\n country={this.props.country}\r\n partner={PidlConfig.PIDL_Partner}\r\n env={this.props.env}\r\n language={this.props.locale}\r\n allowedPaymentMethods={AllowedPaymentMethods}\r\n authToken={this.props.authToken}\r\n busyBlockElement={<Loader size=\"small\" fullScreen={false}></Loader>}\r\n elementFactory={this.props.elementFactory}\r\n showSubmitBlock={true}\r\n completePrerequisites={true}\r\n paymentInstrumentSelectedHandler={this.onPaymentInstrumentSelectedHandler}\r\n onSuccess={this.onSuccessManagePIHandler}\r\n onFailure={this.onFailureManagePIHandler}\r\n onEvent={this.onEventHandler}\r\n //onPageRendered={this.onPageRenderedHandler}\r\n //onEdit={this.onEditHandler}\r\n prefillData={this.props.prefilledAddress} \r\n headers={testHeaders}\r\n baseStyleOverrides={this.baseStyleOverrides}\r\n billableAccountId={this.props.billableAccountId}\r\n />\r\n );\r\n }\r\n\r\n}","import React from \"react\";\r\nimport { Loader } from \"src/component/reusables\";\r\nimport {\r\n pidl,\r\n ManagePiSuccessResponse,\r\n AddPaymentInstrument,\r\n SelectPaymentInstrument,\r\n SelectPaymentMethod,\r\n ResourceHelpersConstants,\r\n EditPaymentInstrument,\r\n IPaymentInstrumentInformation,\r\n IElementFactory,\r\n AllowedViews,\r\n} from \"@cspayments/pidl-react\";\r\nimport {\r\n AllowedPaymentMethods,\r\n ManagePaymentInstrumentCustomConstants,\r\n PidlConfig,\r\n} from \"../../../../../constants/payment-information.constants\";\r\nimport { IPaymentInstrument } from \"@cspayments/pidl-react/dist/lib/sdk/pidlDocumentTypes\";\r\nimport { AppInsightUtility } from \"../../../../../utility\";\r\nimport { IEventType } from \"../../../../../enum/IEventType\";\r\nimport { Pipe, ResourcePipe } from \"src/pipes\";\r\n\r\ntype IPropType = {\r\n country: any;\r\n locale: any;\r\n authToken: any;\r\n env: any;\r\n prefilledAddress: any;\r\n elementFactory: IElementFactory;\r\n billableAccountId: any;\r\n pidlTelemetryOptions: any;\r\n isProdEnvironment: boolean;\r\n onPiAddedHandler: (isValid: boolean, value: string) => void;\r\n};\r\n\r\nconst defaultState = {\r\n paymentFamily: \"\",\r\n paymentType: \"\",\r\n paymentInstrumentId: \"\",\r\n currentView: AllowedViews.SelectPaymentInstrument,\r\n showLoader: false,\r\n};\r\n\r\nconst CLASS_NAME = \"ManagePiCustomComponent\";\r\n\r\nexport class ManagePiCustomComponent extends React.Component<\r\n IPropType,\r\n typeof defaultState\r\n> {\r\n state = defaultState;\r\n private SelectPaymentInstrumentRef =\r\n React.createRef<SelectPaymentInstrument>();\r\n\r\n private isCreditCardExpired = (\r\n pi: pidl.pidlDocumentTypes.IPaymentInstrument\r\n ) => {\r\n // initializeResources() needs to be called from parent app.\r\n // App needs to include @cspayments/pidl-resource-helpers in bundle.\r\n if ((window as any)?.pidlResourceHelpers) {\r\n return pidl.internal.utils.getFunctionExecutionResult<\r\n pidl.pidlDocumentTypes.IPaymentInstrument,\r\n boolean\r\n >(\r\n { functionName: ResourceHelpersConstants.isCreditCardExpired },\r\n { contextData: pi }\r\n );\r\n }\r\n };\r\n\r\n private onFailure = (errorObject: any) => {\r\n AppInsightUtility.logCustomEvent(\r\n IEventType.METHOD_CALL_END,\r\n \"onFailure\",\r\n errorObject\r\n );\r\n };\r\n\r\n private onEditPiSuccess = (paymentSession: any) => {\r\n this.setState({\r\n currentView: AllowedViews.SelectPaymentInstrument,\r\n });\r\n };\r\n\r\n private onAddPiCancel = () => {\r\n this.setState({\r\n currentView: AllowedViews.SelectPaymentInstrument,\r\n });\r\n };\r\n\r\n private setPaymentInstrumentId = (\r\n paymentInstrument?: IPaymentInstrumentInformation | IPaymentInstrument\r\n ) => {\r\n if (paymentInstrument) {\r\n this.setState({\r\n paymentInstrumentId: paymentInstrument.id,\r\n });\r\n\r\n const { onPiAddedHandler } = this.props;\r\n onPiAddedHandler(true, paymentInstrument.id);\r\n }\r\n };\r\n\r\n private onAddPiSuccess = (params: any): void => {\r\n try {\r\n AppInsightUtility.logCustomEvent(\r\n IEventType.METHOD_CALL_END,\r\n \"onAddPiSuccess\",\r\n params\r\n );\r\n const addedPi =\r\n params.response as pidl.pidlDocumentTypes.IPaymentInstrument;\r\n this.setState({\r\n paymentInstrumentId: addedPi.id,\r\n currentView: AllowedViews.SelectPaymentInstrument,\r\n });\r\n this.setPaymentInstrumentId(addedPi);\r\n } catch (err) {\r\n this.setState({\r\n currentView: AllowedViews.SelectPaymentInstrument,\r\n });\r\n }\r\n };\r\n\r\n private onSelectPISuccess = (params: ManagePiSuccessResponse) => {\r\n if (params.resourceActionContext) {\r\n switch (params.resourceActionContext.action) {\r\n case \"selectResourceType\":\r\n this.setState({ currentView: AllowedViews.SelectPaymentMethod });\r\n break;\r\n case \"addResource\":\r\n this.setState({\r\n paymentFamily: params.paymentMethodFamily ?? \"\",\r\n paymentType: params.paymentMethodType ?? \"\",\r\n currentView: AllowedViews.AddPaymentInstrument,\r\n });\r\n break;\r\n case \"editPaymentInstrument\":\r\n this.setState({\r\n paymentFamily:\r\n params.resourceActionContext.resource.paymentMethod\r\n .paymentMethodFamily,\r\n paymentType:\r\n params.resourceActionContext.resource.paymentMethod\r\n .paymentMethodType,\r\n paymentInstrumentId: params.resourceActionContext.resource.id,\r\n currentView: AllowedViews.EditPaymentInstrument,\r\n });\r\n break;\r\n }\r\n return;\r\n }\r\n\r\n const { instance } = params;\r\n\r\n if (typeof instance !== \"string\") {\r\n if (this.isCreditCardExpired(instance)) {\r\n this.setState({\r\n currentView: AllowedViews.EditPaymentInstrument,\r\n paymentFamily: instance.paymentMethod.paymentMethodFamily,\r\n paymentType: instance.paymentMethod.paymentMethodType,\r\n paymentInstrumentId: instance.id,\r\n });\r\n }\r\n }\r\n };\r\n\r\n private onSelectPiEvent: pidl.PidlEventHandler = (\r\n eventName: string,\r\n parameters: any\r\n ) => {\r\n if (\r\n eventName === pidl.internal.constants.eventNames.partnerAction &&\r\n parameters?.displayId ===\r\n ManagePaymentInstrumentCustomConstants.NewPaymentMethodLink\r\n ) {\r\n this.setState({ currentView: AllowedViews.SelectPaymentMethod });\r\n }\r\n\r\n if (\r\n eventName === pidl.internal.constants.eventNames.selectionChanged &&\r\n this.state.currentView === AllowedViews.SelectPaymentInstrument &&\r\n parameters?.propertyName === \"paymentInstrumentId\" &&\r\n parameters?.propertyValue !== this.state.paymentInstrumentId\r\n ) {\r\n const { onPiAddedHandler } = this.props;\r\n onPiAddedHandler(true, parameters?.propertyValue);\r\n }\r\n else if (\r\n eventName === pidl.internal.constants.eventNames.resourceSelected &&\r\n this.state.currentView === AllowedViews.SelectPaymentInstrument &&\r\n parameters?.resourceName === \"paymentInstrumentId\" &&\r\n parameters?.value?.id !== this.state.paymentInstrumentId\r\n ) {\r\n const { onPiAddedHandler } = this.props;\r\n onPiAddedHandler(true, parameters?.value?.id);\r\n }\r\n };\r\n\r\n private onSelectPaymentMethodSuccess = (\r\n params: pidl.pidlDocumentTypes.IActionContext\r\n ) => {\r\n if (params && params.paymentMethodFamily && params.paymentMethodType) {\r\n this.setState({\r\n paymentFamily: params.paymentMethodFamily,\r\n paymentType: params.paymentMethodType,\r\n currentView: AllowedViews.AddPaymentInstrument,\r\n });\r\n }\r\n };\r\n\r\n testHeaders: any = {\r\n \"x-ms-test\": \"px-service-psd2-e2e-emulator\",\r\n };\r\n\r\n pidlData = {\r\n country: this.props.country,\r\n partner: PidlConfig.PIDL_Partner,\r\n env: this.props.env,\r\n language: this.props.locale,\r\n authToken: this.props.authToken,\r\n busyBlockElement: <Loader size=\"small\" fullScreen={false}></Loader>,\r\n elementFactory: this.props.elementFactory, // undefined, //\r\n prefillData: this.props.prefilledAddress,\r\n showSubmitBlock: true,\r\n headers: this.props.isProdEnvironment ? {} : this.testHeaders,\r\n telemetryOptions: this.props.pidlTelemetryOptions,\r\n parameters: {\r\n billableAccountId: `${this.props.billableAccountId}`,\r\n },\r\n };\r\n\r\n render() {\r\n return (\r\n <> \r\n <p className=\"spacer-md-bottom\">\r\n {Pipe(ResourcePipe)(\"Payment_Disclaimer_TotalChange\")}\r\n </p>\r\n {this.state.currentView === AllowedViews.SelectPaymentInstrument && (\r\n <SelectPaymentInstrument\r\n {...this.pidlData}\r\n allowedPaymentMethods={AllowedPaymentMethods}\r\n onSuccess={this.onSelectPISuccess}\r\n onFailure={this.onFailure}\r\n onEvent={this.onSelectPiEvent}\r\n ref={this.SelectPaymentInstrumentRef}\r\n />\r\n )}\r\n {this.state.currentView === AllowedViews.SelectPaymentMethod && (\r\n <SelectPaymentMethod\r\n {...this.pidlData}\r\n allowedPaymentMethods={AllowedPaymentMethods}\r\n onSuccess={this.onSelectPaymentMethodSuccess}\r\n onFailure={this.onFailure}\r\n />\r\n )}\r\n {this.state.currentView === AllowedViews.AddPaymentInstrument && (\r\n <AddPaymentInstrument\r\n {...this.pidlData}\r\n paymentFamily={this.state.paymentFamily}\r\n paymentType={this.state.paymentType}\r\n completePrerequisites={true}\r\n onSuccess={this.onAddPiSuccess}\r\n onFailure={this.onFailure}\r\n onCancel={this.onAddPiCancel}\r\n />\r\n )}\r\n {this.state.currentView === AllowedViews.EditPaymentInstrument && (\r\n <EditPaymentInstrument\r\n {...this.pidlData}\r\n paymentFamily={this.state.paymentFamily}\r\n paymentType={this.state.paymentType}\r\n paymentInstrumentId={this.state.paymentInstrumentId}\r\n onSuccess={this.onEditPiSuccess}\r\n onFailure={this.onFailure}\r\n />\r\n )}\r\n </>\r\n );\r\n }\r\n}\r\n","import React from \"react\";\r\nimport { Loader } from \"src/component/reusables\";\r\nimport { IElementFactory, HandlePaymentChallenge } from \"@cspayments/pidl-react\";\r\nimport {\r\n HandlePaymentChallengeHeaders,\r\n HandlePaymentChallengeTestHeaders,\r\n ManagePaymentInstrumentCustomConstants,\r\n PidlConfig,\r\n} from \"../../../../../constants/payment-information.constants\";\r\nimport { AppInsightUtility } from \"src/utility\";\r\nimport { IEventType } from \"src/enum/IEventType\";\r\n\r\ntype IPropType = {\r\n country: any;\r\n locale: any;\r\n authToken: any;\r\n env: any;\r\n elementFactory: IElementFactory;\r\n piid: string;\r\n amount: number;\r\n currency: string;\r\n billableAccountId: string;\r\n pidlTelemetryOptions: any;\r\n isProdEnvironment: boolean;\r\n handleChallengeCompletedHandler: (isFailure: boolean, errorMessage: any) => void;\r\n};\r\n\r\nconst defaultState = {\r\n currentStep: 0,\r\n showLoader: false,\r\n};\r\n\r\nexport class HandleChallengeComponent extends React.Component<IPropType, typeof defaultState> {\r\n state = defaultState;\r\n\r\n onSuccessHandlePaymentChallenge = (paymentSession: any) => {\r\n // Handle success returned by handlePaymentChallenge\r\n var challengeStatus = paymentSession?.challengeStatus;\r\n if (challengeStatus === \"Succeeded\") {\r\n // Challenge succeeded. Continue with purchase...\r\n // \"Succeeded\" indicates that either challenge was successfully completed by the user //OR the challenge is not required by the bank (i.e. frictionless flow)\r\n } else if (challengeStatus === \"ByPassed\") {\r\n // no challenge is needed as it is MOTO scenario. Continue with the purchase with MOTO\r\n } else if (challengeStatus === \"NotApplicable\") {\r\n // no challenge is needed for the market so continue with the purchase\r\n }\r\n\r\n AppInsightUtility.logCustomEvent(\r\n IEventType.METHOD_CALL_END,\r\n \"onSuccessHandlePaymentChallenge\",\r\n paymentSession\r\n );\r\n\r\n this.props.handleChallengeCompletedHandler(false, null);\r\n };\r\n\r\n onFailureHandlePaymentChallenge = (errorObject: any) => {\r\n var serverError = errorObject?.error?.innererror;\r\n var challengeStatus = serverError?.InnerError?.Message;\r\n\r\n var displayErrorMessage = \"Error.Add_PI\";\r\n var userMessage = serverError?.InnerError?.UserDisplayMessage;\r\n\r\n // Prepend any non-empty user message (that needs to be shown to the user) to the base error message\r\n if (userMessage !== undefined && userMessage !== null && userMessage !== \"\") {\r\n displayErrorMessage = `(${userMessage}) ${displayErrorMessage}`;\r\n }\r\n\r\n // Handle failure/error returned by handlePaymentChallenge\r\n if (challengeStatus === \"Failed\") {\r\n // challenge failed, purchase can't continue\r\n // display the 'userMessage' text on the screen if it not blank\r\n } else if (challengeStatus === \"TimedOut\") {\r\n // challenge timed out, purchase can't continue and display message to the user\r\n }\r\n\r\n AppInsightUtility.logCustomEvent(\r\n IEventType.METHOD_CALL_END,\r\n \"onFailureHandlePaymentChallenge\",\r\n errorObject\r\n );\r\n\r\n this.props.handleChallengeCompletedHandler(true, displayErrorMessage);\r\n };\r\n\r\n onGoHomeHandlePaymentChallenge = () => {\r\n // handle the cancel scenario\r\n //props?.goHomeCallBackMethod();\r\n };\r\n\r\n handleChallengeReturnOptions = {\r\n callbacks: {\r\n failure: this.onFailureHandlePaymentChallenge,\r\n success: this.onSuccessHandlePaymentChallenge,\r\n gohome: this.onGoHomeHandlePaymentChallenge,\r\n },\r\n };\r\n\r\n handleChallengeDisplayOptionsSelector = {\r\n containerId: ManagePaymentInstrumentCustomConstants.HandleChallenge,\r\n showPlaceholderInTextbox: true,\r\n };\r\n\r\n render() {\r\n return (\r\n <HandlePaymentChallenge\r\n env={this.props.env}\r\n elementFactory={this.props.elementFactory}\r\n paymentSessionOrData={{\r\n piid: this.props.piid,\r\n language: this.props.locale,\r\n amount: this.props.amount,\r\n currency: this.props.currency,\r\n country: this.props.country,\r\n isLegacy: true,\r\n partner: PidlConfig.PIDL_Partner,\r\n challengeScenario: PidlConfig.Handle_Challenge_Scenario_Payment as any,\r\n challengeWindowSize: PidlConfig.Handle_Challenge_Window_Size_04 as any,\r\n billableAccountId: this.props.billableAccountId,\r\n piCid: this.props.billableAccountId,\r\n }}\r\n userContext={{\r\n userId: \"me\",\r\n authToken: this.props.authToken,\r\n additionalHeaders: this.props.isProdEnvironment\r\n ? HandlePaymentChallengeHeaders\r\n : HandlePaymentChallengeTestHeaders,\r\n }}\r\n returnOptions={this.handleChallengeReturnOptions}\r\n displayOptions={this.handleChallengeDisplayOptionsSelector}\r\n busyBlockElement={<Loader size=\"small\" fullScreen={false}></Loader>}\r\n telemetryOptions={this.props.pidlTelemetryOptions}\r\n />\r\n );\r\n }\r\n}\r\n","/**\r\n * @description the enroll now route component for MSA\r\n */\r\nimport React, { useEffect, useState } from \"react\";\r\nimport { withRouter } from \"react-router\";\r\nimport {\r\n AlertError,\r\n FlexPageWrapper,\r\n Header,\r\n Loader,\r\n Radio,\r\n Tooltip,\r\n} from \"../../../reusables\";\r\nimport { ApiError, AuthType, Dictionary, IErrorCode } from \"../../../../models\";\r\nimport { Pipe, ResourcePipe, TransformPipe } from \"../../../../pipes\";\r\nimport { RegistrationPrice } from \"../../../shared\";\r\nimport {\r\n AccountUtility,\r\n EnvironmentUtility,\r\n PathUtility,\r\n ProgramsUtility,\r\n ServerData,\r\n} from \"../../../../utility\";\r\nimport {\r\n Subject,\r\n catchError,\r\n of,\r\n takeUntil,\r\n interval,\r\n switchMap,\r\n takeWhile,\r\n tap,\r\n forkJoin,\r\n} from \"rxjs\";\r\nimport {\r\n SellerAccountService,\r\n UnifiedEnrollmentService,\r\n} from \"../../../../services\";\r\nimport { Navigation } from \"../../router\";\r\nimport {\r\n EXTERNAL_ROUTES,\r\n FLIGHT_NAME,\r\n INTERNAL_ROUTES,\r\n WORKFLOW_STATUS_TYPE,\r\n} from \"../../../../constants\";\r\nimport {\r\n PAYMENT_OPTIONS,\r\n PidlConfig,\r\n} from \"../../../../constants/payment-information.constants\";\r\nimport { Switch, SwitchCaseModel } from \"src/component/hoc\";\r\nimport { TokenRedemptionComponent } from \"./token-redemption\";\r\nimport {\r\n createScope,\r\n divider,\r\n partnerCenterTheme,\r\n} from \"@harmony/enablers/react\";\r\nimport { MessageBar, MessageBarType, ThemeProvider } from \"@fluentui/react\";\r\nimport { ManagePiCustomComponent, PidlComponent } from \"./pidl\";\r\nimport { HandleChallengeComponent } from \"./pidl/handle-challenge\";\r\nimport { SubscriptionPrice } from \"src/models/subscription-price\";\r\nimport { initializeResources } from \"@cspayments/pidl-resource-helpers\";\r\nimport { FluentUIElementFactory } from \"@cspayments/pidl-fluent-ui\";\r\n\r\nconst windowsElementFactory = new FluentUIElementFactory();\r\n\r\nconst scope = createScope({\r\n reactInstance: React,\r\n theme: partnerCenterTheme,\r\n});\r\n\r\nconst Divider = scope.forReact(divider);\r\n\r\ntype IPropType = {\r\n history: any;\r\n location: any;\r\n};\r\n\r\nexport const PaymentInformationComponent: React.FC<IPropType> = (props) => {\r\n const programName =\r\n PathUtility.getQueryParamByName(\"programName\").toLowerCase();\r\n const authType = AccountUtility.isMsaAccount() ? AuthType.MSA : AuthType.AAD;\r\n\r\n const unsubscribe = new Subject<void>();\r\n const [showLoader, setShowLoader] = useState(true);\r\n const [country, setCountry] = useState(\"\");\r\n const [accountType, setAccountType] = useState(\"\");\r\n const [sellerId, setSellerId] = useState(0);\r\n const [paymentType, setPaymentType] = useState(PAYMENT_OPTIONS[0].value);\r\n const [token, setToken] = useState(\"\");\r\n const [isValidToken, setIsValidToken] = useState(false);\r\n const [purchaseSubscriptionLoader, setPurchaseSubscriptionLoader] =\r\n useState(false);\r\n const [errorMessage, setErrorMessage] = useState(\"\");\r\n const [showWorkflowAcceptedMessage, setShowWorkflowAcceptedMessage] =\r\n useState(false);\r\n const [pidlAuthToken, setPidlAuthToken] = useState(\"\");\r\n const [isPaymentInstumentIdValid, setPaymentInstumentIdValid] =\r\n useState(false);\r\n const [paymentInstumentId, setPaymentInstrumentId] = useState(\"\");\r\n const [address, setAddress] = useState<Dictionary<string>>({});\r\n const [handlePaymentChallenge, setHandlePaymentChallenge] = useState(false);\r\n const [amount, setAmount] = useState(0);\r\n const [currency, setCurrency] = useState(\"\");\r\n const [billableAccountId, setBillableAccountId] = useState(\"\");\r\n\r\n const getMessage = (\r\n key?: string,\r\n correlationId?: string,\r\n sessionTransactionId?: string,\r\n referenceId?: string\r\n ) => {\r\n if (key?.includes(IErrorCode.BILLING_E_PAYMENT_PROVIDER_DECLINE)) {\r\n return Pipe(ResourcePipe)(\"PaymentProviderDeclined_ErrorMessage\");\r\n } else if (correlationId) {\r\n return Pipe(ResourcePipe, TransformPipe)(\"Common_GenericError\", {\r\n correlationId: correlationId,\r\n });\r\n } else if (referenceId) {\r\n return Pipe(ResourcePipe, TransformPipe)(\"Common_GenericError_WithReferenceId\", {\r\n referenceId: referenceId,\r\n });\r\n }\r\n return Pipe(ResourcePipe)(\"SomethingWentWrong\");\r\n };\r\n\r\n const pidlTelemetryOptions = {\r\n contextData: {\r\n partnerName: PidlConfig.PIDL_Partner,\r\n sessionId: ServerData?.debugInfo?.sessionId,\r\n cvInitValue: ServerData?.debugInfo?.correlationId,\r\n },\r\n };\r\n\r\n const switchScenarios = () => {\r\n return [\r\n new SwitchCaseModel(\r\n (\r\n <TokenRedemptionComponent\r\n sellerId={sellerId}\r\n programName={programName}\r\n onChange={onTokenValidated}\r\n />\r\n ),\r\n PAYMENT_OPTIONS[0].value\r\n ),\r\n\r\n new SwitchCaseModel(\r\n (\r\n <ManagePiCustomComponent\r\n country={country}\r\n locale={ServerData.locale}\r\n authToken={pidlAuthToken}\r\n env={ServerData.pidlEnvironment}\r\n prefilledAddress={address}\r\n elementFactory={windowsElementFactory}\r\n billableAccountId={billableAccountId}\r\n pidlTelemetryOptions={pidlTelemetryOptions}\r\n isProdEnvironment={EnvironmentUtility.isProdEnvironment()}\r\n onPiAddedHandler={onPiSelected}\r\n />\r\n ),\r\n // <PidlComponent\r\n // country={\"gb\"} // {country}\r\n // locale={ServerData.locale}\r\n // authToken={pidlAuthToken}\r\n // env={ServerData.pidlEnvironment}\r\n // prefilledAddress={address}\r\n // elementFactory={windowsElementFactory}\r\n // onPiAddedHandler={onPiSelected}\r\n // billableAccountId={billableAccountId}\r\n // />\r\n PAYMENT_OPTIONS[1].value\r\n ),\r\n ];\r\n };\r\n\r\n const onPaymentModeChange = (event: React.ChangeEvent<HTMLInputElement>) => {\r\n setPaymentType(event.target.value);\r\n setToken(\"\");\r\n setIsValidToken(false);\r\n setPaymentInstrumentId(\"\");\r\n setPaymentInstumentIdValid(false);\r\n setPurchaseSubscriptionLoader(false);\r\n setErrorMessage(\"\");\r\n setShowWorkflowAcceptedMessage(false);\r\n };\r\n\r\n const onTokenValidated = (isValid: boolean, value: string) => {\r\n setIsValidToken(isValid);\r\n setToken(isValid ? value : \"\");\r\n };\r\n\r\n const onPiSelected = (isValid: boolean, value: string) => {\r\n setPaymentInstumentIdValid(false); // reset flag ; to be set by handle challenge\r\n setHandlePaymentChallenge(false);\r\n setPaymentInstrumentId(value);\r\n setHandlePaymentChallenge(isValid);\r\n };\r\n\r\n const onPriceCalculated = (price: SubscriptionPrice) => {\r\n setAmount(price.totalPrice);\r\n setCurrency(price.currency);\r\n setHandlePaymentChallenge(true);\r\n };\r\n\r\n const onHandleChallengeCompleted = (\r\n isFailure: boolean,\r\n errorMessage: any\r\n ) => {\r\n if (isFailure) {\r\n setPaymentInstrumentId(\"\");\r\n setPaymentInstumentIdValid(false);\r\n setErrorMessage(errorMessage);\r\n } else {\r\n setPaymentInstumentIdValid(true);\r\n }\r\n };\r\n\r\n const getAccountInfo = () => {\r\n forkJoin([\r\n SellerAccountService.getDeveloperProgramPreEnrollInfo(programName, true),\r\n UnifiedEnrollmentService.getWorkflowStatus(undefined, programName).pipe(\r\n catchError(() => of(null))\r\n ),\r\n ])\r\n .pipe(\r\n takeUntil(unsubscribe),\r\n catchError((err: ApiError) => {\r\n setErrorMessage(\r\n getMessage(err.errorCode, err.correlationId, err.details[0])\r\n );\r\n return of([]);\r\n })\r\n )\r\n .subscribe(([accountInfo, workflowInfo]) => {\r\n if (accountInfo?.account) {\r\n setSellerId(accountInfo.account.id);\r\n setCountry(\r\n accountInfo.account.identity?.vettedAddress?.countryCode ??\r\n accountInfo.account.sellerCountryIsoCode\r\n );\r\n setAccountType(accountInfo.account.accountType);\r\n const isPaymentSupported = ProgramsUtility.isPaymentSupported(\r\n programName,\r\n authType,\r\n accountInfo.account.accountType\r\n );\r\n setBillableAccountId(accountInfo.commerceAccount?.cpAccountId ?? \"\");\r\n setAddress({\r\n first_name: accountInfo.account.identity?.vettedName?.firstName,\r\n last_name: accountInfo.account.identity?.vettedName?.lastName,\r\n address_line1:\r\n accountInfo.account.identity?.vettedAddress?.addressLine1,\r\n address_line2:\r\n accountInfo.account.identity?.vettedAddress?.addressLine2,\r\n city: accountInfo.account.identity?.vettedAddress?.city,\r\n region:\r\n accountInfo.account.identity?.vettedAddress?.stateOrProvince,\r\n postal_code:\r\n accountInfo.account.identity?.vettedAddress?.postalCode,\r\n });\r\n\r\n if (\r\n isPaymentSupported &&\r\n workflowInfo?.workflowSubStatus ===\r\n WORKFLOW_STATUS_TYPE.WaitingForPayment\r\n ) {\r\n setShowLoader(false);\r\n return;\r\n }\r\n }\r\n\r\n Navigation.navigate(props, INTERNAL_ROUTES.NOT_AUTHORIZED);\r\n });\r\n };\r\n\r\n const isValidRequest = () => {\r\n if (isValidToken || isPaymentInstumentIdValid) {\r\n return true;\r\n }\r\n return false;\r\n };\r\n\r\n const purchaseSubscription = () => {\r\n if (isValidRequest()) {\r\n setErrorMessage(\"\");\r\n setPurchaseSubscriptionLoader(true);\r\n UnifiedEnrollmentService.purchaseSubscription(\r\n programName,\r\n token,\r\n paymentInstumentId\r\n )\r\n .pipe(\r\n catchError((err: ApiError) => {\r\n setErrorMessage(\r\n getMessage(err.errorCode, err.correlationId, err.details[0])\r\n );\r\n setPurchaseSubscriptionLoader(false);\r\n return of(null);\r\n })\r\n )\r\n .subscribe((response: any) => {\r\n if (response?.referenceId) {\r\n getWorkflowStatus(8, response?.referenceId);\r\n }\r\n return response;\r\n });\r\n } else {\r\n setErrorMessage(Pipe(ResourcePipe)(\"Common_FillDetails\"));\r\n return;\r\n }\r\n };\r\n\r\n const getWorkflowStatus = (count: number, referenceId: string): void => {\r\n const retryInterval = 30000; //30 second delay between retry attempts\r\n interval(retryInterval)\r\n .pipe(\r\n switchMap(() =>\r\n UnifiedEnrollmentService.getWorkflowStatus(referenceId)\r\n ),\r\n takeWhile((wf) => {\r\n if (count === 0) {\r\n setPurchaseSubscriptionLoader(false); // Make loader disappear\r\n setShowWorkflowAcceptedMessage(true); // Show wf accepted banner\r\n return false;\r\n } else if (\r\n wf != null &&\r\n wf.workflowStatus.toLowerCase() ===\r\n WORKFLOW_STATUS_TYPE.Completed.toLowerCase()\r\n ) {\r\n window.location.href = EXTERNAL_ROUTES.DASHBOARD_HOME;\r\n return false;\r\n } else if (\r\n wf != null &&\r\n wf.workflowStatus.toLowerCase() ===\r\n WORKFLOW_STATUS_TYPE.Failed.toLowerCase()\r\n ) {\r\n setPurchaseSubscriptionLoader(false);\r\n setErrorMessage(\r\n getMessage(wf.lastErrorMessage, undefined, undefined, referenceId)\r\n );\r\n return false;\r\n } else {\r\n return true;\r\n }\r\n }),\r\n tap(() => {\r\n count -= 1;\r\n })\r\n )\r\n .subscribe();\r\n };\r\n\r\n const fetchDelegateRpsTokenFromUrl = (url: string) => {\r\n // Parse the url and get the access_token value\r\n // Sample Url\r\n // https://partner.microsoft-tst.com/en-us/dashboard/account/exp/enrollment/payment?programName=AppDev#access_token=Ewabc&token_type=bearer&expires_in=86400&scope=PIFD.Read%20PIFD.Create%20PIFD.Update\r\n\r\n var urlParts = url.split(\"#\");\r\n if (urlParts && urlParts.length > 1) {\r\n // Get the query params\r\n var queryParams = urlParts[1].split(\"&\");\r\n if (queryParams && queryParams.length > 1) {\r\n for (var i = 0; i < queryParams.length; i++) {\r\n // Get the query param having access_token\r\n if (queryParams[i].indexOf(\"access_token\") > -1) {\r\n var param = queryParams[i].split(\"=\");\r\n if (param && param.length > 1) {\r\n return param[1];\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n return null;\r\n };\r\n\r\n const fetchDelegateRpsToken = () => {\r\n var currentUrl = window.location.href;\r\n if (currentUrl) {\r\n // Parse the url and get the delegate access_token value\r\n var delegateRPSToken = fetchDelegateRpsTokenFromUrl(currentUrl);\r\n if (delegateRPSToken) {\r\n delegateRPSToken = \"MSADELEGATE1.0 \" + delegateRPSToken;\r\n return delegateRPSToken;\r\n }\r\n\r\n // Perform redirection to get the delegate rps token\r\n var redirectionUrl = ServerData.rpsRedirectUrl;\r\n var updatedRedirectionUrl = redirectionUrl.replace(\r\n \"{redirect_uri}\",\r\n encodeURIComponent(currentUrl)\r\n );\r\n window.location.href = updatedRedirectionUrl;\r\n }\r\n\r\n return null;\r\n };\r\n\r\n useEffect(() => {\r\n if (ServerData.hasFlight(FLIGHT_NAME.EnableRpsLoginRedirect)) {\r\n let rpsToken = fetchDelegateRpsToken();\r\n if (rpsToken) {\r\n setPidlAuthToken(rpsToken);\r\n }\r\n }\r\n\r\n initializeResources();\r\n\r\n if (programName && ProgramsUtility.isProgramFlightEnabled(programName)) {\r\n getAccountInfo();\r\n } else {\r\n Navigation.navigate(props, INTERNAL_ROUTES.NOT_AUTHORIZED);\r\n }\r\n\r\n return () => {\r\n unsubscribe.next();\r\n unsubscribe.complete();\r\n };\r\n }, []);\r\n\r\n return (\r\n <>\r\n {showLoader ? (\r\n <Loader size=\"large\" fullScreen={true} blockOperation={true} />\r\n ) : (\r\n <FlexPageWrapper>\r\n <Header title={Pipe(ResourcePipe)(\"Common_Registration_Payment\")} />\r\n <p className=\"section-subtitle spacer-xxs-top\">\r\n {Pipe(ResourcePipe)(\"Common_Registration_Payment_Subtitle\")}\r\n </p>\r\n\r\n <div className=\"flex spacer-sm-top\">\r\n <h3 className=\"font-weight-bold\">\r\n {Pipe(ResourcePipe)(\"Common_Payment_Details\")}\r\n </h3>\r\n <Tooltip\r\n className=\"spacer-xxs-left\"\r\n showInfoIcon={true}\r\n tooltipText={Pipe(ResourcePipe)(\"Common_PaymentDetails_ToolTip\")}\r\n />\r\n </div>\r\n <h4 className=\"spacer-sm-top\">\r\n {Pipe(ResourcePipe)(\"Common_Payment_Type\")}\r\n </h4>\r\n\r\n <fieldset role=\"radiogroup\" className=\"flex\">\r\n {PAYMENT_OPTIONS.map((option: Dictionary<string>, index) => {\r\n return (\r\n <Radio\r\n key={option.value}\r\n id={`address-option-${index}`}\r\n className=\"spacer-xs-right\"\r\n checked={paymentType === option.value}\r\n value={option.value}\r\n onChange={onPaymentModeChange}\r\n >\r\n {Pipe(ResourcePipe)(option.labelKey)}\r\n </Radio>\r\n );\r\n })}\r\n </fieldset>\r\n\r\n <Switch expression={paymentType} cases={switchScenarios()} />\r\n\r\n {!!(accountType && country) && (\r\n <div className=\"spacer-ml-top\">\r\n <RegistrationPrice\r\n accountType={accountType}\r\n country={country}\r\n programName={programName}\r\n sellerId={sellerId}\r\n token={token}\r\n paymentInstrumentId={paymentInstumentId}\r\n onPriceCalculated={onPriceCalculated}\r\n />\r\n </div>\r\n )}\r\n\r\n {handlePaymentChallenge &&\r\n paymentInstumentId &&\r\n amount > 0 &&\r\n currency && (\r\n <HandleChallengeComponent\r\n country={country}\r\n locale={ServerData.locale}\r\n authToken={pidlAuthToken}\r\n env={ServerData.pidlEnvironment}\r\n elementFactory={windowsElementFactory}\r\n piid={paymentInstumentId}\r\n amount={amount}\r\n currency={currency}\r\n billableAccountId={billableAccountId}\r\n pidlTelemetryOptions={pidlTelemetryOptions}\r\n isProdEnvironment={EnvironmentUtility.isProdEnvironment()}\r\n handleChallengeCompletedHandler={onHandleChallengeCompleted}\r\n />\r\n )}\r\n\r\n <div className=\"spacer-ml-top\">\r\n <Divider />\r\n <div className=\"flex-space-between spacer-ms-top\">\r\n <div style={{ flex: 0.9 }}>\r\n {errorMessage && (\r\n <AlertError key={errorMessage}>{errorMessage}</AlertError>\r\n )}\r\n {showWorkflowAcceptedMessage && (\r\n <MessageBar\r\n messageBarType={MessageBarType.success}\r\n isMultiline={true}\r\n >\r\n {Pipe(ResourcePipe)(\"WorkflowAcceptedConfirmationMessage\")}\r\n </MessageBar>\r\n )}\r\n </div>\r\n {purchaseSubscriptionLoader && <Loader />}\r\n <button\r\n className=\"btn btn-primary\"\r\n onClick={purchaseSubscription}\r\n disabled={purchaseSubscriptionLoader || !isValidRequest()}\r\n >\r\n {Pipe(ResourcePipe)(\"Common_RegistrationPayment_Button\")}\r\n </button>\r\n </div>\r\n </div>\r\n </FlexPageWrapper>\r\n )}\r\n </>\r\n );\r\n};\r\n\r\nexport default withRouter(PaymentInformationComponent as any);\r\n"],"sourceRoot":""}