ServiceSubscriptions

private~ ServiceSubscriptions

ServiceSubscriptions class

Constructor

new ServiceSubscriptions()

Source:

Extends

Methods

(async) authorize(authorizer, agreement, optsopt) → {string}

Source:

Authorize a private plan. Using this over a non-private plan is safe.

Parameters:
Name Type Attributes Description
authorizer Object

Authorizer, must match the authorizer address in Daisy dashboard.

Properties
Name Type Description
privateKey string

Buffer, use Buffer.from("PRIVATE_KEY", "hex").

agreement Object

From module:browser.DaisySDKToken#sign.

opts Object <optional>

Additional options.

Properties
Name Type Attributes Default Description
allowAnyAddress boolean <optional>
false

True if any address can use the authorizer signature to join a private plan.

Returns:
Type
string

(async) createInvitation(plan, paramsopt) → {Promise.<Invitation>}

Source:

Create an invitation link

Parameters:
Name Type Attributes Default Description
plan Object | string

Plan object or plan.id string.

params Object <optional>
{}

Invitation attributes.

Properties
Name Type Attributes Default Description
active Boolean <optional>
true

Is public available or not.

maxUsages Number <optional>
0

Invitation max allowed usages. Set to 0 for unlimited.

callbackExtra Object <optional>
{}

Extra payload, helpful to identify the user.

callbackURL String <optional>

Callback URL to receive Daisy ID from the subscription

redirectURLDefault String <optional>

On success default redirect button.

Returns:
  • Invitation object with public link and identifier.
Type
Promise.<Invitation>

(async) getData() → {Promise.<SubscriptionManager>}

Source:
Inherited From:

Get Subscription Manager data and plans.

Example
const subscriptionProduct = new SubscriptionProductClient({
  identifier: process.env.DAISY_ID,
});
const { plans, ...manager } = await subscriptionProduct.getData();
Returns:
  • Subscription Manager and Plans given the manager in the constructor.
Type
Promise.<SubscriptionManager>

getPlans()

Source:
Inherited From:
Deprecated:

(async) getReceipts(criteria) → {Promise.<Array.<Receipt>>}

Source:
Inherited From:

Get receipts from single subscription.

Parameters:
Name Type Description
criteria Object

Filtering criteria, only one field is required.

Properties
Name Type Description
daisyId string

Find Subscription based on a Daisy ID.

onChainId string

Find Subscription based on a onChainId in the blockchain.

Returns:
  • Receipts.
Type
Promise.<Array.<Receipt>>

(async) getSubscription(criteria) → {Promise.<?Subscription>}

Source:
Inherited From:

Get single subscription.

Example
const subscriptionProduct = new SubscriptionProductClient({
  identifier: process.env.DAISY_ID,
});
const subscription = await subscriptionProduct.getSubscription({ id: "" });
Parameters:
Name Type Description
criteria Object

Filtering criteria, only one field is required.

Properties
Name Type Description
daisyId string

Find Subscription based on a Daisy ID.

onChainId string

Find Subscription based on a onChainId in the blockchain.

Returns:
  • Subscription found.
Type
Promise.<?Subscription>

(async) getSubscriptions(filter) → {Promise.<Array.<Subscription>>}

Source:
Inherited From:

Get subscriptions.

Example
const subscriptionProduct = new SubscriptionProductClient({
  identifier: process.env.DAISY_ID,
});
const subscriptions = await subscriptionProduct.getSubscriptions({ account: "0x0..." });
Parameters:
Name Type Description
filter Object

Filtering criteria.

Properties
Name Type Description
account string

Filter by Ethereum address.

state string

Filter by subscription state.

Returns:
  • Subscriptions based on the filtering criteria.
Type
Promise.<Array.<Subscription>>

(async) submit(input) → {Promise.<Subscription>}

Source:
Inherited From:

Create single subscription.

Example
const subscriptionProduct = new SubscriptionProductClient({
  identifier: process.env.DAISY_ID,
});
const subscription = await subscriptionProduct.submit({ });
Parameters:
Name Type Description
input Object

Input arguments

Properties
Name Type Attributes Description
agreement Object

The agreement is the return of module:browser.DaisySDKToken#sign.

receipt Object <optional>

Optional. The receipt is the return of module:browser.DaisySDKToken#approve.

signature string

The signature is the return of module:browser.DaisySDKToken#sign.

Returns:
Type
Promise.<Subscription>

(async) submitCancel(input) → {Promise.<Subscription>}

Source:
Inherited From:

Submit signature and agreement from the beneficiary user to cancel a subscription.

Parameters:
Name Type Description
input Object

Input arguments

Properties
Name Type Description
agreement Object

The agreement is the return of module:browser.DaisySDKToken#signCancel.

signature string

The signature is the return of module:browser.DaisySDKToken#signCancel.

Returns:
Type
Promise.<Subscription>