# Google Cloud Retail V2 Client - Class PurchaseTransaction (2.5.3)

2.5.3 (latest) 2.5.2 2.4.0 2.3.1 2.2.1 2.1.3 2.0.0 1.7.0 1.6.4 1.5.0 1.4.2 1.3.1 1.2.1 1.1.1 1.0.1 Reference documentation and code samples for the Google Cloud Retail V2 Client class PurchaseTransaction.

A transaction represents the entire purchase transaction.

Generated from protobuf message `google.cloud.retail.v2.PurchaseTransaction`

## Namespace

Google \\ Cloud \\ Retail \\ V2

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ id` | `string` The transaction ID with a length limit of 128 characters. |
| `↳ revenue` | `float` Required. Total non-zero revenue or grand total associated with the transaction. This value include shipping, tax, or other adjustments to total revenue that you want to include as part of your revenue calculations. |
| `↳ tax` | `float` All the taxes associated with the transaction. |
| `↳ cost` | `float` All the costs associated with the products. These can be manufacturing costs, shipping expenses not borne by the end user, or any other costs, such that: \* \* Profit = [revenue](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.PurchaseTransaction#_Google_Cloud_Retail_V2_PurchaseTransaction__getRevenue__) - [tax](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.PurchaseTransaction#_Google_Cloud_Retail_V2_PurchaseTransaction__getTax__) - [cost](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.PurchaseTransaction#_Google_Cloud_Retail_V2_PurchaseTransaction__getCost__) |
| `↳ currency_code` | `string` Required. Currency code. Use three-character ISO-4217 code. |

### getId

The transaction ID with a length limit of 128 characters.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setId

The transaction ID with a length limit of 128 characters.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getRevenue

Required. Total non-zero revenue or grand total associated with the
transaction. This value include shipping, tax, or other adjustments to
total revenue that you want to include as part of your revenue
calculations.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `float` |   |

### setRevenue

Required. Total non-zero revenue or grand total associated with the
transaction. This value include shipping, tax, or other adjustments to
total revenue that you want to include as part of your revenue
calculations.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `float` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getTax

All the taxes associated with the transaction.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `float` |   |

### setTax

All the taxes associated with the transaction.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `float` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getCost

All the costs associated with the products. These can be manufacturing
costs, shipping expenses not borne by the end user, or any other costs,
such that:

- Profit = [revenue](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.PurchaseTransaction#_Google_Cloud_Retail_V2_PurchaseTransaction__getRevenue__) - [tax](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.PurchaseTransaction#_Google_Cloud_Retail_V2_PurchaseTransaction__getTax__) - [cost](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.PurchaseTransaction#_Google_Cloud_Retail_V2_PurchaseTransaction__getCost__)

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `float` |   |

### setCost

All the costs associated with the products. These can be manufacturing
costs, shipping expenses not borne by the end user, or any other costs,
such that:

- Profit = [revenue](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.PurchaseTransaction#_Google_Cloud_Retail_V2_PurchaseTransaction__getRevenue__) - [tax](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.PurchaseTransaction#_Google_Cloud_Retail_V2_PurchaseTransaction__getTax__) - [cost](https://docs.cloud.google.com/php/docs/reference/cloud-retail/latest/V2.PurchaseTransaction#_Google_Cloud_Retail_V2_PurchaseTransaction__getCost__)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `float` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getCurrencyCode

Required. Currency code. Use three-character ISO-4217 code.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setCurrencyCode

Required. Currency code. Use three-character ISO-4217 code.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |