User & Subscription
This page describes all of the page/campaign methods available within the Limio SDK.
Retrieving details of the current user
If you need to find out if a user is validated and get some details about that user, including Subscription you can use the useUser
method.
Example to display authenticated user's email in a navigation bar:
Example to display an authenticated user's Subscriptions and the Status of those Subscriptions, as well as upcoming payments:
Example user
:
Getting details from the a subscription
useSubInfo
Extracts and returns key subscription information such as status, gift status, quantity, whether the subscription has lapsed, and if there are any pending changes.
Returns:
SubInfo An object containing:
status
: string: The current status of the subscription.isGift
: boolean: Whether the subscription is a gift.quantity
: number: The quantity associated with the subscription.hasLapsed
: boolean | undefined: Whether the subscription has lapsed.hasPendingChange
: boolean: Whether there is a pending change scheduled for the subscription.
Getting the user's invoices
To get all of the account level invoices from Zuora, Limio exposes a hook, useUserInvoices. When called this will retrieve ever invoice from the users account. Example usage:
The invoices are an array of unaltered invoice objects from Zuora. See here for further information on the data structures of each invoice.
Getting the user's address
getCurrentAddress
Checks a Limio Address Object to find and return the active billing or delivery address associated with a customer account.
Parameters:
type
:string
(required) The type of address to retrieve. Can be"billing"
or"delivery"
.addresses
:LimioAddressObject
(required) An array containing the customer's associated address objects, typically including both billing and delivery addresses.
Returns:
LimioAddressObject
: An object containing the data of the active address matching the specified type. The returned object usually includes the full address details such as street, city, postal code, and country.
Example LimioAddressObject
Subscription helpers
getPriceFromSchedule
Retrieves the price from a Limio schedule item and returns an object containing the price value and currency code. It can also take into account the country code, which may influence the price calculation.
Parameters:
schedule
:LimioScheduleItem
An object representing a schedule item within a Limio subscription.country
:string
(optional) An alpha-2 country code that may be used to adjust the price based on the country.
Example LimioScheduleItem
:
Returns:
{ value: string, currencyCode: string }
An object containing:value
:string
: The price value extracted from the schedule item.currencyCode
:string
: The currency code associated with the price.
getCurrentOffer
Returns the current active offer associated with a user's subscription. Useful for retrieving details about the active promotional or pricing offer that applies to the subscription.
Parameters:
userSubscription
:LimioUserSubscription
An object representing the user's subscription, including any associated offers.
Returns:
LimioOffer
: An object representing the current active offer associated with the subscription. The offer object typically includes details such as pricing, terms, and conditions.
getPeriodForOffer
Returns the billing period of a LimioOffer
object, indicating the duration or frequency of the offer's billing cycle. If the offer is a one-off charge (non-recurring), it returns "N/A"
.
This function can be used in conjunction with getCurrentOffer
to retrieve the billing period of the user's current offer.
Parameters:
offer
:LimioOfferObject
An object representing a Limio offer, containing details such as its billing cycle, price, and attributes.
Returns:
A string representing the period of the offer (e.g., "1 month"), or "N/A" if the offer is a one-off charge or does not auto-renew.
Example Output:
"1 month"
if the offer is recurring monthly."N/A"
if the offer is a one-off charge or evergreen.
checkCurrentSchedule
Determines the next applicable schedule from the existing schedules for a subscription. Useful for displaying information such as the next bill date and price.
Parameters:
schedules: Array An array of schedule objects associated with the subscription. Each schedule object typically includes a status and a data.date.
Returns:
schedule: Array Returns the next applicable schedule object based on the provided parameters, or null/undefined if no suitable schedule is found.
getRenewalDateForUserSubscription
Retrieves and returns the renewal date for a user's subscription, formatted according to the default date format defined in the Limio App settings.
Parameters:
userSubscription: UserSubscription An object containing the user's subscription details, such as status, schedule, and term end date.
Returns:
A string representing the formatted renewal date of the user's subscription. Possible return values include:
The next scheduled renewal date.
The term end date if no next schedule is found.
"N/A"
if the subscription status is "cancelled".
getPriceForUserSubscription
Calculates and returns the price information for a user's subscription, considering factors such as the user's subscription status, country, and any applicable offers or charges.
Parameters:
userSubscription: UserSubscription An object representing the user's subscription details, such as status, schedule, and purchase country.
Returns:
A string representing the price information for the user's subscription. Possible return values include:
A formatted currency amount for the next scheduled payment.
"Currently unavailable"
if the price cannot be determined."N/A"
if the subscription status is "cancelled".
Last updated