{"version":3,"sources":["lib/contingencyResolver.js","components/CheckoutButton/query.gql.js","components/GiveAtCheckout/Mutation/query.gql.js","components/CheckoutButton/utils.js","components/CheckoutButton/Button.js","lib/creditButtonHelper.js","components/SplitTender/utils.js"],"names":["contingencyResolver","contingencyFlow","paymentContingencies","confirmCreditCardCvvData","sepaMandateAcceptanceNeeded","threeDomainSecure","threeDSContingencyData","needConsentForBankAccountInfoRetrieval","needRealTimeBalanceForBankAccount","strongCustomerAuthenticationRequired","selectedFundingOption","selectedFundingOptionId","currencyCode","creditFinancingOption","inClearCreditOptionFlow","hasGPLFundingInstrument","contingencyLogger","noop","contextId","action","logger","fpti","SCA_CONTINGENCY_PAYLOAD","isObject","encryptedId","CVV_CONTINGENCY_PAYLOAD","currency_code","THREE_DS_PAYLOAD","resolution","paymentCard","id","from","to","selected_funding_option_id","SEPA_CONTINGENCY_PAYLOAD","fi_id","isPayNowUserActionFlow","CPA_PAYLOAD","selectedFundingOptionFinancingCode","fundingInstrument","creditFields","creditOffer","financingCode","CLEAR_CREDIT_OPTION_PAYLOAD","credit_option_financing_code","selected_fi_financing_code","definitions","names","filter","definition","kind","name","value","CHECKOUT_BUTTON_QUERY","FundingOptionFragment","CreditOfferFragment","PaymentContingenciesFragment","approvePaymentMutation","approveSuggestedDonationMutation","resolveContingencies","approveMemberPaymentVariables","updateFeatures","visible","data","showWidget","token","getToken","status","CHECKOUT_BUTTON_STATES","PENDING","inContingencyFlow","logApprovePayment","cartTotal","cryptocurrencyHoldingDetails","cryptocurrencyQuote","currencyValue","errorCode","fundingMethodType","isGplOffer","preferredShippingAddressId","rewardsPayload","secondaryFundingOptionIds","selectedAddressId","selectedInstallmentOption","selectedPlan","selectedTab","setStickyFiRequired","shouldHideCart","totalIncentivesAmount","userId","viewName","selectedFundingInstrument","splitBalancePlan","getSplitBalancePlan","getSplitBalanceFundingSourceFromPlan","splitBalanceFiId","splitBalanceFiType","type","fiId","length","fiType","get","fiName","rewards","chosenFundingOption","getFptiFundingOptionType","cryptocurrencyPayloadItems","isCryptoFundingInstrument","cart_show_amt","undefined","amount","cart_show_curr","asset_price_with_spread","assetPrice","asset_price_wo_spread","fixed_fee_amt","fee_amt","fulfil_amt","fulfil_qty","quantity","asset_symbol","symbol","order_fiat_amt","order_by","op_nm","incentivesCurrencyCode","incentivesCurrencyValue","TRANSITION_PAYLOAD","int_err_code","buyer_country","getCountry","set_sticky_fi_required","currencyConversionFpti","fi_type","fi_name","chosen_funding_option","funding_method_type","shipping_id","preferrred_shipping_address","installment_option","term","rewardsFpti","rewardAmount","button_type","entry_point","view_name","offer_value","cal","transition","LOG_TRANSITIONS","PROCESS_REVIEW","window","PAYPAL","analytics","instance","recordClick","page","link","fltk","cust","amt","ccpg","curr","CheckoutButton","className","useQuery","variables","threeDsExperienceVars","creditPpcOffersGqlParams","fetchPolicy","useButtonFeature","checkoutButtonLabelOverride","checkoutButtonStatus","checkoutSessionType","creditOfferAsFI_DE","fundingOptions","giveAtCheckoutNonProfitId","giveAtCheckoutOpted","hasPPCreditInstallments","inOpenBankingFlow","installments","isDonation","isDonationEligible","isIncentivePresent","isOpenBankingEnabled","merchantName","previousCheckoutButtonStatus","scaCompleted","shareAddressWithDonatee","splitTenderData","userAction","validShippingMethod","payLaterContext","usePayLaterContext","payContext","usePayContext","getQuote","useCryptoQuoteContext","payState","balanceId","continueButtonAction","creditFIOption","preferredFundingOptionId","usePayAfterDelivery","useSplitBalance","defaultPreferredFi","billingAgreement","isBillingAgreement","getIsPayNowUserActionFlow","useIsButtonDisabled","loading","Boolean","checkoutSession","isButtonDisabled","setIsButtonDisabled","isCryptoFI","isInstallmentsFeatureEnabled","eligible","enabled","installmentsFeatureData","availableInstallments","findInstallmentsInPlan","getSelectedInstallmentOption","useViewName","useCart","total","shouldUseGplButtonText","useGplButtonTextOnFinalRyi","useButtonLogging","mapCreditPPCOffer","creditPPCOffers","onClickCreditOffer","useOnClickCreditOffer","creditButtonText","isPpcFi","isPaypalCreditFundingInstrument","isPpcReuse","isPPCReuse","isInstallment","isInstallmentCreditType","content","OfferType","payLaterState","checkoutButtonText","uiElements","creditFI","payButtonText","continueButtonText","getContent","getCreditCheckoutButtonData","approvePayment","useMutation","approveDonation","approvePaymentSplitTender","SPLIT_TENDER_APPROVE_MUTATION","handleGiveAtCheckout","GAC_PAYLOAD","gac_npid","then","info","catch","error","approveMemberPayment","isAutoResolved","checkoutButtonStartTime","Date","now","defaultSelectedFI","getDefaultSelectedFundingInstrument","isDefaultFISelected","is_default_fi_selected","isOfferSelected","params","euat","redirectToLogin","updateFeature","display","message","getSelectedFundingSource","fi","plan","shouldOpenInstallmentInterstitial","Array","isArray","creditOfferType","shouldRedirectToCyco","creditType","isCreditWithAdditionalData","isCryptoAbleToCoverTransaction","handleInsufficientBalanceError","isPpcOfferAcq","processPpcOffer","openSelectInstallmentsInterstitial","fId","isInstallmentSelected","selectedInstallmentMap","isIframe","fallback","reason","preAuthorizationRequired","preAuthorizationData","rewardSelected","authType","isPreAuthRequired","REVIEW_CPA_PAYLOAD","client_epoch_ts","getPreAuthorizationRequired","handleMultiOfferContinueButtonAction","processGplOffer","hasOnlyIncentives","isSingleFundingOptionByType","getFundingSourceFromPlanByType","getSecondaryFundingOptionIds","checkRealTimeBalance","clearCreditFinancingOption","fundingSources","find","fundingSource","groupedSources","approvePaymentVariables","parseFloat","currency","installmentToInstallmentsInput","cryptocurrencyQuoteId","update","store","approveMemberPaymentResult","buyer","paymentState","state","hasPaymentContingencies","some","contingency","ERROR_PAYLOAD","code","CheckoutError","Error","buyer_id","completedPaymentInfo","returnToMerchantAfterApprove","approveMemberPaymentResultPayload","useEffect","RESOLVED","flow","buttonText","isDECreditOfferAsFiSelected","isString","getPadPlan","number","getPadNumberOfDelayedDays","isGPLFundingInstrument","cryptoName","label","payNowContent","continueContent","getButtonText","data-testid","toLowerCase","data-disabled","onClick","isSplitReady","errorsOccurrenceCount","splitFundingOptions","_splitFundingOptions","selectedSplitFundingInstruments","selectedBackupFundingInstrument","_types","PAYPAL_BALANCE","CREDIT_CARD","BANK_ACCOUNT","PAYPAL_CREDIT","getSplitOptionsAndBackup","fundingOption","map","instrument","isPrimaryInstrument","fundingInstrumentType","toNumber","logApprovePaymentPrepare","showSplitTenderError","approveMemberPaymentWithSplitFundingOptions","logApprovePaymentProcess","shipping_address_id","preferred_shipping_address","logApprovePaymentError","resetSplitTenderData","userCanSplit","showSplitContinue","showSplitExperience","getEligibleForPrimaryFiIdList","isEligibleForPrimaryInstrument","isSplitTenderActive","SplitTenderGate","experiment","resolvedTreatment","backupFi"],"mappings":"4FAAA,qDAmBaA,EAAsB,SAAC,GAgBxB,IAAD,YACLC,EADK,aAAP,GAAO,MAfTC,qBAeS,gBAPL,GAOK,GAdPC,gCAcO,MAdoB,GAcpB,MAbPC,mCAaO,MAbuB,GAavB,MAZPC,yBAYO,MAZa,GAYb,MAXPC,8BAWO,MAXkB,GAWlB,MAVPC,8CAUO,MAVkC,GAUlC,MATPC,yCASO,MAT6B,GAS7B,MARPC,4CAQO,MARgC,GAQhC,EANTC,EAMS,EANTA,sBACAC,EAKS,EALTA,wBACAC,EAIS,EAJTA,aACAC,EAGS,EAHTA,sBACAC,EAES,EAFTA,wBACAC,EACS,EADTA,wBAGIC,EAAoBC,IAGxB,OAAIR,QAAJ,IAAIA,KAAsCS,YACxCjB,EAAkB,sBAClBe,EAAoB,8BAA0C,GAA1C,GAAGG,cAAH,MAAY,0BAAZ,SAClBC,SAAOC,KAAKF,EAAQG,kCAAwB,CAAEH,cAKhDR,GACAY,YAASpB,IACTA,EAAyBqB,cAAgBb,IAEzCV,EAAkB,mBAClBe,EAAoB,8BAA4B,GAA5B,GAAGG,cAAH,MAAY,YAAZ,SAClBC,SAAOC,KAAKF,EAAQM,kCAAwB,CAAEN,SAAQO,cAAed,OAKvED,GACAY,YAASlB,IACTA,EAAkBmB,cAAgBb,IAElCV,EAAkB,wBAClBe,EAAoB,8BAAgC,GAAhC,GAAGG,cAAH,MAAY,gBAAZ,SAClBC,SA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components/CheckoutButton/Button~21833f8f.5d6818de.js","sourcesContent":["import { logger } from '@paypalcorp/c3-util-logger';\nimport { isObject, noop } from '@paypalcorp/c3-util-lang';\nimport {\n CVV_CONTINGENCY_PAYLOAD,\n THREE_DS_PAYLOAD,\n SEPA_CONTINGENCY_PAYLOAD,\n CPA_PAYLOAD,\n SCA_CONTINGENCY_PAYLOAD,\n CLEAR_CREDIT_OPTION_PAYLOAD,\n} from '@paypalcorp/c3-util-logger';\n\n/**\n * @param {Object} option\n * @param {Object} option.paymentContingencies | CheckoutSession.paymentContingencies\n * @param {String} option.selectedFundingOptionId | Selected funding instrument id\n * @returns {Object} Return the contingencyFlow and its associated contingencyLogger function\n * @example\n * const { contingencyFlow, contingencyLogger } = contingencyResolver({ ... });\n */\nexport const contingencyResolver = ({\n paymentContingencies: {\n confirmCreditCardCvvData = {},\n sepaMandateAcceptanceNeeded = {},\n threeDomainSecure = {}, // 3DS (1.0)\n threeDSContingencyData = {}, // 3DS (2.0)\n needConsentForBankAccountInfoRetrieval = {},\n needRealTimeBalanceForBankAccount = {},\n strongCustomerAuthenticationRequired = {},\n } = {},\n selectedFundingOption,\n selectedFundingOptionId,\n currencyCode,\n creditFinancingOption,\n inClearCreditOptionFlow,\n hasGPLFundingInstrument,\n} = {}) => {\n let contingencyFlow;\n let contingencyLogger = noop;\n\n // Resolve sca contingency\n if (strongCustomerAuthenticationRequired?.contextId) {\n contingencyFlow = 'REVIEW_BEFORE_LOGIN';\n contingencyLogger = ({ action = 'renderReviewBeforeLogin' } = {}) =>\n logger.fpti(action, SCA_CONTINGENCY_PAYLOAD({ action }));\n }\n\n // Resolve cvv contingency\n if (\n selectedFundingOptionId &&\n isObject(confirmCreditCardCvvData) &&\n confirmCreditCardCvvData.encryptedId === selectedFundingOptionId\n ) {\n contingencyFlow = 'CVV_CONFIRMATION';\n contingencyLogger = ({ action = 'renderCvv' } = {}) =>\n logger.fpti(action, CVV_CONTINGENCY_PAYLOAD({ action, currency_code: currencyCode }));\n }\n\n // Resolve 3DS (1.0) contingency use case\n if (\n selectedFundingOptionId &&\n isObject(threeDomainSecure) &&\n threeDomainSecure.encryptedId === selectedFundingOptionId\n ) {\n contingencyFlow = 'THREE_DS_CONFIRMATION';\n contingencyLogger = ({ action = 'renderThreeDS' } = {}) =>\n logger.fpti(action, THREE_DS_PAYLOAD({ action, currency_code: currencyCode }));\n }\n\n // Resolve 3DS (2.0) contingency use case\n if (\n selectedFundingOptionId &&\n isObject(threeDSContingencyData) &&\n threeDSContingencyData.resolution &&\n selectedFundingOptionId === threeDSContingencyData.resolution?.paymentCard?.id\n ) {\n contingencyFlow = 'THREE_DS_TWO_CONFIRMATION';\n contingencyLogger = ({ action = 'prepareThreeDs_v2' } = {}) =>\n logger.fpti(action, {\n from: 'review',\n to: 'render_threeds_v2',\n currency_code: currencyCode,\n selected_funding_option_id: selectedFundingOptionId,\n });\n }\n\n // Resolve SEPA mandate contingency\n if (\n selectedFundingOptionId &&\n isObject(sepaMandateAcceptanceNeeded) &&\n sepaMandateAcceptanceNeeded.id === selectedFundingOptionId\n ) {\n contingencyFlow = 'SEPA_CONFIRMATION';\n contingencyLogger = ({ action = 'renderSepa' } = {}) =>\n logger.fpti(\n action,\n SEPA_CONTINGENCY_PAYLOAD({\n action,\n currency_code: currencyCode,\n fi_id: selectedFundingOptionId,\n })\n );\n }\n\n // Resolve Open OpenBanking needConsentForBankAccountInfoRetrieval contingency\n if (\n selectedFundingOptionId &&\n isObject(needConsentForBankAccountInfoRetrieval) &&\n needConsentForBankAccountInfoRetrieval.encryptedId === selectedFundingOptionId\n ) {\n contingencyFlow = 'OPEN_BANKING';\n contingencyLogger = ({ action = 'prepareRtb', isPayNowUserActionFlow } = {}) =>\n logger.fpti(\n 'NEED_CONSENT_INTERSTITIAL_RENDER',\n CPA_PAYLOAD({ action, fi_id: selectedFundingOptionId, isPayNowUserActionFlow })\n );\n }\n\n // Resolve Open OpenBanking needRealTimeBalanceForBankAccount contingency\n if (\n selectedFundingOptionId &&\n isObject(needRealTimeBalanceForBankAccount) &&\n needRealTimeBalanceForBankAccount.encryptedId === selectedFundingOptionId\n ) {\n contingencyFlow = 'NEED_RTB';\n contingencyLogger = ({ action = 'prepareRtbCheck' } = {}) =>\n logger.fpti(\n 'NEED_REAL_TIME_BALANCE',\n CPA_PAYLOAD({ action, fi_id: selectedFundingOptionId })\n );\n }\n\n // Clear credit financing option if financingCode of\n // selectedFI does not match the one in CheckoutSession\n const selectedFundingOptionFinancingCode =\n selectedFundingOption?.fundingInstrument?.creditFields?.creditOffer?.financingCode ?? null;\n\n if (\n !inClearCreditOptionFlow &&\n creditFinancingOption?.financingCode &&\n selectedFundingOptionFinancingCode !== creditFinancingOption?.financingCode &&\n hasGPLFundingInstrument\n ) {\n contingencyFlow = 'CLEAR_CREDIT_OPTION';\n contingencyLogger = ({ action = 'processClearCreditOption' } = {}) =>\n logger.fpti(\n action,\n CLEAR_CREDIT_OPTION_PAYLOAD({\n action,\n fi_id: selectedFundingOptionId,\n credit_option_financing_code: creditFinancingOption?.financingCode,\n selected_fi_financing_code: selectedFundingOptionFinancingCode,\n })\n );\n }\n\n return {\n contingencyFlow,\n contingencyLogger,\n };\n};\n","import gql from 'graphql-tag';\nimport {\n FundingOptionFragment,\n PaymentContingenciesFragment,\n} from '@paypalcorp/c3-graphql-fragments';\nimport { CreditOfferFragment } from '@/components/CreditOffer';\n\nexport const CHECKOUT_BUTTON_QUERY = gql`\n ${FundingOptionFragment}\n ${CreditOfferFragment}\n ${PaymentContingenciesFragment}\n query CheckoutButton(\n $areCookiesDisabled: Boolean\n $experiences: [ThreeDSPaymentExperience]\n $isIframe: Boolean\n $token: String!\n ) {\n checkoutSession(token: $token) {\n cart {\n amounts {\n total {\n currencyValue\n currencyCode\n }\n }\n category\n }\n fundingOptions(returnAllPlans: true, groupSourcesOnType: INCENTIVE) {\n ...FundingOptionFragment\n }\n creditPPCOffers(areCookiesDisabled: $areCookiesDisabled, isIframe: $isIframe) {\n ...CreditOfferFragment\n }\n flags {\n hasPPCreditInstallments\n hideShipping\n isIncentivePresent\n isOptionallyShareAddress\n }\n merchant {\n name\n }\n paymentContingencies {\n ...PaymentContingenciesFragment\n threeDomainSecure(experiences: $experiences) {\n ...ThreeDomainSecureFields\n }\n }\n creditFinancingOption {\n creditType\n financingCode\n }\n userAction\n checkoutSessionType\n buyer {\n userId\n }\n }\n }\n`;\n\nexport const approvePaymentMutation = gql`\n ${PaymentContingenciesFragment}\n mutation approveMemberPayment(\n $token: String!\n $selectedAddressId: String\n $preferredShippingAddressId: String\n $selectedFundingOptionId: String!\n $preferredFundingOptionId: String\n $secondaryFundingOptionIds: [String!]\n $selectedInstallmentOption: InstallmentsInput\n $rewards: RewardsInput\n $preAuthorizationRequired: Boolean\n $fundingMethodType: FundingInstrumentMethodType\n $shareAddressWithDonatee: Boolean\n $setStickyFiRequired: Boolean\n $scaCompleted: Boolean!\n $experiences: [ThreeDSPaymentExperience]\n $cryptocurrencyQuoteId: String\n ) {\n approveMemberPayment(\n token: $token\n selectedAddressId: $selectedAddressId\n preferredShippingAddressId: $preferredShippingAddressId\n primaryFundingOptionId: $selectedFundingOptionId\n preferredFundingOptionId: $preferredFundingOptionId\n secondaryFundingOptionIds: $secondaryFundingOptionIds\n selectedInstallmentOption: $selectedInstallmentOption\n rewards: $rewards\n preAuthorizationRequired: $preAuthorizationRequired\n fundingMethodType: $fundingMethodType\n shareAddressWithDonatee: $shareAddressWithDonatee\n setStickyFiRequired: $setStickyFiRequired\n strongCustomerAuthenticationCompleted: $scaCompleted\n cryptocurrencyQuoteId: $cryptocurrencyQuoteId\n ) {\n state\n buyer {\n userId\n email {\n stringValue\n }\n name {\n fullName\n }\n }\n cart {\n intent\n paymentId\n billingToken\n returnUrl {\n href\n pathname\n }\n cancelUrl {\n href\n pathname\n }\n intent\n items {\n quantity\n name\n sku\n unitPrice {\n currencyValue\n }\n itemOptionSelections {\n name\n description\n }\n }\n amounts {\n subtotal {\n currencyCode\n currencyFormat\n }\n tax {\n currencyCode\n currencyFormat\n }\n shipping {\n currencyCode\n currencyFormat\n }\n insurance {\n currencyCode\n currencyFormat\n }\n handlingFee {\n currencyCode\n currencyFormat\n }\n total {\n currencyCode\n currencyFormat\n }\n discount {\n currencyCode\n currencyFormat\n }\n }\n }\n paymentContingencies {\n ...PaymentContingenciesFragment\n threeDomainSecure(experiences: $experiences) {\n ...ThreeDomainSecureFields\n }\n }\n completedPaymentInfo {\n transactionId\n transactionState\n softDescriptor\n postbackData\n }\n merchant {\n preferences {\n autoReturnToMerchant\n enablePaymentDataTransfer\n returnUrl\n }\n }\n }\n }\n`;\n","import gql from 'graphql-tag';\n\nexport const approveSuggestedDonationMutation = gql`\n mutation approveSuggestedDonation($token: String!) {\n approveSuggestedDonation(token: $token)\n }\n`;\n","import get from 'dlv';\nimport {\n LOG_TRANSITIONS,\n logger,\n REVIEW_CPA_PAYLOAD,\n TRANSITION_PAYLOAD,\n} from '@paypalcorp/c3-util-logger';\nimport { currencyConversionFpti } from '@/components/CurrencyConversion/fpti';\nimport { rewardsFpti } from '@/components/Rewards/utilities';\nimport getContent from '@/lib/content';\nimport { getFptiFundingOptionType } from '@/lib/fpti';\nimport { getCountry, getToken } from '@paypalcorp/c3-shared-globals';\nimport { isString } from '@paypalcorp/c3-util-lang';\nimport {\n getFundingSourceFromPlanByType,\n getSplitBalanceFundingSourceFromPlan,\n getSplitBalancePlan,\n isCryptoFundingInstrument,\n isSingleFundingOptionByType,\n updateFeatures,\n getPadPlan,\n getPadNumberOfDelayedDays,\n} from '@paypalcorp/c3-util-store';\nimport { CHECKOUT_BUTTON_STATES } from './constants';\nimport { isCreditWithAdditionalData, isGPLFundingInstrument } from '@/lib/creditInstallmentsHelper';\n\n/**\n * Get if pre auth is required\n * @param {Object} rewardsPayload rewards data\n * @param {Object} preAuthorizationData preauth data\n * @param {Boolean} isPayNowUserActionFlow if we're in the Pay Now state\n */\nexport function getPreAuthorizationRequired(\n rewardsPayload,\n preAuthorizationData,\n isPayNowUserActionFlow\n) {\n /**\n * Establish rewards to determine for preAuth Requirement\n *\n * NOTE:\n * Currently, Rewards in planning does not come with preAuth. this could\n * eventually change as preAuth's could soon be coming back from planning\n * as `true` even with Rewards.\n *\n * For now, preAuth should be false when there's a reward\n */\n if (rewardsPayload.rewardSelected) {\n return false;\n }\n\n if (preAuthorizationData) {\n const { authType } = preAuthorizationData;\n const isPreAuthRequired = authType === 'FULL' || authType === 'PARTIAL';\n\n if (isPreAuthRequired) {\n logger.fpti(\n 'CPA_REVIEW',\n REVIEW_CPA_PAYLOAD({\n action: 'preparePreAuth',\n client_epoch_ts: Date.now(),\n isPayNowUserActionFlow,\n })\n );\n }\n return isPreAuthRequired;\n }\n\n return false;\n}\n\n/**\n * Get the secondary funding option IDs\n * @param {Array} fundingOptions funding options\n * @param {Boolean} isIncentivePresent if an incentive is shown\n * @param {Object} selectedPlan the selected plan\n * @param {Boolean} useSplitBalance if we're using split balance\n * @param {Array} allBalanceIds the balance IDs from split balance\n */\nexport function getSecondaryFundingOptionIds(\n fundingOptions,\n isIncentivePresent,\n selectedPlan,\n useSplitBalance,\n balanceId\n) {\n const secondaryFundingOptionIds = useSplitBalance ? [balanceId] : [];\n const hasOnlyIncentives = isSingleFundingOptionByType({ fundingOptions, type: 'INCENTIVE' });\n\n if (isIncentivePresent && !hasOnlyIncentives) {\n const { fundingInstrument: { id } = {} } = getFundingSourceFromPlanByType({\n plan: selectedPlan,\n type: 'INCENTIVE',\n });\n\n return [...secondaryFundingOptionIds, id].filter(Boolean);\n }\n\n return secondaryFundingOptionIds;\n}\n\n/**\n * Get the Checkout Button text\n */\nexport function getButtonText({\n availableInstallments,\n checkoutButtonLabelOverride,\n creditOfferAsFI_DE = {},\n creditButtonText,\n isDonation,\n isPayNowUserActionFlow,\n selectedInstallmentOption,\n billingAgreement,\n selectedFundingOption,\n usePayAfterDelivery,\n}) {\n const setStickyFiRequired = !isCreditWithAdditionalData(\n selectedFundingOption?.fundingInstrument?.name || '',\n selectedFundingOption?.fundingInstrument?.type || ''\n );\n\n if (creditButtonText) {\n if (!billingAgreement || setStickyFiRequired) {\n return creditButtonText;\n }\n }\n\n const { data: { isDECreditOfferAsFiSelected, continueButtonText } = {} } = creditOfferAsFI_DE;\n\n if (isDECreditOfferAsFiSelected) {\n return continueButtonText;\n }\n\n if (checkoutButtonLabelOverride && isString(checkoutButtonLabelOverride)) {\n return checkoutButtonLabelOverride;\n }\n\n if (Boolean(availableInstallments) && !Boolean(selectedInstallmentOption)) {\n return getContent('installments.selectButtonText');\n }\n\n if (Boolean(getPadPlan(selectedFundingOption)) && usePayAfterDelivery) {\n return getContent('checkoutButton.continueWithPad', {\n number: getPadNumberOfDelayedDays(selectedFundingOption),\n });\n }\n\n if (\n billingAgreement &&\n // Don't show \"Agree & Continue\" for GPL products\n !isGPLFundingInstrument(selectedFundingOption?.fundingInstrument)\n ) {\n return isPayNowUserActionFlow\n ? getContent('checkoutButton.ba.agreePayNow')\n : getContent('checkoutButton.ba.agreeContinue');\n }\n\n if (isDonation) {\n return isPayNowUserActionFlow\n ? getContent('checkoutButton.donateNow')\n : getContent('checkoutButton.continue');\n }\n\n if (isCryptoFundingInstrument(selectedFundingOption?.fundingInstrument)) {\n const cryptoName = selectedFundingOption?.fundingInstrument?.label;\n\n return getContent('crypto.sellAndContinue', {\n cryptoName,\n });\n }\n\n const payNowContent = getContent('checkoutButton.payNow');\n const continueContent = getContent('checkoutButton.continue');\n return isPayNowUserActionFlow ? payNowContent : continueContent;\n}\n\n/**\n * Resolve any payment related contingency before triggering the `approvePayment` mutation\n * @param {String} contingencyFlow the contingency flow to go thru\n * @param {Object} approveMemberPaymentVariables approve payment payload\n * @param {Function} contingencyLogger log contingency to FPTI\n */\nexport function resolveContingencies(contingencyFlow, approveMemberPaymentVariables) {\n return updateFeatures([\n {\n id: contingencyFlow,\n visible: true,\n data: {\n ...(contingencyFlow === 'REVIEW_BEFORE_LOGIN' ? { showWidget: true } : {}),\n approveMemberPaymentVariables: { token: getToken(), ...approveMemberPaymentVariables },\n },\n },\n // Set `CHECKOUT_BUTTON` status to `PENDING`\n {\n id: 'CHECKOUT_BUTTON',\n data: { status: CHECKOUT_BUTTON_STATES.PENDING, inContingencyFlow: true },\n },\n ]);\n}\n\n/**\n * Log data when approving the payment\n * @param {Object} data data to log\n */\nexport function logApprovePayment({\n cartTotal,\n cryptocurrencyHoldingDetails,\n cryptocurrencyQuote,\n currencyCode,\n currencyValue,\n errorCode,\n fundingMethodType,\n isGplOffer = false,\n preferredShippingAddressId = '',\n rewardsPayload,\n secondaryFundingOptionIds,\n selectedAddressId,\n selectedFundingOption,\n selectedFundingOptionId,\n selectedInstallmentOption,\n selectedPlan,\n selectedTab,\n setStickyFiRequired,\n shouldHideCart,\n totalIncentivesAmount,\n userId,\n viewName,\n} = {}) {\n /*\n * We need to retrieve fi_id and fi_type correctly when we have SPLIT BALANCE and\n * concatenate those values in csv format for better logging. Otherwise,\n * we just display Id and Type from main FI.\n *\n * Example Split Balance:\n * fi_type:CREDIT_CARD,PAYPAL_BALANCE\n * fi_id:CC-YP9NVE23DZS44,BALANCEUSD\n *\n * Example 1 FI selected:\n * fi_type:CREDIT_CARD\n * fi_id:CC-YP9NVE23DZS44\n */\n const selectedFundingInstrument = selectedFundingOption?.fundingInstrument;\n const splitBalancePlan = getSplitBalancePlan(selectedFundingOption) || {};\n const { fundingInstrument: { id: splitBalanceFiId, type: splitBalanceFiType } = {} } =\n getSplitBalanceFundingSourceFromPlan(splitBalancePlan) || {};\n const fiId =\n secondaryFundingOptionIds?.length > 0 && splitBalanceFiId\n ? `${selectedFundingOptionId}, ${splitBalanceFiId}`\n : selectedFundingOptionId;\n const fiType =\n secondaryFundingOptionIds?.length > 0 && splitBalanceFiType\n ? `${get(selectedFundingOption, 'fundingInstrument.type')}, ${splitBalanceFiType}`\n : get(selectedFundingOption, 'fundingInstrument.type');\n const fiName = get(selectedFundingOption, 'fundingInstrument.name');\n const { fundingInstrument: { rewards } = {} } = selectedFundingOption || {};\n const chosenFundingOption = getFptiFundingOptionType(selectedFundingInstrument);\n const cryptocurrencyPayloadItems = isCryptoFundingInstrument(selectedFundingInstrument)\n ? {\n cart_show_amt: !shouldHideCart ? cartTotal?.amount : undefined,\n cart_show_curr: !shouldHideCart ? cartTotal?.currencyCode : undefined,\n asset_price_with_spread: cryptocurrencyQuote?.assetPrice?.currencyValue,\n asset_price_wo_spread: cryptocurrencyQuote?.assetPrice?.currencyValue,\n // Currently there are no fees for pay with crypto in checkout\n fixed_fee_amt: 0,\n fee_amt: 0,\n fulfil_amt: cartTotal?.amount,\n fulfil_qty: cryptocurrencyQuote?.quantity,\n asset_symbol: cryptocurrencyHoldingDetails?.symbol,\n order_fiat_amt: cartTotal?.amount,\n order_by: 'FIAT_VALUE',\n op_nm: 'crypto_sell_with_xo',\n }\n : {};\n const { currencyCode: incentivesCurrencyCode, currencyValue: incentivesCurrencyValue } =\n totalIncentivesAmount || {};\n\n logger.fpti(\n 'approvePayment',\n TRANSITION_PAYLOAD({\n from: 'REVIEW',\n to: 'process_review',\n int_err_code: errorCode,\n currency_code: currencyCode,\n buyer_country: getCountry(),\n set_sticky_fi_required: setStickyFiRequired,\n ...currencyConversionFpti({ selectedPlan, action: 'process_review' }),\n fi_id: fiId,\n fi_type: fiType,\n fi_name: fiName,\n chosen_funding_option: chosenFundingOption,\n funding_method_type: fundingMethodType,\n ...{\n shipping_id: selectedAddressId,\n preferrred_shipping_address: preferredShippingAddressId === selectedAddressId ? 1 : 0,\n },\n installment_option: selectedInstallmentOption ? selectedInstallmentOption.term : undefined,\n ...rewardsFpti(rewards, rewardsPayload?.rewardAmount),\n button_type: isGplOffer ? 'pay_in_four' : 'regular',\n entry_point: selectedTab,\n view_name: viewName,\n ...cryptocurrencyPayloadItems,\n ...(totalIncentivesAmount && {\n offer_value: `${incentivesCurrencyValue} ${incentivesCurrencyCode}`,\n }),\n })\n );\n logger.cal.transition(LOG_TRANSITIONS.PROCESS_REVIEW);\n if (!errorCode) {\n if (window.PAYPAL?.analytics?.instance) {\n window.PAYPAL.analytics.instance.recordClick({\n data: {\n page: 'main:xo:lite:hermione:member:review',\n link: 'process_review',\n fltk: getToken(),\n cust: userId,\n amt: currencyValue,\n ccpg: getCountry(),\n curr: currencyCode,\n chosen_funding_option: chosenFundingOption,\n },\n });\n }\n }\n}\n","import React, { useEffect } from 'react';\nimport { useQuery, useMutation } from '@apollo/react-hooks';\nimport { useCryptoQuoteContext } from '@paypalcorp/c3-context-providers';\nimport { usePayLaterContext, usePayContext } from '@/components/ContextProviders';\nimport { isCreditWithAdditionalData } from '@/lib/creditInstallmentsHelper';\n\nimport {\n logger,\n ERROR_PAYLOAD,\n GAC_PAYLOAD,\n REVIEW_CPA_PAYLOAD,\n TRANSITION_PAYLOAD,\n} from '@paypalcorp/c3-util-logger';\nimport { getCountry, getToken } from '@paypalcorp/c3-shared-globals';\nimport { isIframe } from '@paypalcorp/c3-util-browser';\nimport {\n updateFeature,\n getSelectedFundingSource,\n getDefaultSelectedFundingInstrument,\n isCryptoFundingInstrument,\n} from '@paypalcorp/c3-util-store';\nimport CheckoutError from '@/lib/checkoutError';\nimport { useViewName } from '@/lib/fpti';\nimport { isPaypalCreditFundingInstrument, params, isInstallmentCreditType } from '@/lib/utils';\nimport { fallback, redirectToLogin, returnToMerchantAfterApprove } from '@/lib/redirects';\nimport { contingencyResolver } from '@/lib/contingencyResolver';\nimport { getIsPayNowUserActionFlow } from '@/lib/userAction';\nimport getCreditCheckoutButtonData from '@/lib/creditButtonHelper';\nimport { checkRealTimeBalance } from '@/lib/fiBalance';\n\nimport { CHECKOUT_BUTTON_STATES } from './constants';\nimport { approvePaymentMutation } from './query.gql';\nimport {\n handleInsufficientBalanceError,\n isCryptoAbleToCoverTransaction,\n} from '@/components/Crypto';\nimport { approveSuggestedDonationMutation } from '@/components/GiveAtCheckout/Mutation/query.gql';\nimport { useButtonFeature, useIsButtonDisabled, useButtonLogging } from './hooks';\nimport {\n getPreAuthorizationRequired,\n getSecondaryFundingOptionIds,\n getButtonText,\n resolveContingencies,\n logApprovePayment,\n} from './utils';\nimport { Button } from '@paypalcorp/pp-react-buttons';\nimport {\n findInstallmentsInPlan,\n getSelectedInstallmentOption,\n installmentToInstallmentsInput,\n openSelectInstallmentsInterstitial,\n} from '@/components/Installments/utilities';\nimport { isBillingAgreement } from '@/lib/checkoutSession';\nimport { useCart } from '@/components/Cart/hooks';\nimport { mapCreditPPCOffer } from '@/components/CreditOffer/utils';\nimport { useOnClickCreditOffer } from '@/components/CreditOffer/hooks';\nimport { CHECKOUT_BUTTON_QUERY } from './query.gql';\nimport { SPLIT_TENDER_APPROVE_MUTATION } from '@/components/SplitTender/query.gql';\nimport { toNumber } from '@paypalcorp/c3-util-lang';\nimport {\n approvePaymentPrepare as logApprovePaymentPrepare,\n approvePaymentProcess as logApprovePaymentProcess,\n approvePaymentError as logApprovePaymentError,\n} from '@/components/SplitTender/logging';\nimport { getSplitOptionsAndBackup } from '@/components/SplitTender/utils';\nimport getContent from '@/lib/content';\nimport { creditPpcOffersGqlParams, clearCreditFinancingOption } from '@/lib/credit';\nimport { threeDsExperienceVars } from '@paypalcorp/c3-util-threed-ds';\nimport { useGplButtonTextOnFinalRyi } from '@/components/PayLater/Multi/hooks';\nimport { handleMultiOfferContinueButtonAction } from '@/components/PayLater/Multi/utils';\n\nexport default function CheckoutButton({ className }) {\n const { data } = useQuery(CHECKOUT_BUTTON_QUERY, {\n variables: {\n ...threeDsExperienceVars({ token: getToken() }),\n ...creditPpcOffersGqlParams(),\n },\n fetchPolicy: 'cache-only',\n });\n const {\n checkoutButtonLabelOverride,\n checkoutButtonStatus,\n checkoutSessionType,\n creditFinancingOption,\n creditOfferAsFI_DE,\n currencyCode,\n currencyValue,\n fundingOptions,\n giveAtCheckoutNonProfitId,\n giveAtCheckoutOpted,\n hasPPCreditInstallments,\n inContingencyFlow,\n inOpenBankingFlow,\n inClearCreditOptionFlow,\n installments,\n isDonation,\n isDonationEligible,\n isIncentivePresent,\n isOpenBankingEnabled,\n merchantName,\n paymentContingencies,\n preferredShippingAddressId,\n previousCheckoutButtonStatus,\n rewardsPayload,\n scaCompleted,\n selectedAddressId,\n shareAddressWithDonatee,\n splitTenderData,\n userAction,\n userId,\n validShippingMethod,\n } = useButtonFeature(data);\n const payLaterContext = usePayLaterContext();\n const payContext = usePayContext();\n const { getQuote } = useCryptoQuoteContext();\n const {\n balanceId,\n continueButtonAction,\n creditFIOption,\n preferredFundingOptionId,\n selectedFundingOptionId,\n selectedTab,\n usePayAfterDelivery,\n useSplitBalance,\n } = payContext.payState;\n const { selectedFundingOption, selectedPlan, defaultPreferredFi, hasGPLFundingInstrument } =\n payContext;\n const selectedFundingInstrument = selectedFundingOption?.fundingInstrument;\n const billingAgreement = isBillingAgreement(checkoutSessionType);\n const isPayNowUserActionFlow = getIsPayNowUserActionFlow(userAction);\n const [isButtonDisabled, setIsButtonDisabled] = useIsButtonDisabled({\n // cache-only queries resolve immediately even if there's no data\n // so check for the presence of the data we are expecting instead\n loading: !Boolean(data?.checkoutSession),\n inContingencyFlow,\n });\n const isCryptoFI = isCryptoFundingInstrument(selectedFundingInstrument);\n const cryptocurrencyHoldingDetails = selectedFundingInstrument?.cryptocurrencyHoldingDetails;\n const isInstallmentsFeatureEnabled = installments.eligible && installments.enabled;\n const installmentsFeatureData = installments?.data;\n const availableInstallments = isInstallmentsFeatureEnabled\n ? findInstallmentsInPlan(selectedFundingOptionId, selectedPlan)\n : null;\n const selectedInstallmentOption = isInstallmentsFeatureEnabled\n ? getSelectedInstallmentOption(selectedFundingOptionId, installmentsFeatureData)\n : null;\n const viewName = useViewName();\n const { shouldHideCart, total: cartTotal } = useCart();\n const shouldUseGplButtonText = useGplButtonTextOnFinalRyi(creditFIOption);\n // We will attempt to get the crypto quote from context. It is possible that this\n // will fail and we will either get nothing, or an expired quote ID. In these cases we\n // should defer to approveMemberPayment for error handling.\n const cryptocurrencyQuote = isCryptoFI ? getQuote(cryptocurrencyHoldingDetails?.symbol) : null;\n\n useButtonLogging({\n checkoutSession: data?.checkoutSession,\n currencyCode,\n defaultPreferredFi,\n isButtonDisabled,\n isPayNowUserActionFlow,\n selectedFundingOption,\n selectedPlan,\n });\n\n const creditOffer =\n mapCreditPPCOffer({ creditPPCOffers: data?.checkoutSession?.creditPPCOffers }) || {};\n const { onClickCreditOffer } = useOnClickCreditOffer({\n creditOffer,\n });\n\n const { creditButtonText } = getCreditCheckoutButtonData({\n creditFIOption,\n creditOfferAsFI_DE,\n isPayNowUserActionFlow,\n payLaterContext,\n payContext,\n selectedFundingOptionId,\n shouldUseGplButtonText,\n creditOffer,\n });\n\n const [approvePayment] = useMutation(approvePaymentMutation, {\n variables: threeDsExperienceVars(),\n });\n\n const [approveDonation] = useMutation(approveSuggestedDonationMutation);\n const [approvePaymentSplitTender] = useMutation(SPLIT_TENDER_APPROVE_MUTATION);\n\n const handleGiveAtCheckout = () => {\n if (giveAtCheckoutOpted) {\n logger.fpti(\n 'GIVE_AT_CHECKOUT',\n GAC_PAYLOAD({ action: 'processGAC', gac_npid: giveAtCheckoutNonProfitId })\n );\n\n return approveDonation({ variables: { token: getToken() } })\n .then(() => logger.cal.info('APPROVE_SUGGESTED_DONATION_CALL_SUCCESS'))\n .catch((error) => logger.cal.error('APPROVE_SUGGESTED_DONATION_ERROR', error));\n }\n };\n\n function approveMemberPaymentSplitTender() {\n const {\n errorsOccurrenceCount = 0,\n splitFundingOptions: _splitFundingOptions = [],\n selectedSplitFundingInstruments = [],\n selectedBackupFundingInstrument,\n } = splitTenderData;\n const _types = {\n PAYPAL_BALANCE: 'BALANCE',\n CREDIT_CARD: 'CARD',\n BANK_ACCOUNT: 'BANK',\n PAYPAL_CREDIT: 'CREDIT',\n };\n\n if (!validShippingMethod) {\n return;\n }\n\n const instrumentsInSplit = getSplitOptionsAndBackup({\n splitFundingOptions: _splitFundingOptions,\n selectedSplitFundingInstruments,\n selectedBackupFundingInstrument,\n });\n\n const splitFundingOptions = instrumentsInSplit\n .filter((fundingOption) => {\n const { value } = fundingOption;\n return value !== null;\n })\n .map((instrument) => {\n const {\n value: currencyValue,\n fundingInstrument: { id, type },\n } = instrument;\n const fundingInstrumentType = _types[type] || type;\n const isPrimaryInstrument = selectedBackupFundingInstrument === id;\n return {\n fundingInstrumentType,\n id,\n amount: {\n currencyCode, // ! TODO - currently only USD is supported\n currencyValue: toNumber(currencyValue),\n },\n isPrimaryInstrument,\n };\n });\n logApprovePaymentPrepare(splitFundingOptions);\n\n // Clear any Split tender alert errors before users try to proceed to the merchant\n updateFeature('SPLIT_TENDER_GATE', {\n data: {\n showSplitTenderError: false,\n },\n });\n\n approvePaymentSplitTender({\n variables: {\n token: getToken(),\n splitFundingOptions,\n selectedAddressId,\n preferredShippingAddressId,\n },\n update: async (\n store,\n {\n data: {\n approveMemberPaymentWithSplitFundingOptions: approveMemberPaymentResultPayload,\n } = {},\n } = {}\n ) => {\n logApprovePaymentProcess(splitFundingOptions, currencyCode, getCountry(), {\n shipping_address_id: selectedAddressId,\n preferred_shipping_address: preferredShippingAddressId === selectedAddressId,\n });\n await handleGiveAtCheckout();\n returnToMerchantAfterApprove({\n approveMemberPaymentResultPayload,\n currencyCode, // TODO\n merchantName,\n });\n },\n }).catch((error) => {\n // The general `temporary` rule is that we're going to allow users to try submitting their order three times per session,\n // if for some reason all of the attempts resulted with an error, then we're going to disable the Split experience for now.\n // Note that this is a temporary solution since we do not know what all of the error types that PAPS returns are.\n updateFeature('SPLIT_TENDER_GATE', {\n data: {\n showSplitTenderError: true,\n errorsOccurrenceCount: errorsOccurrenceCount + 1,\n },\n });\n\n // ! TODO preAuthorizationRequired\n logApprovePaymentError(error);\n });\n }\n\n function approveMemberPayment({ isAutoResolved }) {\n const checkoutButtonStartTime = Date.now();\n\n const defaultSelectedFI = fundingOptions\n ? getDefaultSelectedFundingInstrument(fundingOptions)\n : {};\n const isDefaultFISelected = defaultSelectedFI?.id === selectedFundingOptionId;\n logger.fpti(\n 'reviewButtonClick',\n TRANSITION_PAYLOAD({\n from: 'REVIEW',\n to: 'process_review_click',\n is_default_fi_selected: isDefaultFISelected,\n fi_id: selectedFundingOptionId,\n })\n );\n\n // redirect to login if euat user chooses to pay with gpl or ppc\n if (payLaterContext?.isOfferSelected && params().euat) {\n return redirectToLogin('EUAT_LOGIN');\n }\n\n if (!selectedFundingOptionId && !payLaterContext?.isOfferSelected) {\n updateFeature('REVIEW_PAGE_ALERT', {\n visible: true,\n data: {\n type: 'info',\n display: true,\n message: getContent('paymentOptions.noSelectedFiErrorMessage'),\n },\n });\n\n // log that no option was selected when trying to continue\n logApprovePayment({\n currencyCode,\n errorCode: 'NO_SELECTED_OPTION',\n selectedFundingOption,\n selectedFundingOptionId,\n selectedInstallmentOption,\n selectedPlan,\n selectedTab,\n viewName,\n });\n\n return;\n }\n\n if ((isButtonDisabled && !isAutoResolved) || !validShippingMethod) {\n return;\n }\n\n const { fundingMethodType } = getSelectedFundingSource({\n fi: selectedFundingOption,\n plan: selectedPlan,\n });\n const shouldOpenInstallmentInterstitial =\n Array.isArray(availableInstallments) &&\n availableInstallments.length > 0 &&\n !Boolean(selectedInstallmentOption);\n\n const creditOfferType = creditOffer?.content?.OfferType;\n const shouldRedirectToCyco =\n (hasPPCreditInstallments || isInstallmentCreditType(creditOfferType)) &&\n creditFinancingOption?.creditType === undefined &&\n isPaypalCreditFundingInstrument(selectedFundingOption);\n\n const { name: fiName = '', type: fiType = '' } = selectedFundingOption?.fundingInstrument || {};\n const setStickyFiRequired = !isCreditWithAdditionalData(fiName, fiType);\n\n // If we are attempting to approve payment with a crypto funding instrument\n // we must first check if the instrument has enough currency to cover the txn.\n // If not we should show a error message and prevent continuing\n if (\n isCryptoFI &&\n !isCryptoAbleToCoverTransaction(cryptocurrencyHoldingDetails, cryptocurrencyQuote)\n ) {\n logger.cal.info('CRYPTO_ERROR_LESS_BALANCE');\n\n handleInsufficientBalanceError();\n\n return;\n }\n\n if (payLaterContext.isPpcOfferAcq) {\n return payLaterContext.processPpcOffer();\n }\n\n if (shouldRedirectToCyco) {\n return onClickCreditOffer();\n }\n\n if (payLaterContext.isGplOffer && continueButtonAction) {\n return continueButtonAction();\n }\n\n // For LATAM installments if we have not selected an installment term for\n // the selected FI we need to redirect the user to the select installment\n // interstitial instead of approving the payment.\n if (isInstallmentsFeatureEnabled && shouldOpenInstallmentInterstitial) {\n logger.cal.info(\n `INSTALLMENTS_OPEN_INTERSTITIAL_FROM_CHECKOUT_BUTTON_${getCountry()}_${currencyCode}`\n );\n\n openSelectInstallmentsInterstitial({\n availableInstallments: availableInstallments,\n fId: selectedFundingOptionId,\n isInstallmentSelected: false,\n selectedInstallmentMap: installmentsFeatureData?.selectedInstallmentMap,\n });\n\n return;\n }\n\n const { contingencyFlow, contingencyLogger } = contingencyResolver({\n currencyCode,\n paymentContingencies,\n selectedFundingOption,\n selectedFundingOptionId,\n creditFinancingOption,\n inClearCreditOptionFlow,\n hasGPLFundingInstrument,\n });\n\n if (isIframe() && contingencyFlow === 'OPEN_BANKING') {\n return fallback({ reason: 'moneynodewebRedirection' });\n }\n\n const preAuthorizationRequired = getPreAuthorizationRequired(\n rewardsPayload,\n selectedPlan.preAuthorizationData,\n isPayNowUserActionFlow\n );\n\n // This criteria applies when a multi-installment GPL offer has been approved\n // and the \"change\" link is clicked from the specialized RYI.\n if (payLaterContext.isGplOffer && hasGPLFundingInstrument) {\n return handleMultiOfferContinueButtonAction(payLaterContext, selectedAddressId);\n }\n\n // We should probably be using contingencyFlow here instead 🤔\n // We should launchCap when the GPL offer is selected and the Credit FI option is selected\n // to make sure CAP is not launched when GPL FI is selected on return/specialized RYI page\n if (payLaterContext.isGplOffer) {\n logger.cal.info(\n `CAP_CPL_START_TIME:`,\n `Checkout button click timestamp ${checkoutButtonStartTime}`\n );\n updateFeature('CREDIT_APPLY_PORTABLE', {\n visible: false,\n data: { checkoutButtonStartTime },\n });\n return payLaterContext.processGplOffer(selectedAddressId);\n }\n\n // Enable the Checkout button if all contingencies are resolved\n if (!contingencyFlow) {\n updateFeature('CHECKOUT_BUTTON', { data: { inContingencyFlow: false } });\n }\n\n const secondaryFundingOptionIds = getSecondaryFundingOptionIds(\n fundingOptions,\n isIncentivePresent,\n selectedPlan,\n useSplitBalance,\n balanceId\n );\n\n // Resolve any payment related contingency before triggering the `approvePayment` mutation\n // Note: when contingency flow is in Open Banking but Elmo is accidentally ramped to CONTROL\n // Open Banking interstitial will be disabled based on the Elmo settings\n // In that case we shall not proceed with Open Banking flow\n // but try to proceed with transaction directly even it may throw errors\n if (\n checkoutButtonStatus !== CHECKOUT_BUTTON_STATES.PENDING &&\n contingencyFlow &&\n !(contingencyFlow === 'OPEN_BANKING' && !isOpenBankingEnabled)\n ) {\n // Trigger fpti event\n contingencyLogger();\n\n // NEED_RTB - Need Real Time Balance Check for OpenBanking flow\n if (contingencyFlow === 'NEED_RTB') {\n return checkRealTimeBalance(selectedFundingOptionId);\n }\n\n if (contingencyFlow === 'CLEAR_CREDIT_OPTION') {\n return clearCreditFinancingOption();\n }\n\n resolveContingencies(contingencyFlow, {\n fundingMethodType,\n preAuthorizationRequired,\n preferredFundingOptionId,\n secondaryFundingOptionIds,\n selectedAddressId,\n selectedFundingOptionId,\n });\n\n return;\n }\n\n const totalIncentivesAmount = selectedPlan?.fundingSources.find(\n (fundingSource) => fundingSource?.groupedSources?.length > 0\n )?.amount;\n\n logApprovePayment({\n cartTotal,\n cryptocurrencyQuote,\n cryptocurrencyHoldingDetails,\n currencyCode,\n currencyValue,\n fundingMethodType,\n isDonationEligible,\n isGplOffer: payLaterContext.isGplOffer,\n preferredShippingAddressId,\n rewardsPayload,\n secondaryFundingOptionIds,\n selectedAddressId,\n selectedFundingOption,\n selectedFundingOptionId,\n selectedInstallmentOption,\n selectedPlan,\n selectedTab,\n setStickyFiRequired,\n shareAddressWithDonatee,\n shouldHideCart,\n totalIncentivesAmount,\n userId,\n viewName,\n });\n\n const approvePaymentVariables = {\n token: getToken(),\n selectedAddressId,\n preferredShippingAddressId,\n preferredFundingOptionId,\n selectedFundingOptionId,\n secondaryFundingOptionIds,\n preAuthorizationRequired,\n fundingMethodType,\n scaCompleted,\n rewards: rewardsPayload.rewardSelected\n ? {\n id: rewardsPayload.rewardSelected,\n amount: `${parseFloat(rewardsPayload.rewardAmount)}`,\n currency: currencyCode,\n }\n : undefined,\n selectedInstallmentOption: selectedInstallmentOption\n ? installmentToInstallmentsInput(selectedInstallmentOption)\n : undefined,\n shareAddressWithDonatee: isDonationEligible ? shareAddressWithDonatee : undefined,\n setStickyFiRequired,\n cryptocurrencyQuoteId: isCryptoFI ? cryptocurrencyQuote?.id : undefined,\n };\n\n logger.cal.info('PREPARE_APPROVE_PAYMENT_MUTATION', {\n variables: {\n ...approvePaymentVariables,\n },\n });\n\n approvePayment({\n variables: approvePaymentVariables,\n update: async (\n store,\n { data: { approveMemberPayment: approveMemberPaymentResult } = {} } = {}\n ) => {\n const {\n buyer: { userId } = {},\n paymentContingencies = {},\n state: paymentState,\n } = approveMemberPaymentResult || {};\n\n // don't disable submit button so users can still click continue if there are any\n // payment related contingencies returned from `approvePayment()` mutation\n const hasPaymentContingencies = [\n 'confirmCreditCardCvvData',\n 'threeDomainSecure', // 3DS (1.0) transactional contingency\n 'threeDSContingencyData', // 3DS (2.0) transactional contingency\n 'sepaMandateAcceptanceNeeded',\n 'needConsentForBankAccountInfoRetrieval',\n 'needRealTimeBalanceForBankAccount',\n 'strongCustomerAuthenticationRequired',\n ].some((contingency) => Boolean(paymentContingencies[contingency]));\n setIsButtonDisabled(!hasPaymentContingencies);\n\n // Check paymentContingencies based on success mutation\n const { contingencyFlow, contingencyLogger } = contingencyResolver({\n currencyCode,\n paymentContingencies,\n selectedFundingOption,\n selectedFundingOptionId,\n creditFinancingOption,\n inClearCreditOptionFlow,\n hasGPLFundingInstrument,\n });\n\n // if `approvePayment()` mutation returns any checkoutSession related paymentContingencies\n // such as cvv or 3DS we will handle it here\n if (checkoutButtonStatus !== CHECKOUT_BUTTON_STATES.PENDING && contingencyFlow) {\n // Trigger fpti event\n contingencyLogger();\n\n // when User Changed the FI which has NEED_RTB contingency\n // Need to trigger Real Time Balance Check for OpenBanking flow\n if (contingencyFlow === 'NEED_RTB') {\n return checkRealTimeBalance(selectedFundingOptionId);\n }\n\n return resolveContingencies(contingencyFlow, {\n fundingMethodType,\n preAuthorizationRequired,\n preferredFundingOptionId,\n secondaryFundingOptionIds,\n selectedAddressId,\n selectedFundingOptionId,\n });\n }\n\n // NOTE: this is where we check unknown contingencies that hermione client\n // can't handle & we will fallback to hermesnodeweb to continue\n if (paymentState === 'NON_PAYABLE') {\n logger.fpti(`approvePaymentError`, ERROR_PAYLOAD({ code: 'GQLError' }));\n return CheckoutError({ error: new Error('APPROVE_FAILED_NON_PAYABLE') });\n }\n\n if (preAuthorizationRequired) {\n logger.fpti(\n 'CPA_REVIEW',\n REVIEW_CPA_PAYLOAD({\n action: 'processPreAuth',\n client_epoch_ts: Date.now(),\n buyer_id: userId,\n })\n );\n }\n\n await handleGiveAtCheckout();\n\n if (!contingencyFlow) {\n if (approveMemberPaymentResult.completedPaymentInfo) {\n updateFeature('WPS_DONE_PAGE', {\n visible: true,\n });\n return;\n }\n returnToMerchantAfterApprove({\n approveMemberPaymentResultPayload: approveMemberPaymentResult,\n currencyCode,\n merchantName,\n });\n }\n },\n }).catch((error) => {\n if (preAuthorizationRequired) {\n logger.fpti(\n 'CPA_REVIEW',\n REVIEW_CPA_PAYLOAD({\n action: 'processPreAuth',\n client_epoch_ts: Date.now(),\n })\n );\n }\n\n logger.fpti(`approvePaymentError`, ERROR_PAYLOAD({ code: 'GQLError' }));\n });\n }\n\n // Automatically resume to to `approvePayment()` mutation when there are\n // no more payment related contingencies need to be handled\n useEffect(() => {\n if (\n selectedFundingOptionId &&\n checkoutButtonStatus === CHECKOUT_BUTTON_STATES.RESOLVED &&\n (checkoutButtonStatus !== previousCheckoutButtonStatus || inOpenBankingFlow)\n ) {\n if (inOpenBankingFlow) {\n updateFeature('CHECKOUT_BUTTON', { data: { flow: null } });\n }\n const { fundingMethodType } = getSelectedFundingSource({\n fi: selectedFundingOption,\n plan: selectedPlan,\n });\n if (fundingMethodType === 'ECHECK') {\n logger.fpti(\n 'reviewECheck',\n TRANSITION_PAYLOAD({\n from: 'REVIEW',\n to: 'process_review_echeck',\n fi_id: selectedFundingOptionId,\n })\n );\n } else {\n approveMemberPayment({ isAutoResolved: true });\n }\n }\n // ? we don't necessarily need to depend on `approveMemberPayment` changing\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n checkoutButtonStatus,\n inOpenBankingFlow,\n previousCheckoutButtonStatus,\n selectedFundingOptionId,\n ]);\n\n const buttonText = getButtonText({\n availableInstallments,\n billingAgreement,\n checkoutButtonLabelOverride,\n creditButtonText,\n creditOfferAsFI_DE,\n isDonation,\n isPayNowUserActionFlow,\n selectedFundingOption,\n selectedInstallmentOption,\n usePayAfterDelivery,\n });\n\n return (\n \n {buttonText}\n \n );\n}\n","import get from 'dlv';\nimport { isInstallmentCreditType } from '@/lib/utils';\nimport { isPaypalCreditFundingInstrument } from '@/lib/utils';\nimport getContent from '@/lib/content';\n\nexport default function getCreditCheckoutButtonData({\n creditOfferAsFI_DE = {},\n creditFIOption,\n isPayNowUserActionFlow,\n selectedFundingOptionId,\n payLaterContext,\n payContext,\n creditOffer,\n shouldUseGplButtonText,\n}) {\n const isPpcFi = isPaypalCreditFundingInstrument(payContext.selectedFundingOption);\n const isPpcReuse = payContext?.payState?.isPPCReuse;\n const isInstallment = isInstallmentCreditType(creditOffer?.content?.OfferType);\n \n if (payLaterContext.payLaterState.checkoutButtonText) {\n return {\n creditButtonText: payLaterContext.payLaterState.checkoutButtonText,\n };\n } else if (shouldUseGplButtonText) {\n return {\n creditButtonText:\n creditFIOption?.fundingInstrument?.creditFields?.creditOffer?.uiElements?.creditFI\n ?.payButtonText,\n };\n } else if (\n selectedFundingOptionId === get(creditFIOption, 'id', -1) &&\n creditFIOption.fundingInstrument.creditFields !== null\n ) {\n return {\n creditButtonText: isPayNowUserActionFlow\n ? creditFIOption.fundingInstrument.creditFields.creditOffer.uiElements.creditFI\n .payButtonText\n : creditFIOption.fundingInstrument.creditFields.creditOffer.uiElements.creditFI\n .continueButtonText,\n };\n } else if (get(creditOfferAsFI_DE, 'data.isSelected')) {\n return {\n creditButtonText: get(creditOfferAsFI_DE, 'data.continueButtonText'),\n };\n } else if (isPpcFi && isPpcReuse && isInstallment) {\n return {\n creditButtonText: getContent('checkoutButton.continue'),\n };\n }\n return {\n creditButtonText: '',\n };\n}\n","import { updateFeature } from '@paypalcorp/c3-util-store';\n\n/**\n * Method created to reset split tender related data\n */\nexport const resetSplitTenderData = () => {\n updateFeature('SPLIT_TENDER_GATE', {\n data: {\n userCanSplit: false,\n isSplitReady: false,\n showSplitContinue: false,\n showSplitExperience: false,\n selectedBackupFundingInstrument: undefined,\n selectedSplitFundingInstruments: undefined,\n },\n });\n};\n\n/**\n * Method responsible for returning a list of fi ids that a elegible\n * for being a backup/primary fi.\n */\nexport const getEligibleForPrimaryFiIdList = (splitFundingOptions) => {\n return splitFundingOptions\n .filter((fundingOption) => fundingOption.isEligibleForPrimaryInstrument)\n .map((fundingOption) => fundingOption.id);\n};\n\nexport const isSplitTenderActive = (SplitTenderGate) => {\n return SplitTenderGate?.experiment?.resolvedTreatment === 'TREATMENT_1';\n};\n\nexport const getSplitOptionsAndBackup = ({\n splitFundingOptions,\n selectedSplitFundingInstruments,\n selectedBackupFundingInstrument,\n}) => {\n const backupIsOneOfSelected = !!selectedSplitFundingInstruments.find(\n ({ id }) => id === selectedBackupFundingInstrument\n );\n\n if (backupIsOneOfSelected) {\n return selectedSplitFundingInstruments;\n }\n\n const backupFi = splitFundingOptions.find(({ id }) => id === selectedBackupFundingInstrument);\n\n if (!backupFi) {\n // This should never happen.\n return selectedSplitFundingInstruments;\n }\n\n return [...selectedSplitFundingInstruments, { ...backupFi, value: 0 }];\n};\n"],"sourceRoot":""}