# Price Phase Task Utilization

Price Phase Tasks Video Demo

Price Phase Tasks allow computed pricing for any workload in any Cloud (even public Clouds) to be overridden based on custom logic designed by the user. The variable “spec” is fed into the Task which represents the Instance configuration. The Task can be designed to use the Instance config data and compute an appropriate price for the Instance. HPE Morpheus Enterprise expects a return payload in the format below for the price override to work correctly. If used, pricing computed via Task replaces any other costing data which would have been applied to the workload (such as pricing based on the Service Plan). The user will see price estimates based on the Price Phase Task in the Instance provisioning wizard where the Service Plan pricing would otherwise be shown. Additionally, since Workflows which invoke Price Phase Tasks are tied to the Layout, the user can see different pricing depending on which Instance Type Layout is selected.

NOTE

Price Phase Tasks are only invoked if the Workflow is tied to a Layout.

The return payload should be a JSON array of “priceData” objects. priceData objects should contain values for each of the keys in the table below:

| Key | Description | Data Type | Possible Values |
| --- | --- | --- | --- |
| incurCharges | Indicates the Instance state when this charge should be applied | String | **Running:** Charge is incurred while the workload is in a running state, **Stopped:** Charge is incurred while the workload is in a stopped or shutdown state, **Always:** This charge is always applied. Some charges may apply simultaneously, for example, “Always” and “Running” states will apply while the workload is running. |
| currency | Indicates the currency in which the charge will be applied | String | Enter any three‐letter currency code which HPE Morpheus Enterprise supports for its pricing, such as “USD”, “CAD”, or “GBP” |
| unit | Indicates the time interval at which the charge is applied | String | Enter “minute”, “hour”, “day”, “month”, or “year” |
| cost | Indicates the amount applied as cost for each configured time unit interval that passes. This is the cost to you, not the price with markup which the customer would see. | Number | A numerical amount such as “3.00” or “34.23” |
| price | Indicates the amount applied as price for each configured time unit interval that passes. This is the price to the customer with any built‐in markup you need to apply. | Number | A numerical amount such as “3.00” or “34.23” |

A number of different Task types could be used in this phase. As long as the Task is returning the required JSON array, the Task will work correctly. Below is an example using a Groovy Task. This is simply outputting a static payload though in a real world scenario you’d likely use Task logic to output a dynamic array based on the Instance configuration.

```
```
def rtn = [  
  priceData: [  
    [  
      incurCharges: 'always',  
      currency: 'USD',  
      unit: 'hour',  
      cost: 2.0,  
      price: 2.0  
    ],  
    [  
      incurCharges: 'running',  
      currency: 'USD',  
      unit: 'hour',  
      cost: 3.0,  
      price: 3.0  
    ],  
    [  
      incurCharges: 'stopped',  
      currency: 'USD',  
      unit: 'hour',  
      cost: 1.0,  
      price: 1.0  
    ]  
  ]  
]  
return rtn
```
```
