# Order

### Order

Contract representing the exchange of goods or services

#### **Attributes**

| Name               | Required | Type                                                                         | Description                             |
| ------------------ | -------- | ---------------------------------------------------------------------------- | --------------------------------------- |
| `number`           | Yes      | String                                                                       | unique order identifier                 |
| `buyer`            | Yes      | Object                                                                       | buyer name, phone, email and IP address |
| `total`            | -        | [Money](https://docs.shopgo.me/management-api/primitives#money)              | total amount of money due for payment   |
| `created`          | -        | [DateTime](https://docs.shopgo.me/management-api/primitives#datetime)        | order creation timestamp                |
| `billing_address`  | Yes      | [Address](https://docs.shopgo.me/management-api/primitives#address)          | address to send order invoice to        |
| `shipping_address` | Yes      | [Address](https://docs.shopgo.me/management-api/primitives#address)          | address to ship order purchases to      |
| `payments`         | -        | \[[Payment](https://docs.shopgo.me/management-api/payment#payment)]          | payments made to settle order           |
| `shipments`        | -        | \[[Shipment](https://docs.shopgo.me/management-api/shipment#shipment)]       | shipments created to fulfill order      |
| `purchases`        | -        | \[[Purchase](https://docs.shopgo.me/management-api/purchase#purchase)]       | order line items                        |
| `adjustments`      | -        | \[[Adjustment](https://docs.shopgo.me/management-api/adjustment#adjustment)] | order price adjustments                 |
| `visible`          | -        | Boolean                                                                      | order visibility status                 |
| `viewed`           | -        | Boolean                                                                      | flag to mark order as viewed by user    |
| `cancelled`        | -        | Boolean                                                                      | flag to mark order as cancelled         |
| `confirmed`        | -        | Boolean                                                                      | flag to mark order as confirmed         |
| `payment_method`   | Yes      | String                                                                       | payment method chosen by shopper        |

#### Example

```javascript
{
    "number": "R1551607648",
    "buyer": {
        "ip": "127.0.0.1",
        "name": "John Doe",
        "email": "",
        "phone": "+447591234567"
    },
    "total": {
        "amount": "25.00",
        "currency": "JOD"
    },
    "created": <DateTime>,
    "billing_address": <Address>,
    "shipping_address": <Address>,
    "payments": [<Payment>],
    "shipments": [<Shipment>],
    "purchases": [<Purchase>],
    "adjustments": [<Adjustment>],
    "visible": true,
    "viewed": true,
    "cancelled": false,
    "confirmed": false,
    "authorized": false,
    "source": "en",
    "payment_method": "cash_on_delivery"
}
```

#### Notes

1\. Difference between `Order.payment_method` and `Payment.method`

The field `payment_method` in the `Order` object contains the payment method chosen at checkout.

Even though this is likely to be the same as the `method` field in the order's `Payment`object(s), there are some edges cases in which those two fields are different. For example, a shopper may indicate that they wish to pay with a credit card, but then fail to make a credit card payment and pay with cash on delivery instead. In this case, the Order's `payment_method` field will be the intended payment method (here `credit_card`) while the `method` field of the order's child `Payment` object is the actual method used to make payment (here `cash_ond_delivery`).

In general, `payment_method` should be interpreted as the payment method preferred or attempted by the shopper, while the `method` field of `Payment` objects represent the actual method used to make payment.

2\. The `payment_method` parameter can take one of the following values:

* `cash`
* `credit_card`
* `bank_transfer`
* `other`
