Overview
TheuseBillingContext hook provides access to the billing context within your application. This context includes various billing-related states and functions that help manage user subscriptions, plans, and modal visibility.
Import
Usage
Example
Provided Values
TheuseBillingContext hook provides a variety of values and functions. Below is a detailed list along with usage examples for each.
userToken
The authentication token for the user.
setUserToken
Function to set the authentication token for the user.
user
The user object.
setUser
Function to set the user object.
selectedPlan
The currently selected subscription plan.
setSelectedPlan
Function to set the selected subscription plan.
plans
An array of available subscription plans.
customer
The customer object.
setCustomer
Function to set the customer object.
isMonthly
Boolean indicating if the billing cycle is monthly.
toggleBillingCycle
Function to toggle the billing cycle between monthly and yearly.
showUpgradeModal
Boolean indicating if the upgrade modal is visible.
setShowUpgradeModal
Function to set the visibility of the upgrade modal.
showFreeTrialButton
Boolean indicating if the free trial button is visible.
setShowFreeTrialButton
Function to set the visibility of the free trial button.
isBillingModalOpen
Boolean indicating if the billing modal is open.
setIsBillingModalOpen
Function to set the visibility of the billing modal.
showContactModal
Boolean indicating if the contact modal is visible.
setShowContactModal
Function to set the visibility of the contact modal.
showSuccessModal
Boolean indicating if the success modal is visible.
setShowSuccessModal
Function to set the visibility of the success modal.
showWelcomeModal
Boolean indicating if the welcome modal is visible.
setShowWelcomeModal
Function to set the visibility of the welcome modal.
handleSelectPlan
Function to handle plan selection.
handleContactUs
Function to handle contact us action.
handleSubmitContactUsForm
Function to handle contact us form submission.
closeSuccessModal
Function to close the success modal.
closeContactModal
Function to close the contact modal.
closeUpgradeModal
Function to close the upgrade modal.
closeBillingModal
Function to close the billing modal.
closeEntitlementUsageLimitModal
Function to close the entitlement usage limit modal.
handleUpgrade
Function to handle the upgrade action.
handleSuccess
Function to handle success action after subscription.
handleTrial
Function to handle starting a trial subscription.
subscription
The current subscription object.
setSubscription
Function to set the current subscription object.
showEntitlementLimitModal
Boolean indicating if the entitlement limit modal is visible.
setShowEntitlementLimitModal
Function to set the visibility of the entitlement limit modal.
Dependencies
This hook depends on the following:- A Config object with
BILLING_API_URLdefined BILLING_CYCLESandENTERPRISE_PLAN_NAMEconstants from a types file