Issue, adjust and submit a Purchase Order

Here we will practice with a simple Deal for two parties. You will learn how to create Deal, switch Deal steps and how the information will spread between parties.

On each step you will send API commands exactly as the participants would. For this case we keep a private blockchain network. Each party has its own node. In real life these would be nodes of decentralised apps (e.g. cargo tracking platform).

This case demonstrates the distribution of a transaction among nodes and switching the status of a transaction. It uses a predefined smart contract with the FirstDeal transaction type.

How to start

To run Purchase Order scenario you can use any command-line tool for IT-savvy users. We recommend using cURl. Find more at our Tools guide.

Transaction parties

  • Buyer
  • Seller

Scenario overview

Buyer issues a Purchase Order to the outside Seller, initiating the sales transaction. Buyer provides the Purchase Order with the following information:

  • Number of the Purchase Order
  • Items being purchased
  • Delivery date
  • Quantity and other payment terms, ship-to address, invoicing instructions and the name of the purchasing office. Seller makes adjustments (if allowed to) and accepts the purchase order (it becomes a binding contract on both buyer and seller).

Status transition map (non-controlled)

  • Created
  • Issued
  • Adjusted
  • Ordered

The script consists of the following sequential steps:

  1. At Buyer node create a Deal with the following attributes: DocNumber=123, Item=Pepper, DeliveryDate=2020-08-08, Quantity=10 (Buyer - QRM1,HLF1, ETH1)
  2. At Buyer node change the Deal status to Issued (Buyer - QRM1,HLF1, ETH1)
  3. Get the GLobal Deal Identifier (Buyer - QRM1,HLF1, ETH1)
  4. Make sure on Seller node the Deal status is Issued (Seller - QRM2,HLF2, ETH2)
  5. At Seller node change the Deal status to Adjusted, add attribute PaymentDate=2020-01-02 and change attribute DeliveryDate=2020-08-09 (Seller)
  6. Make sure at Buyer node the Deal status is Adjusted (Buyer)
  7. At Buyer node change the Deal status to Ordered (Buyer)
  8. Make sure at Seller node the Deal status is Ordered (Seller)

Pre-adjustment

Attention!

In the call case the ID is replaced with (UID) word - you need to replace it with your obtained ID when creating the Deal at Step 1.

Attention!

In queries in the headers CHANNEL, AUHORIZATION you must use the personal identifier you received during registration. This will allow not to interfere with the simultaneous work of several users, as well as facilitate the work of the Technical Support service if you have any questions. The query examples use the personal identifier Demo.

For more information about authorization, visit API: Authorization Page

If you run into any error, visit API: Errors Page

1. Create a Deal

Variables needed:

  • CHANNEL
  • AUTHORIZATION

Use POST-method call /api/deals/. Buyer node - QRM1,HLF1, ETH1. The json specification of the transaction is indicated as the request data. In our case:

Body data

{
  "kind": "FirstDeal",
  "parties": [
    {
      "key": "QRM1",
      "role": "Buyer"
    },
    {
      "key": "QRM2",
      "role": "Seller"
    }
  ],
  "parameters": [
    {
      "key": "DocNumber",
      "value": "123"
    },
    {
      "key": "Item",
      "value": "Pepper"
    },
    {
      "key": "DeliveryDate",
      "value": "2020-08-08"
    },
    {
      "key": "Quantity",
      "value": "10"
    }
  ]
}

Call example


curl -X POST "http://qrm1.kekker.com/api/deals"
-H "Accept: application/json"
-H "x-api-version: 2.0"
-H "Channel: 
" -H "Content-Type: application/json" -H "Authorization:
" -d " { \"kind\": \"FirstDeal\", \"parties\": [ { \"key\": \"QRM1\", \"role\": \"Buyer\" }, { \"key\": \"QRM2\", \"role\": \"Seller\" } ], \"parameters\": [ { \"key\": \"DocNumber\", \"value\": \"123\" }, { \"key\": \"Item\", \"value\": \"Pepper\" }, { \"key\": \"DeliveryDate\", \"value\": \"2020-08-08\" }, { \"key\": \"Quantity\", \"value\": \"10\" } ] }"

curl -X POST "http://hlf1.kekker.com/api/deals"
-H "Accept: application/json"
-H "x-api-version: 2.0"
-H "Channel: 
" -H "Content-Type: application/json" -H "Authorization:
" -d " { \"kind\": \"FirstDeal\", \"parties\": [ { \"key\": \"HLF1\", \"role\": \"Buyer\" }, { \"key\": \"HLF2\", \"role\": \"Seller\" } ], \"parameters\": [ { \"key\": \"DocNumber\", \"value\": \"123\" }, { \"key\": \"Item\", \"value\": \"Pepper\" }, { \"key\": \"DeliveryDate\", \"value\": \"2020-08-08\" }, { \"key\": \"Quantity\", \"value\": \"10\" } ] }"

curl -X POST "http://eth1.kekker.com/api/deals"
-H "Accept: application/json"
-H "x-api-version: 2.0"
-H "Channel: 
" -H "Content-Type: application/json" -H "Authorization:
" -d " { \"kind\": \"FirstDeal\", \"parties\": [ { \"key\": \"ETH1\", \"role\": \"Buyer\" }, { \"key\": \"ETH2\", \"role\": \"Seller\" } ], \"parameters\": [ { \"key\": \"DocNumber\", \"value\": \"123\" }, { \"key\": \"Item\", \"value\": \"Pepper\" }, { \"key\": \"DeliveryDate\", \"value\": \"2020-08-08\" }, { \"key\": \"Quantity\", \"value\": \"10\" } ] }"

Response example

If everything is fine you'll receive the Queue identifier [QUEUID] and the Local Deal Identifier [LOCALDEALID] in the response body. Save them and add to further requests.

{
  "queueId": "QUEUEID",
  "localDealId": "LOCALDEALID"
}

2. At Buyer node change the Deal status to Issued

Variables needed:

  • CHANNEL
  • AUTHORIZATION
  • LOCALDEALID (from 1-st step)

Use POST-method call /api/deals/{LOCALDEALID} where {LOCALDEALID} is the Local Deal Identifier. Buyer node - QRM1, HLF1, ETH1. The JSON specification of the new Deal status is indicated as the request data. In our case:

Body data

{
   "status": "Issued"
}

Call example


curl -X POST "http://qrm1.kekker.com/api/deals/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Content-Type: application/json" -H "Authorization:
" -d " { \"status\": \"Issued\" }"

curl -X POST "http://hlf1.kekker.com/api/deals/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Content-Type: application/json" -H "Authorization:
" -d " { \"status\": \"Issued\" }"

curl -X POST "http://eth1.kekker.com/api/deals/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Content-Type: application/json" -H "Authorization:
" -d " { \"status\": \"Issued\" }"

Response example

If everything is fine you'll receive the Queue identifier [QUEUID] in the response body.

{QUEUEID}

3. Get the Global Deal Identifier

Variables needed:

  • CHANNEL
  • AUTHORIZATION
  • QUEUEID (from the 2-nd step)

Use GET-method call /api/queue/{QUEUEID}. Buyer node - QRM1,HLF1, ETH1

Call example


curl -X GET "http://qrm1.kekker.com/api/queue/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Authorization:
"

curl -X GET "http://hlf1.kekker.com/api/queue/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Authorization:
"

curl -X GET "http://eth1.kekker.com/api/queue/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Authorization:
"

Response example

If everything is fine you'll receive the Global Deal Identifier [DEALID] in the response body. Save it for later.

{
  "dealId": "DEALID",
  "localDealId": "LOCALDEALID",
  "queueId": "QUEUEID",
  "status": "Success"
}

4. Make sure on Seller node the Deal status is Issued

Variables needed:

  • CHANNEL
  • AUTHORIZATION
  • DEALID (from the 3-rd step)

Use GET-method call /api/deals/{DEALID} where {DEALID} is the Global Deal Identifier. Seller node - QRM2,HLF2, ETH2.

Attention!

Wait for 2 minutes after step [2] before executing these queries

Call example (the node URL is different)


curl -X GET "http://qrm2.kekker.com/api/deals/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Authorization:
"

curl -X GET "http://hlf2.kekker.com/api/deals/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Authorization:
"

curl -X GET "http://eth2.kekker.com/api/deals/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Authorization:
"

Response example (check status and parameters)

{
  "dealId": "DEALID",
  "localDealId": "LOCALDEALID",
  "kind": "FirstDeal",
  "version": 2,
  "status": "Issued",
  "parent": null,
  "parameters": [
    {
      "key": "DocNumber",
      "value": "123"
    },
    {
      "key": "Item",
      "value": "Pepper"
    },
    {
      "key": "DeliveryDate",
      "value": "2020-08-08"
    },
    {
      "key": "Quantity",
      "value": "10"
    }
  ],
  "parties": [
    {
      "key": "QRM1",
      "role": "Buyer"
    },
    {
      "key": "QRM2",
      "role": "Seller"
    }
  ],
  "transitions": [],
  "files": [],
  "history": [
    {
      "status": "Issued",
      "version": 2,
      "remark": "",
      "executor": "QRM1"
    }
  ]
}

5. At Seller node change the Deal status to Adjusted, add attribute PaymentDate and change attribute DeliveryDate

Variables needed:

  • CHANNEL
  • AUTHORIZATION
  • DEALID (from the 3-rd step)

Use POST-method call /api/deals/{DEALID} where {DEALID} is the Global Deal Identifier. Seller node - QRM2,HLF2, ETH2.

Body data

{
  "status": "Ajusted",
  "remark": "2",
  "parameters": [
    {
      "key": "PaymentDate",
      "value": "2020-01-02"
    },
    {
      "key": "DeliveryDate",
      "value": "2020-08-09"
    }
    ]
}

Call example


curl -X POST "http://qrm2.kekker.com/api/deals/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Content-Type: application/json" -H "Authorization:
" -d " { \"status\": \"Adjusted\", \"remark\": "2", \"parameters\": [ { \"key\": \"PaymentDate\", \"value\": \"2020-01-02\" }, { \"key\": \"DeliveryDate\", \"value\": \"2020-08-09\" } ] }"

curl -X POST "http://hlf2.kekker.com/api/deals/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Content-Type: application/json" -H "Authorization:
" -d " { \"status\": \"Adjusted\", \"remark\": "2", \"parameters\": [ { \"key\": \"PaymentDate\", \"value\": \"2020-01-02\" }, { \"key\": \"DeliveryDate\", \"value\": \"2020-08-09\" } ] }"

curl -X POST "http://eth2.kekker.com/api/deals/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Content-Type: application/json" -H "Authorization:
" -d " { \"status\": \"Adjusted\", \"remark\": "2", \"parameters\": [ { \"key\": \"PaymentDate\", \"value\": \"2020-01-02\" }, { \"key\": \"DeliveryDate\", \"value\": \"2020-08-09\" } ] }"

Response example

If everything is fine you'll receive the Queue identifier [QUEUID] in the response body.

{QUEUEID}

6. Make sure at Buyer node the Deal status is Adjusted

Variables needed:

  • CHANNEL
  • AUTHORIZATION
  • DEALID (from the 3-rd step)

Use GET-method call /api/deals/{DEALID} where {DEALID} is the Global Deal Identifier. Buyer node - QRM1,HLF1, ETH1.

Attention!

Wait for 2 minutes after step [4] before executing these queries

Call example


curl -X GET "http://qrm1.kekker.com/api/deals/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Authorization:
"

curl -X GET "http://hlf1.kekker.com/api/deals/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Authorization:
"

curl -X GET "http://eth1.kekker.com/api/deals/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Authorization:
"

Response example

{
  "dealId": "DEALID",
  "localDealId": "LOCALDEALID",
  "kind": "FirstDeal",
  "version": 3,
  "status": "Ajusted",
  "parent": null,
  "parameters": [
    {
      "key": "DocNumber",
      "value": "123"
    },
    {
      "key": "Item",
      "value": "Pepper"
    },
    {
      "key": "DeliveryDate",
      "value": "2020-08-09"
    },
    {
      "key": "Quantity",
      "value": "10"
    },
    {
      "key": "PaymentDate",
      "value": "2020-01-02"
    }
  ],
  "parties": [
    {
      "key": "QRM1",
      "role": "Buyer"
    },
    {
      "key": "QRM2",
      "role": "Seller"
    }
  ],
  "transitions": [],
  "files": [],
  "history": [
    {
      "status": "Issued",
      "version": 2,
      "remark": "",
      "executor": "QRM1"
    },
    {
      "status": "Ajusted",
      "version": 3,
      "remark": "2",
      "executor": "QRM2"
    }
  ]
}

7. At Buyer node change the Deal status to Ordered

Variables needed:

  • CHANNEL
  • AUTHORIZATION
  • DEALID (from the 3-rd step)

Use POST-method call /api/deals/{DEALID} where {DEALID} is the Global Deal Identifier. Buyer node - QRM1,HLF1, ETH1.

Body data

{
  "status": "Ordered"
}

Call example


curl -X POST "http://qrm1.kekker.com/api/deals/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Content-Type: application/json" -H "Authorization:
" -d " { \"status\": \"Ordered\" }"

curl -X POST "http://hlf1.kekker.com/api/deals/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Content-Type: application/json" -H "Authorization:
" -d " { \"status\": \"Ordered\" }"

curl -X POST "http://eth1.kekker.com/api/deals/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Content-Type: application/json" -H "Authorization:
" -d " { \"status\": \"Ordered\" }"

Response example

If everything is fine you'll receive the Queue identifier [QUEUID] in the response body.

{QUEUEID}

8. Make sure on Seller node the Deal status is Ordered

Variables needed:

  • CHANNEL
  • AUTHORIZATION
  • DEALID (from the 3-rd step)

Use GET-method call /api/deals/{DEALID} where {DEAL} is the Global Deal Identifier. Seller node - QRM2,HLF2, ETH2.

Attention!

Wait for 2 minutes after step [2] before executing these queries

Call example (the node URL is different)


curl -X GET "http://qrm2.kekker.com/api/deals/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Authorization:
"

curl -X GET "http://hlf2.kekker.com/api/deals/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Authorization:
"

curl -X GET "http://eth2.kekker.com/api/deals/
" -H "Accept: application/json" -H "x-api-version: 2.0" -H "Channel:
" -H "Authorization:
"

Response example (check status and parameters)

{
  "dealId": "DEALID",
  "localDealId": "LOCALDEALID",
  "kind": "FirstDeal",
  "version": 4,
  "status": "Ordered",
  "parent": null,
  "parameters": [
    {
      "key": "DocNumber",
      "value": "123"
    },
    {
      "key": "Item",
      "value": "Pepper"
    },
    {
      "key": "DeliveryDate",
      "value": "2020-08-09"
    },
    {
      "key": "Quantity",
      "value": "10"
    },
    {
      "key": "PaymentDate",
      "value": "2020-01-02"
    }
  ],
  "parties": [
    {
      "key": "QRM1",
      "role": "Buyer"
    },
    {
      "key": "QRM2",
      "role": "Seller"
    }
  ],
  "transitions": [],
  "files": [],
  "history": [
    {
      "status": "Issued",
      "version": 2,
      "remark": "",
      "executor": "QRM1"
    },
    {
      "status": "Ajusted",
      "version": 3,
      "remark": "2",
      "executor": "QRM2"
    },
    {
      "status": "Ordered",
      "version": 4,
      "remark": "",
      "executor": "QRM1"
    }
  ]
}

Test the platform’s powerful features now

By submitting this form, you confirm that you have read and agree to our privacy policy and terms of service