Payment Upon IoT

payment-upon-iot@0.6.0 Contract ^0.20.0 ae0fbb7876538e4733cb03dc699b7a50c20fe9caf8740fdb1f4125a218acd893

This is a payment contract that pays out a fixed amount each time a button is pressed.

Download Archive Open in Template Studio

Payment upon IoT Button Press

This is template pays out a fixed amount each time a button is pressed.

It responds to:

  • single press : increments a counter by 1
  • double press : decrements a counter by 1
  • long press : pays out based on the current counter and resets the counter to 0

Template Text

Grammar

Upon long button press, {{buyer}} shall pay to {{seller}} {{amountPerUnit}} for each short button press. A maximum of {{paymentCount}} payments may be made before this contract is COMPLETED.

Note: to undo a short button press the buyer may double-press the button.

Sample

Upon long button press, "Dan" shall pay to "Grant" 10 USD for each short button press. A maximum of 5 payments may be made before this contract is COMPLETED.

Note: to undo a short button press the buyer may double-press the button.

Sample Data

{
    "$class": "org.accordproject.payment.iot.PaymentUponButtonContract",
    "contractId": "f31b06d7-0e8b-4ffc-b317-bd960fd235bc",
    "buyer": {
        "$class": "org.accordproject.cicero.contract.AccordParty",
        "partyId": "Dan"
    },
    "seller": {
        "$class": "org.accordproject.cicero.contract.AccordParty",
        "partyId": "Grant"
    },
    "amountPerUnit": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 10,
        "currencyCode": "USD"
    },
    "paymentCount": 5
}

Template Model

Model Dependencies

Template Logic

Find the full logic for this template on on GitHub.

State Types

Type Sample JSON
org.accordproject.payment.iot.CounterState
{
    "$class": "org.accordproject.payment.iot.CounterState",
    "status": "INITIALIZED",
    "counter": 41.593,
    "paymentCount": 14.92,
    "stateId": "feabfbd2-ff3e-11e9-b361-efc0ae54bdd6"
}

Request Types

Type Sample JSON
org.accordproject.iot.DoubleButtonPress
{
    "$class": "org.accordproject.iot.DoubleButtonPress",
    "serialNumber": "Nostrud dolore officia.",
    "batteryVoltage": "Duis labore pariatur.",
    "transactionId": "feabadb2-ff3e-11e9-b361-efc0ae54bdd6",
    "timestamp": "2019-11-04T15:09:23.723-05:00"
}
org.accordproject.iot.LongButtonPress
{
    "$class": "org.accordproject.iot.LongButtonPress",
    "serialNumber": "Ut pariatur aute occaecat nostrud.",
    "batteryVoltage": "Proident.",
    "transactionId": "feabadb3-ff3e-11e9-b361-efc0ae54bdd6",
    "timestamp": "2019-11-04T15:09:23.723-05:00"
}
org.accordproject.iot.SingleButtonPress
{
    "$class": "org.accordproject.iot.SingleButtonPress",
    "serialNumber": "Veniam ex.",
    "batteryVoltage": "Amet proident qui mollit.",
    "transactionId": "feabadb1-ff3e-11e9-b361-efc0ae54bdd6",
    "timestamp": "2019-11-04T15:09:23.723-05:00"
}
org.accordproject.payment.iot.MonetaryAmountPayment
{
    "$class": "org.accordproject.payment.iot.MonetaryAmountPayment",
    "amount": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 199.1,
        "currencyCode": "MAD"
    },
    "transactionId": "feabadb4-ff3e-11e9-b361-efc0ae54bdd6",
    "timestamp": "2019-11-04T15:09:23.723-05:00"
}
org.accordproject.signature.ContractSigned
{
    "$class": "org.accordproject.signature.ContractSigned",
    "contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#9426",
    "transactionId": "feabadb0-ff3e-11e9-b361-efc0ae54bdd6",
    "timestamp": "2019-11-04T15:09:23.723-05:00"
}

Response Types

Type Sample JSON
org.accordproject.cicero.runtime.Response
{
    "$class": "org.accordproject.cicero.runtime.Response",
    "transactionId": "feabd4c4-ff3e-11e9-b361-efc0ae54bdd6",
    "timestamp": "2019-11-04T15:09:23.724-05:00"
}

Events Types

Type Sample JSON
org.accordproject.base.Event
{
    "abstract": "this is an abstract type"
}
org.accordproject.cicero.runtime.PaymentObligation
{
    "$class": "org.accordproject.cicero.runtime.PaymentObligation",
    "amount": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 42.78,
        "currencyCode": "LKR"
    },
    "description": "Veniam qui pariatur mollit.",
    "contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#3219",
    "promisor": "resource:org.accordproject.cicero.contract.AccordParty#4969",
    "promisee": "resource:org.accordproject.cicero.contract.AccordParty#7366",
    "deadline": "2019-11-04T15:09:23.725-05:00",
    "eventId": "feabfbd3-ff3e-11e9-b361-efc0ae54bdd6",
    "timestamp": "2019-11-04T15:09:23.725-05:00"
}

Technical Integration

Please refer to the Cicero documentation for details and examples of how to integrate a call to a Cicero template into your application.

View the Latest code for this template on GitHub.