# Order

See https://developer.paypal.com/docs/api/orders/v2/#definition-order.

## Methods

### Order::\_\_construct()

Creates an order object using constructor.

#### Signature

```php
public function __construct(string $intent = CAPTURE);
```

#### Example

```php
$order = new Order('CAPTURE');
```

### Order::addPurchaseUnit()

Adds a new purchase unit item into purchase\_units array.

#### Signature

```php
public function addPurchaseUnit(PurchaseUnit $purchase_unit): self;
```

#### Example

```php
$order = new Order('CAPTURE');
$order->addPurchaseUnit($purchase_unit);
```

### Order::getPurchaseUnits()

Gets an array for purchase units from an order.

#### Signature

```php
public function getPurchaseUnits(): array;
```

#### Example

```php
$purchase_units = $order->getPurchaseUnits($purchase_unit);
```

### Order::setApplicationContext()

Sets the application context of an order.

#### Signature

```php
public function setApplicationContext(ApplicationContext $application_context): self;
```

#### Example

```php
$order = new Order('CAPTURE');
$order->setApplicationContext($application_context);
```

### Order::getApplicationContext()

Gets an order application context.

#### Signature

```php
public function getApplicationContext(): ?ApplicationContext;
```

#### Example

```php
$application_context = $order->getApplicationContext() // ApplicationContext::class ;
```

### Order::setIntent()

Sets an order intent.

#### Signature

```php
public function setIntent(string $intent): self;
```

#### Example

```php
$order = new Order('CAPTURE');
$order->setIntent('AUTHORIZE');
```

### Order::getIntent()

Gets an order intent.

#### Signature

```php
public function getIntent(): string;
```

#### Example

```php
$order = new Order('CAPTURE');
$intent = $order->getIntent() // CAPTURE;
```

### Order::getId()

Gets an order id.

#### Signature

```php
public function getId(): string;
```

#### Example

```php
$order = new Order('CAPTURE');
$id = $order->getId() // 8F783829JA718493L;
```

### Order::getStatus()

Gets an order status.

#### Signature

```php
public function getStatus(): string;
```

#### Example

```php
$order = new Order('CAPTURE');
$status = $order->getStatus() // COMPLETED;
```

### Order::getPayee()

Gets an order payee.

#### Signature

```php
public function getPayee(): ?Payee;
```

#### Example

```php
$order = new Order('CAPTURE');
$payee = $order->getPayee() // Payee::class;
```
