Type: "Subscription"

Introduction

A subscription represents an instance of a service that has been subscribed to by a wallet. A subscription is always associated with a service, and always has a lifecycle.

API Methods

.id

Returns the unique subscription ID that can be used to reference the subscription inside a wallet. This method has no parameters.

    ...
    local id = context.active_subscription().id()
    ...

The subscription will always have an ID as a subscription cannot exist without being instantiated on a wallet.

service

This method returns a simple table of data representing the service that the subscription is for.

This method has no parameters.

    ...
    local service = context.active_subscription().service()
    ...

The service response table includes the following fields:

Field Type Description
.id String The service ID, as defined for the service in the service configuration.
.name String The name of the service, as defined in the service configuration.

The response from the service() method is never nil.

lifecycle_instance

Returns an object representing the current state of the subscription’s lifecycle (a lifecycle instance). This is effectively the subscription’s current state.

A lifecycle instance refers to a lifecycle which describes the state machine this instance is progressing through.

This method has no parameters.

The subscription will always have a lifecycle, so this method will always return a non-nil value.

subscription_context

Returns a table that is the subscription context provided during the subscription process. This might include data that customises this subscription specifically to the wallet subscribing to this service.

This method has no parameters.

The subscription context will never be nil, but it may be an empty table. The content of the subscription context will be what was provided during the initial subscription event and would be provided by the client calling the OCS.

merged_context

Returns a table that is the subscription context provided during the subscription process merged with the service properties.

The service’s properties are the properties defined during the definition of the service, and depends on the service class. A Value Pack service (for example) includes debit and credit details to apply during the value pack subscription and/or renewal process.

A specific subscription context, applied when a subscriber subscribes to a service, then may (if the service is coded to allow it) amy allow service properties with subscription context.

This method merges the service properties with the subscription properties. This is a “deep merge” which means that at every hash level the subscription properties replace the service properties.

This method has no parameters.

The resulting context will never be nil, but it may be an empty table.