Periodic Charges
Periodic Charge Functions
Overview
The NCC Charging API offers a periodic charge management functions for usage within your scripts.
All periodic charge state and subscription information and operations are for the current logical subscriber only.
Subscriber periodic charge information is never cached.
Subscription State
- ccs.periodic_charge.get_charge_state
 - ccs.periodic_charge.is_active
 - ccs.periodic_charge.is_grace
 - ccs.periodic_charge.is_subscribed
 - ccs.periodic_charge.is_terminated
 - ccs.periodic_charge.is_unsubscribed
 - ccs.periodic_charge.is_unavailable
 - ccs.periodic_charge.get_charge_class
 
Subscription Management
- ccs.periodic_charge.subscribed_to_group
 - ccs.periodic_charge.is_valid_product
 - ccs.periodic_charge.subscribe
 - ccs.periodic_charge.unsubscribe
 - ccs.periodic_charge.to_grace
 - ccs.periodic_charge.terminate
 - ccs.periodic_charge.charge_alignment
 - ccs.periodic_charge.transfer_to
 
Data Lookup
- ccs.periodic_charge.get_state_by_name
 - ccs.periodic_charge.get_state_by_id
 - ccs.periodic_charge.state_id_for_name
 - ccs.periodic_charge.state_name_for_id
 - ccs.periodic_charge.get_period_by_name
 - ccs.periodic_charge.get_period_by_id
 - ccs.periodic_charge.period_id_for_name
 - ccs.periodic_charge.period_name_for_id
 - ccs.periodic_charge.get_action_by_name
 - ccs.periodic_charge.get_action_by_id
 - ccs.periodic_charge.action_id_for_name
 - ccs.periodic_charge.action_name_for_id
 
| ▲ ccs.periodic_charge.get_charge_state (periodic_charge_id, lookup_info) | |||
|---|---|---|---|
| Parameters | periodic_charge_id | The periodic charge ID to retrieve state information about for the logical subscriber. | |
| lookup_info | A table of subscriber lookup information. Optional; will be automatically retrieved if not provided. | ||
| Returns | A periodic charge state entry with the state of the periodic charge for the current logical subscriber. If no periodic charge information is found, the 'Unsubscribed' (2) state will be returned for consistency with NCC's built-in periodic charge functions. | ||
| Errors | 
If no periodic_charge_id is provided:
 If no periodic charges are retrieved for the logical subscriber’s ACS customer or the periodic charge information is not able to be turned into a table: 
  | 
    ||
| Usage | 
This function queries the Lua runtime for subscriber and customer data and looks for the periodic charge specified, returning its state as a periodic charge state entry. Any subscriber lookup information provided will be used instead of performing fresh retrieval operations.
 | 
    ||
| ▲ ccs.periodic_charge.is_active (periodic_charge_id, lookup_info) | |||
|---|---|---|---|
| Parameters | periodic_charge_id | The periodic charge ID to retrieve state information about for the logical subscriber. | |
| lookup_info | A table of subscriber lookup information. Optional; will be automatically retrieved if not provided. | ||
| Returns | 
If the specified periodic charge's state for the current logical subscriber has the class 'Active', returns true. Otherwise, returns false.
 | 
    ||
| Errors | None. | ||
| Usage | 
This function offers a helper lookup on the periodic charge state for the current logical subscriber. It calls the ccs.periodic_charge.get_charge_state function with the supplied periodic charge ID and lookup information, if any, and then checks the class of the given periodic charge. If the class of the periodic charge is 'Active', the function returns true. Otherwise, the function returns false.
 | 
    ||
| ▲ ccs.periodic_charge.is_grace (periodic_charge_id, lookup_info) | |||
|---|---|---|---|
| Parameters | periodic_charge_id | The periodic charge ID to retrieve state information about for the logical subscriber. | |
| lookup_info | A table of subscriber lookup information. Optional; will be automatically retrieved if not provided. | ||
| Returns | 
If the specified periodic charge's state for the current logical subscriber has the class 'Grace', returns true. Otherwise, returns false.
 | 
    ||
| Errors | None. | ||
| Usage | 
This function offers a helper lookup on the periodic charge state for the current logical subscriber. It calls the ccs.periodic_charge.get_charge_state function with the supplied periodic charge ID and lookup information, if any, and then checks the class of the given periodic charge. If the class of the periodic charge is 'Grace', the function returns true. Otherwise, the function returns false.
 | 
    ||
| ▲ ccs.periodic_charge.is_subscribed (periodic_charge_id, lookup_info) | |||
|---|---|---|---|
| Parameters | periodic_charge_id | The periodic charge ID to retrieve state information about for the logical subscriber. | |
| lookup_info | A table of subscriber lookup information. Optional; will be automatically retrieved if not provided. | ||
| Returns | 
If the specified periodic charge's state for the current logical subscriber has the class 'Grace' or the class 'Active', returns true. Otherwise, returns false.
 | 
    ||
| Errors | None. | ||
| Usage | 
This function offers a helper lookup on the periodic charge state for the current logical subscriber. It calls the ccs.periodic_charge.get_charge_state function with the supplied periodic charge ID and lookup information, if any, and then checks the class of the given periodic charge. If the class of the periodic charge is 'Grace' or 'Active', the function returns true. Otherwise, the function returns false.
 | 
    ||
| ▲ ccs.periodic_charge.is_terminated (periodic_charge_id, lookup_info) | |||
|---|---|---|---|
| Parameters | periodic_charge_id | The periodic charge ID to retrieve state information about for the logical subscriber. | |
| lookup_info | A table of subscriber lookup information. Optional; will be automatically retrieved if not provided. | ||
| Returns | 
If the specified periodic charge's state for the current logical subscriber has the class 'Terminated', returns true. Otherwise, returns false.
 | 
    ||
| Errors | None. | ||
| Usage | 
This function offers a helper lookup on the periodic charge state for the current logical subscriber. It calls the ccs.periodic_charge.get_charge_state function with the supplied periodic charge ID and lookup information, if any, and then checks the class of the given periodic charge. If the class of the periodic charge is 'Terminated', the function returns true. Otherwise, the function returns false.
 | 
    ||
| ▲ ccs.periodic_charge.is_unsubscribed (periodic_charge_id, lookup_info) | |||
|---|---|---|---|
| Parameters | periodic_charge_id | The periodic charge ID to retrieve state information about for the logical subscriber. | |
| lookup_info | A table of subscriber lookup information. Optional; will be automatically retrieved if not provided. | ||
| Returns | 
If the specified periodic charge's state for the current logical subscriber has the class 'Unsubscribed', returns true. Otherwise, returns false.
 | 
    ||
| Errors | None. | ||
| Usage | 
This function offers a helper lookup on the periodic charge state for the current logical subscriber. It calls the ccs.periodic_charge.get_charge_state function with the supplied periodic charge ID and lookup information, if any, and then checks the class of the given periodic charge. If the class of the periodic charge is 'Unsubscribed', the function returns true. Otherwise, the function returns false.
 | 
    ||
| ▲ ccs.periodic_charge.is_unavailable (periodic_charge_id, lookup_info) | |||
|---|---|---|---|
| Parameters | periodic_charge_id | The periodic charge ID to retrieve state information about for the logical subscriber. | |
| lookup_info | A table of subscriber lookup information. Optional; will be automatically retrieved if not provided. | ||
| Returns | 
If the specified periodic charge's state for the current logical subscriber has the class 'Unavailable', returns true. Otherwise, returns false.
 | 
    ||
| Errors | None. | ||
| Usage | 
This function offers a helper lookup on the periodic charge state for the current logical subscriber. It calls the ccs.periodic_charge.get_charge_state function with the supplied periodic charge ID and lookup information, if any, and then checks the class of the given periodic charge. If the class of the periodic charge is 'Unavailable', the function returns true. Otherwise, the function returns false.
 | 
    ||
| ▲ ccs.periodic_charge.get_charge_class (periodic_charge_id, lookup_info) | |||
|---|---|---|---|
| Parameters | periodic_charge_id | The periodic charge ID to retrieve information about for the logical subscriber. | |
| lookup_info | A table of subscriber lookup information. Optional; will be automatically retrieved if not provided. | ||
| Returns | Returns the CLASS of the periodic charge state the current logical subscriber's specified periodic charge. | ||
| Errors | None. | ||
| Usage | 
This function offers a helper lookup on the periodic charge state for the current logical subscriber. It calls the ccs.periodic_charge.get_charge_state function with the supplied periodic charge ID and lookup information, if any, and then returns the class of the given periodic charge.
 | 
    ||
| ▲ ccs.periodic_charge.subscribed_to_group (periodic_charge_id, lookup_info) | |||
|---|---|---|---|
| Parameters | pc_group_id | The periodic charge group ID to retrieve information about for the logical subscriber. | |
| lookup_info | A table of subscriber lookup information. Optional; will be automatically retrieved if not provided. | ||
| Returns | 
If the current logical subscriber is subscribed to any periodic charge in the specified periodic charge group, returns true. Otherwise, returns false.
 | 
    ||
| Errors | None. | ||
| ▲ ccs.periodic_charge.is_valid_product (periodic_charge_id, lookup_info) | |||
|---|---|---|---|
| Parameters | periodic_charge_id | The periodic charge ID to retrieve information about for the logical subscriber. | |
| lookup_info | A table of subscriber lookup information. Optional; will be automatically retrieved if not provided. | ||
| Returns | 
If the current logical subscriber's active wallet has a product type that the specified periodic charge is associated with, returns true. Otherwise, returns false.
 | 
    ||
| Errors | None. | ||
| Usage | 
This function checks the specified periodic charge and returns true if the periodic charge is associated with the current logical subscriber's active wallet's product type, i.e. is available to be subscribed to barring other qualifiers.
 | 
    ||
| ▲ ccs.periodic_charge.subscribe (periodic_charge_info, lookup_info) | |||
|---|---|---|---|
| Parameters | periodic_charge_info | 
A table of periodic charge information for the operation, formatted as:
 | 
    |
| lookup_info | A table of subscriber lookup information. Optional; will be automatically retrieved if not provided. | ||
| Returns | Nothing. | ||
| Errors | 
This operation takes place via an extended wallet update transaction with the NCC runtime; errors listed under that function may also occur.
 If periodic charge information is not supplied in a table: 
 If no periodic charge ID is supplied: 
 If the logical subscriber’s product type is not valid for the periodic charge specified: 
 If the logical subscriber’s active wallet state is not Active or Dormant: 
 If the logical subscriber’s active wallet already has a subscription to the specified periodic charge: 
 If the apply charge indicator is specified but is neither true nor false: 
 If the apply charge indicator is true but the periodic charge does not support applying a charge: 
 If the pro-rate indicator is specified but is neither true nor false: 
 If the pro-rate indicator is true but the apply charge indicator is not true: 
 If the pro-rate indicator is true but the periodic charge does not support pro-rating: 
 If the reference date field is supplied but the periodic charge does not support reference dates: 
 If repetition or reference date information is supplied for a daily periodic charge: 
 If monthly repetition information is supplied for a weekly periodic charge: 
 If the repeat day of week is specified but is not a valid number: 
 If weekly repetition information is supplied for a monthly, quarterly, half-yearly, or annual periodic charge: 
 If the repeat day of month is specified but is not a valid number: 
 If the repeat month of year is specified but is not a valid number: 
 If repetition information is specified for a custom-frequency periodic charge: 
 Should any of the following errors occur, contact N-Squared Support: 
  | 
    ||
| Usage | 
Use this function to subscribe the current logical subscriber to a specified periodic charge. The information provided in periodic_charge_info will depend on the configuration of the periodic charge you are subscribing to.
 | 
    ||
| ▲ ccs.periodic_charge.unsubscribe (periodic_charge_info, lookup_info) | |||
|---|---|---|---|
| Parameters | periodic_charge_info | 
A table of periodic charge information for the operation, formatted as:
 | 
    |
| lookup_info | A table of subscriber lookup information. Optional; will be automatically retrieved if not provided. | ||
| Returns | Nothing. | ||
| Errors | 
This operation takes place via an extended wallet update transaction with the NCC runtime; errors listed under that function may also occur.
 If periodic charge information is not supplied in a table: 
 If no periodic charge ID is supplied: 
 If the logical subscriber does not have a subscription to the periodic charge specified: 
 Should any of the following errors occur, contact N-Squared Support: 
  | 
    ||
| Usage | 
Use this function to unsubscribe the current logical subscriber from the specified periodic charge.
 | 
    ||
| ▲ ccs.periodic_charge.to_grace (periodic_charge_info, lookup_info) | |||
|---|---|---|---|
| Parameters | periodic_charge_info | 
A table of periodic charge information for the operation, formatted as:
 | 
    |
| lookup_info | A table of subscriber lookup information. Optional; will be automatically retrieved if not provided. | ||
| Returns | Nothing. | ||
| Errors | 
This operation takes place via an extended wallet update transaction with the NCC runtime; errors listed under that function may also occur.
 If periodic charge information is not supplied in a table: 
 If no periodic charge ID is supplied: 
 If the logical subscriber does not have a subscription to the periodic charge specified: 
 Should any of the following errors occur, contact N-Squared Support: 
  | 
    ||
| Usage | 
Use this function to move the current logical subscriber's specified periodic charge subscription to the Grace state.
 | 
    ||
| ▲ ccs.periodic_charge.terminate (periodic_charge_info, lookup_info) | |||
|---|---|---|---|
| Parameters | periodic_charge_info | 
A table of periodic charge information for the operation, formatted as:
 | 
    |
| lookup_info | A table of subscriber lookup information. Optional; will be automatically retrieved if not provided. | ||
| Returns | Nothing. | ||
| Errors | 
This operation takes place via an extended wallet update transaction with the NCC runtime; errors listed under that function may also occur.
 If periodic charge information is not supplied in a table: 
 If no periodic charge ID is supplied: 
 If the logical subscriber does not have a subscription to the periodic charge specified: 
 Should any of the following errors occur, contact N-Squared Support: 
  | 
    ||
| Usage | 
Use this function to move the current logical subscriber's specified periodic charge subscription to the Terminated state.
 | 
    ||
| ▲ ccs.periodic_charge.charge_alignment (periodic_charge_info, lookup_info) | |||
|---|---|---|---|
| Parameters | periodic_charge_info | 
A table of periodic charge information for the operation, formatted as:
 | 
    |
| lookup_info | A table of subscriber lookup information. Optional; will be automatically retrieved if not provided. | ||
| Returns | Nothing. | ||
| Errors | 
This operation takes place via an extended wallet update transaction with the NCC runtime; errors listed under that function may also occur.
 If periodic charge information is not supplied in a table: 
 If no periodic charge ID is supplied: 
 If the logical subscriber’s product type is not valid for the periodic charge specified: 
 If the logical subscriber’s active wallet state is not Active or Dormant: 
 If the logical subscriber is not subscribed to the periodic charge specified: 
 If the apply charge indicator is specified but is neither true nor false: 
 If the apply charge indicator is true but the periodic charge does not support applying a charge: 
 If the pro-rate indicator is specified but is neither true nor false: 
 If the pro-rate indicator is true but the apply charge indicator is not true: 
 If the pro-rate indicator is true but the periodic charge does not support pro-rating: 
 If the reference date field is supplied but the periodic charge does not support reference dates: 
 If repetition or reference date information is supplied for a daily periodic charge: 
 If monthly repetition information is supplied for a weekly periodic charge: 
 If the repeat day of week is specified but is not a valid number: 
 If weekly repetition information is supplied for a monthly, quarterly, half-yearly, or annual periodic charge: 
 If the repeat day of month is specified but is not a valid number: 
 If the repeat month of year is specified but is not a valid number: 
 If repetition information is specified for a custom-frequency periodic charge: 
 If no repetition or reference information is supplied: 
 Should any of the following errors occur, contact N-Squared Support: 
  | 
    ||
| Usage | 
Use this function to realign the repetition information or reference date of the specified periodic charge for the current logical subscriber. The information provided in periodic_charge_info> will depend on the configuration of the periodic charge you are subscribing to.
 | 
    ||
| ▲ ccs.periodic_charge.transfer_to (periodic_charge_info, lookup_info) | |||
|---|---|---|---|
| Parameters | periodic_charge_info | 
A table of periodic charge information for the operation, formatted as:
 | 
    |
| lookup_info | A table of subscriber lookup information. Optional; will be automatically retrieved if not provided. | ||
| Returns | Nothing. | ||
| Errors | 
This operation takes place via an extended wallet update transaction with the NCC runtime; errors listed under that function may also occur.
 If periodic charge information is not supplied in a table: 
 If no periodic charge ID is supplied: 
 If the logical subscriber does not have a subscription to any periodic charge in the same group as the periodic charge specified: 
 If the logical subscriber’s current subscription within the periodic charge group of the specified periodic charge is not active: 
 If the periodic charge to transfer to is not in a periodic charge group: 
 Should any of the following errors occur, contact N-Squared Support: 
  | 
    ||
| Usage | 
Use this function to transfer a current, Active periodic charge subscription in a periodic charge group to another periodic charge within that group.
 | 
    ||
| ▲ ccs.periodic_charge.get_state_by_name (state_name) | |||
|---|---|---|---|
| Parameters | state_name | The name of the periodic charge state to retrieve. | |
| Returns | 
Either nil if no match is found, or a table for a single periodic charge state, formatted as:
 | 
    ||
| Errors | None. | ||
| Usage | 
This function returns a single periodic charge state matching the name provided, or nil if no matching state was found.
 | 
    ||
| ▲ ccs.periodic_charge.get_state_by_id (state_id) | |||
|---|---|---|---|
| Parameters | state_id | The ID of the periodic charge state to retrieve. | |
| Returns | 
Either nil if no match is found, or a table for a single periodic charge state, formatted as:
 | 
    ||
| Errors | None. | ||
| Usage | 
This function returns a single periodic charge state matching the ID provided, or nil if no matching state was found.
 | 
    ||
| ▲ ccs.periodic_charge.state_id_for_name (state_name) | |||
|---|---|---|---|
| Parameters | state_name | The name of the periodic charge state to retrieve the ID for. | |
| Returns | 
The ID of the periodic charge state with the provided name, or nil if no match is found.
 | 
    ||
| Errors | None. | ||
| Usage | 
This is a specialised shortcut version of ccs.periodic_charge.get_state_by_name that returns only the ID of the periodic charge state with the name provided. If the periodic charge state is not found, nil is returned.
 | 
    ||
| ▲ ccs.periodic_charge.state_name_for_id (state_id) | |||
|---|---|---|---|
| Parameters | state_id | The ID of the periodic charge state to retrieve the name for. | |
| Returns | 
The name of the periodic charge state with the provided ID, or nil if no match is found.
 | 
    ||
| Errors | None. | ||
| Usage | 
This is a specialised shortcut version of ccs.periodic_charge.get_state_by_id that returns only the name of the periodic charge state with the ID provided. If the periodic charge state is not found, nil is returned.
 | 
    ||
| ▲ ccs.periodic_charge.get_period_by_name (period_name) | |||
|---|---|---|---|
| Parameters | period_name | The name of the periodic charge period to retrieve. | |
| Returns | 
Either nil if no match is found, or a table for a single periodic charge period, formatted as:
 | 
    ||
| Errors | None. | ||
| Usage | 
This function returns a single periodic charge period matching the name provided, or nil if no matching period was found.
 | 
    ||
| ▲ ccs.periodic_charge.get_period_by_id (period_id) | |||
|---|---|---|---|
| Parameters | period_id | The ID of the periodic charge period to retrieve. | |
| Returns | 
Either nil if no match is found, or a table for a single periodic charge period, formatted as:
 | 
    ||
| Errors | None. | ||
| Usage | 
This function returns a single periodic charge period matching the ID provided, or nil if no matching period was found.
 | 
    ||
| ▲ ccs.periodic_charge.period_id_for_name (period_name) | |||
|---|---|---|---|
| Parameters | period_name | The name of the periodic charge period to retrieve the ID for. | |
| Returns | 
The ID of the periodic charge period with the provided name, or nil if no match is found.
 | 
    ||
| Errors | None. | ||
| Usage | 
This is a specialised shortcut version of ccs.periodic_charge.get_period_by_name that returns only the ID of the periodic charge period with the name provided. If the periodic charge period is not found, nil is returned.
 | 
    ||
| ▲ ccs.periodic_charge.period_name_for_id (period_id) | |||
|---|---|---|---|
| Parameters | period_id | The ID of the periodic charge period to retrieve the name for. | |
| Returns | 
The name of the periodic charge period with the provided ID, or nil if no match is found.
 | 
    ||
| Errors | None. | ||
| Usage | 
This is a specialised shortcut version of ccs.periodic_charge.get_period_by_id that returns only the name of the periodic charge period with the ID provided. If the periodic charge period is not found, nil is returned.
 | 
    ||
| ▲ ccs.periodic_charge.get_action_by_name (action_name) | |||
|---|---|---|---|
| Parameters | action_name | The name of the periodic charge action to retrieve. | |
| Returns | 
Either nil if no match is found, or a table for a single periodic charge action, formatted as:
 | 
    ||
| Errors | None. | ||
| Usage | 
This function returns a single periodic charge action matching the name provided, or nil if no matching action was found.
 | 
    ||
| ▲ ccs.periodic_charge.get_action_by_id (action_id) | |||
|---|---|---|---|
| Parameters | action_id | The ID of the periodic charge action to retrieve. | |
| Returns | 
Either nil if no match is found, or a table for a single periodic charge action, formatted as:
 | 
    ||
| Errors | None. | ||
| Usage | 
This function returns a single periodic charge action matching the ID provided, or nil if no matching action was found.
 | 
    ||
| ▲ ccs.periodic_charge.action_id_for_name (action_name) | |||
|---|---|---|---|
| Parameters | action_name | The name of the periodic charge action to retrieve the ID for. | |
| Returns | 
The ID of the periodic charge action with the provided name, or nil if no match is found.
 | 
    ||
| Errors | None. | ||
| Usage | 
This is a specialised shortcut version of ccs.periodic_charge.get_action_by_name that returns only the ID of the periodic charge action with the name provided. If the periodic charge action is not found, nil is returned.
 | 
    ||
| ▲ ccs.periodic_charge.action_name_for_id (action_id) | |||
|---|---|---|---|
| Parameters | action_id | The ID of the periodic charge action to retrieve the name for. | |
| Returns | 
The name of the periodic charge action with the provided ID, or nil if no match is found.
 | 
    ||
| Errors | None. | ||
| Usage | 
This is a specialised shortcut version of ccs.periodic_charge.get_action_by_id that returns only the name of the periodic charge action with the ID provided. If the periodic charge action is not found, nil is returned.
 | 
    ||