Magazine Subscription

DOCUMENTSFINANCIAL

Contract purpose

This Smart Contract manages the subscriptions for a magazine.

There are 4 types of subscriptions, identified by indices from 0 to 3: monthly/yearly subscription for adults and monthly/yearly subscription for students

Contract parameters

monthlyAdultPrice: the monthly price of a subscription for an adult

yearlyAdultPrice : the yearly price of a subscription for an adult

monthlyStudentPrice: the monthly price of a subscription for a student

yearlyStudentPrice: the yearly price of a subscription for a student

Exposed methods and variables

manager address of the contract creator

subscribe called by anyone who wants to become a subscriber. The function returns the subscription index and the price the user has to pay and it emits the newSubscriber event.

parameter nametypedetails
_namestringthe person's name
_startDateintegerthe date when the subscription starts (unix epoch time
_typeintegercan be 0,1,2 or 3 and defines what kind of subscription the user chose

paySubscription payable function called by a subscriber to pay for the service and it shows him the date (unix time) of his most recent payment. It also emits the subscriptionPaid event.

parameter nametypedetails
_idintegerthe subscription index

getSubscriber this function is called by the manager to check the details about a particular subscriber

parameter nametypedetails
_idintegerthe subscription index

showMySubType allows the subscriber to check the type of his subscription

parameter nametypedetails
_idintegerthe subscription index

changeSubType allows the subscriber to change the type of his subscription

parameter nametypedetails
_idintegerthe subscription index
_newTypeintegerthe new index for the subscription type

cancelSubscription allows the testator to increase the amount of savings he previously set

parameter nametypedetails
_idintegerthe subscription index

transferMoney allows the manager to transfer a particular amount of money from the contract's balance to its account.

parameter nametypedetails
_amountintegerthe amount of money sent to the manager's address

Events

newSubscriber

parameter nametypedetails
indexintegerindex of the subscription

subscriptionPaid

parameter nametypedetails
payerethereum addressaddress of the subscriber
indexintegerindex of the subscription

subscriptionCanceled

parameter nametypedetails
indexintegerindex of the subscription
cancelDateintegerthe cancellation date (unix epoch time)
lastPaidintegerthe date of the last payment for this subscription (unix epoch time)
Buy
Reviewed by Modex
Buy Contract Test Contract

Create an account or login to purchase this smart contract