Subscription Contracts
For providers users
Subscription Contracts is the main contract that allow providers users to interact with the providers created app.
View Methods
isMySubscriber
function isMySubscriber(
uint256 _appId,
address _user
)
Returns user subscription information for check if a specific address is a user of specific app.
Return values :
isSubscriber
bool
True if user is a current subscriber of the app, false if not.
isTrialSubscriber
bool
True if user is a trial subscriber of the app, false if not
paymentId
bytes32
The id of the payment that is used in the subscription
subscriptionId
bytes32
The subscription id
paymentDue
function paymentDue(bytes32 _subscriptionId)
Returns subscription status
Return values :
isDue
bool
True, if it is the time for user to pay, false if not.
isOver
bool
True if the user has not paid and the subscription must be stopped.
Write Methods
createSubscription
function createSubscription(
uint256 _appId,
bytes32 _paymentId,
address _token,
uint256 _userChoosenPeriod
)
Subscribe to an app
cancelSubscription
function cancelSubscription(
bytes32 _subscriptionId,
uint256 _appId
)
Stop subscription
processSubscription
function processSubscription(bytes32 _subscriptionId)
Restart subscription if stopped.
renewSubscription
function renewSubscription(bytes32 _subscriptionId)
Renewal of the subscription if it has expired.
migrateToNewPayment
function migrateToNewPayment(
bytes32 _subscriptionId,
bytes32 _newPayment,
address _token
)
Migrate existing subscripiton to a new payment
refundSubscription
function refundSubscription(bytes32 _subscriptionId)
Pay subscription all at once
Events & ABI
event NewSubscription(
address subscriber,
uint256 indexed appId,
bytes32 subscriptionId
)
event TrialSubscription(
address subscriber,
uint256 indexed appId,
bytes32 subscriptionId
);
event SubscriptionCancelled(
address subscriber,
uint256 indexed appId,
bytes32 subscriptionId
);
event SubscriptionProcessed(
address subscriber,
uint indexed appId,
bytes32 subscriptionId
);
event RefundSubscription(
address subscriber,
uint256 indexed appId,
bytes32 subscriptionId
);
event RenewSubscription(
address subscriber,
uint256 indexed appId,
bytes32 subscriptionId
);
[
{
"name": "NewSubscription",
"type": "event",
"anonymous": false,
"inputs": [
{
"type": "address",
"name": "subscriber",
"indexed": false
},
{
"type": "uint256",
"name": "appId",
"indexed": true
},
{
"type": "bytes32",
"name": "subscriptionId",
"indexed": false
}
]
}
]
Last updated