Payment Upon IoT

payment-upon-iot@0.5.1 Contract ^0.13.0 8fd09d940cab57886fb8023e6fffcf30c1752a3cd9b5df1c7ea08483054b07b8

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

Download Archive Open in Template Studio Open in VSCode Web

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

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.
          

Model Dependencies

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 on GitHub.

Sample Instance

{
    "$class": "org.accordproject.payment.iot.PaymentUponButtonContract",
    "contractId": "a525166e-c255-4604-b66f-98773d51eb9a",
    "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
}

State Types

Type Sample JSON
org.accordproject.payment.iot.CounterState
{
    "$class": "org.accordproject.payment.iot.CounterState",
    "status": "INITIALIZED",
    "counter": 199.599,
    "paymentCount": 153.2,
    "stateId": "2e42d1d2-b399-11e9-a415-2f2abeed0243"
}

Request Types

Type Sample JSON
org.accordproject.iot.DoubleButtonPress
{
    "$class": "org.accordproject.iot.DoubleButtonPress",
    "serialNumber": "Elit in.",
    "batteryVoltage": "Consectetur ipsum do magna.",
    "transactionId": "2e423591-b399-11e9-a415-2f2abeed0243",
    "timestamp": "2019-07-31T09:43:29.897-04:00"
}
org.accordproject.iot.LongButtonPress
{
    "$class": "org.accordproject.iot.LongButtonPress",
    "serialNumber": "Officia amet voluptate amet pariatur.",
    "batteryVoltage": "Veniam tempor.",
    "transactionId": "2e423592-b399-11e9-a415-2f2abeed0243",
    "timestamp": "2019-07-31T09:43:29.897-04:00"
}
org.accordproject.iot.SingleButtonPress
{
    "$class": "org.accordproject.iot.SingleButtonPress",
    "serialNumber": "Excepteur aute nulla.",
    "batteryVoltage": "Sunt sit.",
    "transactionId": "2e423590-b399-11e9-a415-2f2abeed0243",
    "timestamp": "2019-07-31T09:43:29.897-04:00"
}
org.accordproject.payment.iot.MonetaryAmountPayment
{
    "$class": "org.accordproject.payment.iot.MonetaryAmountPayment",
    "amount": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 140.518,
        "currencyCode": "TTD"
    },
    "transactionId": "2e423593-b399-11e9-a415-2f2abeed0243",
    "timestamp": "2019-07-31T09:43:29.897-04:00"
}
org.accordproject.signature.ContractSigned
{
    "$class": "org.accordproject.signature.ContractSigned",
    "contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#5269",
    "transactionId": "2e420e80-b399-11e9-a415-2f2abeed0243",
    "timestamp": "2019-07-31T09:43:29.896-04:00"
}

Response Types

Type Sample JSON
org.accordproject.cicero.runtime.Response
{
    "$class": "org.accordproject.cicero.runtime.Response",
    "transactionId": "2e4283b0-b399-11e9-a415-2f2abeed0243",
    "timestamp": "2019-07-31T09:43:29.899-04: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": 255.186,
        "currencyCode": "JOD"
    },
    "description": "Laboris.",
    "contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#6638",
    "promisor": "resource:org.accordproject.cicero.contract.AccordParty#8783",
    "promisee": "resource:org.accordproject.cicero.contract.AccordParty#5799",
    "deadline": "2019-07-31T09:43:29.901-04:00",
    "eventId": "2e42d1d3-b399-11e9-a415-2f2abeed0243",
    "timestamp": "2019-07-31T09:43:29.901-04:00"
}