New Page
Easy PV and Heatpunk generate a full bill of materials for a project, and for our UK and Ireland sites you can very quickly place an order for the components from Midsummer. So you may like to import the shopping cart into your application and display an ordering link. Users love the ease of ordering all the kit for an installation.
The cart is based on the bill of materials generated by the software for a given project. The bill of materials for the project is refreshed every time the overview page of the project is opened by a user in Easy PV or Heatpunk.
To fetch project data, including the cart and order link, use the api/v1/projects/data
endpoint. You need to pass in the project ID, and the user you are acting as. The user must have view rights to the project.
Sample request:
curl --location 'https://heatpunk.co.uk/api/v1/projects/data?projectId=[YOUR PROJECT ID]&userEmail=[YOUR USER EMAIL]' \
--header 'accept: application/json' \
--header 'X-API-KEY: [YOUR API KEY]'
What to expect in the response:
You will get back an object which includes projectData
, a cart
array and a midsummerOrderLink
string.
ProjectData
The projectData
array will include core project and customer information. For example:
"projectData": {
"lat": 52.2305742,
"lng": 0.14036,
"zoom": 19,
"address": "101 Kings Hedges Rd, Cambridge , UK",
"postcode": "CB4 2QD",
"dateCreated": "2024-10-02 17:42:45",
"dateModified": "2024-10-17 14:11:58",
"projectName": "Sample Project",
"customerName": "Testing Testington",
"includeTerrain": false,
"MCSSiteVisitDisclaimer": false,
"geography": {
"altitude": 12,
"distance": "2to20",
"hillSlope": null,
"hillZone": null,
"terrain": "country",
"topography": "no",
"windZone": 3,
"snowZone": 2
},
"projectType": "three-d-model",
"magicMode": true,
"customerPhone": "0777 777 777",
"customerEmail": "testing@testington.com",
"userID": "19380",
"status": "Lead",
"mapImagery": {
"selectedType": "orthorectified",
"orthorectified": {
"fileId": "rG2G25",
"rotationUsed": 2.2618198,
"radius": 48.137703120171004
}
},
"projectID": "986206",
"MCSDisclaimer": true,
"MCSReservedCapacity": 50,
"MCSAdditionalConsumption": 0,
"MCSConsumption": "3500",
"MCSOccupancy": "home all day",
"totalConsumption": 3500,
"selfConsumption": 980.7616984962381,
"threeDModelSettingsViewDirection": [
-4.3836904133806645,
-6.107308078177546,
10.644089349920092,
0.054191298862051804,
2.2301402617071955,
2.241462631675495
],
"threeDSnapshots": [
"l6Jskm"
],
}
Cart
The cart
array contains the full bill of materials as a JSON object. This contains details of all the products that have been specified in the project. For example:
"cart": [
{
"name": "Jinko Tiger Neo 440W N-Type All Black Mono solar panel",
"qty": 6,
"item": 84,
"line": 504,
"dbID": "5265",
"availableFrom": {
"midsummer": {
"ID": "5265",
"price": 504
}
}
},
{
"name": "Growatt MIN 10000 TL-X2 Three MPPT 1ph inverter",
"qty": 1,
"item": 1050,
"line": 1050,
"dbID": "5397",
"availableFrom": {
"midsummer": {
"ID": "5397",
"price": 1050
}
}
},
{
"name": "Giv.AC 3.0 inverter",
"qty": 1,
"item": 933.8,
"line": 933.8,
"dbID": "3040",
"availableFrom": {
"midsummer": {
"ID": "3040",
"price": 933.8
}
}
},
{
"name": "GivEnergy 5.2kWh LiFePO4 Battery",
"qty": 1,
"item": 1796.2,
"line": 1796.2,
"dbID": "4284",
"availableFrom": {
"midsummer": {
"ID": "4284",
"price": 1796.2
}
}
},
]
midsummerOrderLink
The midsummerOrderLink
is a URL that can be used to order everything needed for a project from Midsummer. For example:
"midsummerOrderLink": "https://midsummerwholesale.co.uk/upload/?order=eyJpdGVtcyI6eyI3OCI6eyJ0aXRsZSI6IkxhYmVsIHNoZWV0IiwicXR5IjoyfSwiMzgwIjp7InRpdGxlIjoiMTAwbSByZWVsIG9mIDZtbTIgc29sYXIgY2FibGUiLCJxdHkiOjF9LCIxNzc5Ijp7InRpdGxlIjoiTUM0IDZtbSBDb25uZWN0b3IgUGFpciIsInF0eSI6NH0sIjIyOTgiOnsidGl0bGUiOiJUaWdvIFJldHJvZml0IEZyYW1lIE1vdW50ZWQgT3B0aW1pc2VyIFRTNC1BLU8iLCJxdHkiOjZ9LCIyNTg2Ijp7InRpdGxlIjoiRmFzdGVuc29sIHJhaWwgc3BsaWNlIiwicXR5Ijo2fSwiMjU4NyI6eyJ0aXRsZSI6IkZhc3RlbnNvbCByYWlsIGJvbHQiLCJxdHkiOjZ9LCIyNTk0Ijp7InRpdGx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I6eyJ0aXRsZSI6IkppbmtvIFRpZ2VyIE5lbyA0NDBXIE4tVHlwZSBBbGwgQmxhY2sgTW9ubyBzb2xhciBwYW5lbCIsInF0eSI6Nn0sIjUyNzYiOnsidGl0bGUiOiJGYXN0ZW5zb2wgc2lsdmVyIHJhaWwgMzU1MG1tIiwicXR5Ijo3fSwiNTM5NyI6eyJ0aXRsZSI6Ikdyb3dhdHQgTUlOIDEwMDAwIFRMLVgyIFRocmVlIE1QUFQgMXBoIGludmVydGVyIiwicXR5IjoxfSwiNTU2MSI6eyJ0aXRsZSI6IkdpdkVuZXJneSBHRU0xMjBDVCBNb2RidXMgRW5lcmd5IE1ldGVyIiwicXR5IjoxfSwiIjp7InRpdGxlIjoiTWF0dCBTY2FmZm9sZGluZyBvdmVyIGNvbnNlcnZhdG9yeSIsInF0eSI6MX0sIjI2NDgjMzU5MCI6eyJ0aXRsZSI6IkZhc3RlbnNvbCBibGFjayBlbmQgY2FwIiwicXR5IjoxMn19LCJ0cmFjZSI6eyJzcmMiOiJlYXN5LXB2IiwibW9kZSI6InVrIiwicHJvamVjdElEIjoiOTg2MjA2In19",
Customise cart and order links
If you wish to modify the bill of materials for a project and create your own cart
object, you can use this to generate a custom order link. If you do this, you can also add some additional parameters such as a delivery address or order reference to the order (see instructions in the next section).
In its simplest form, an order can be just an object with an 'items' property. For each item, specify the the products by providing the product ID and the quantity required.
const order = {
"items": {
"2586": {
"qty": 99
},
"4258": {
"qty": 99
}
}
}
Here is a more complex order, with a shipping address, despatch date and reference:
const order = {
"items": {
"2586": {
"qty": 99
},
},
"deliveryOption": "standard",
"shippingAddress": {
"postcode": "CB24 6AZ",
"add1": "Midsummer Energy",
"add2": "Cambridge Road Industrial Estate",
"add3": "Milton",
"add4": "",
"email": "sales@midsummerenergy.co.uk",
"phone": "01223 858414",
"firstname": "Andy",
"lastname": "Rankin"
},
"despatchDate": "2023-02-08",
"reference": "trial order"
}
Once you have created the JSON object containing the products required for the project you can create an order string by following these steps:
- Stringify the object
- Base64 encode the result of the stringified object
- URL encode the base64 encoded string
- Append your string to the following URL to create your custom order link
https://midsummerwholesale.co.uk/upload?order=[result string]
In JavaScript the function you need to generate an order is:
function createOrderLink(order) {
return "https://midsummerwholesale.co.uk/upload?order="+encodeURIComponent(btoa(JSON.stringify(order)))
}