﻿# Payment

## Usage

```JavaScript
import { mockServer, PaymentApi } from 'geta-checkout';

const paymentApi = new PaymentApi(mockServer.paymentServices);

paymentApi.get()
    .then(payment => console.log('There are', payment.methods.length, 'methods available.'))
```

## Properties

| Name                    | Type                    | Description                                   |
|-------------------------|-------------------------|-----------------------------------------------|
| errorMessage            | String                  |                                               |
| selectedMethodId        | String                  | Example: `nets`.                              |
| methods                 | Array                   | Available payment methods                     |

## Methods

### `get()`

→ `payment` or `Error`

```javascript
paymentApi.get()
    .then(console.log)
    .catch(console.error);
```
### `set(paymentId, data={})`

→ `payment` or `Error`

## Payment methods

### Nets

| Name                    | Type                    | Description                                   |
|-------------------------|-------------------------|-----------------------------------------------|
| id                      | String                  | `nets`                                        |
| image                   | [Image](../image/readme.md) |                                           |
| name                    | String                  |                                               |
| description             | String                  |                                               |
| selectValue             | String                  | `0`                                           |

### Invoice

| Name                    | Type                    | Description                                   |
|-------------------------|-------------------------|-----------------------------------------------|
| id                      | String                  | `invoice`                                     |
| image                   | [Image](../image/readme.md) |                                           |
| name                    | String                  |                                               |
| description             | String                  |                                               |
| selectValue             | String                  | `1`                                           |

### CustomPayment

| Name                    | Type                    | Description                                   |
|-------------------------|-------------------------|-----------------------------------------------|
| id                      | String                  | `customPayment`                               |
| image                   | [Image](../image/readme.md) |                                           |
| name                    | String                  |                                               |
| description             | String                  |                                               |
| selectValue             | String                  | `2`                                           |