# Fiserv / CardPointe

Fetch settled transactions from Fiserv's CardPointe Settlement Status API, with per-date iteration and batch grouping.

## Setup

Get your CardPointe API credentials from your Fiserv/CardConnect representative. You need the merchant ID, API username, and API password.

```bash
export FISERV_MERCHANT_ID=your_merchant_id
export FISERV_API_USERNAME=your_username
export FISERV_API_PASSWORD=your_password
```

Optionally set the API base URL (defaults to the UAT sandbox):

```bash
export FISERV_API_URL=https://fts.cardconnect.com   # production
```

## Usage

```bash
vgrid fetch fiserv --from 2026-01-01 --to 2026-01-31 --out fiserv.csv
```

For production use, pass the production API URL:

```bash
vgrid fetch fiserv --from 2026-01-01 --to 2026-01-31 \
  --api-url https://fts.cardconnect.com --out fiserv.csv
```

## Options

| Flag | Description | Default |
|------|-------------|---------|
| `--from` | Start date inclusive (YYYY-MM-DD) | required |
| `--to` | End date exclusive (YYYY-MM-DD) | required |
| `--api-url` | CardPointe API base URL | `FISERV_API_URL` env or `https://fts-uat.cardconnect.com` |
| `--merchant-id` | Merchant ID | `FISERV_MERCHANT_ID` env |
| `--api-username` | API username | `FISERV_API_USERNAME` env |
| `--api-password` | API password | `FISERV_API_PASSWORD` env |
| `--out` | Output CSV path | stdout |
| `-q` / `--quiet` | Suppress progress messages | off |

## Type mapping

| Fiserv type | Canonical type |
|---|---|
| `sale` | `charge` |
| `refund` | `refund` |
| `void` | `void` |
| _anything else_ | `adjustment` |

Type matching is case-insensitive.

## Date handling

- **`effective_date`** — `authdate` field converted from `MMDDYYYY` to `YYYY-MM-DD`
- **`posted_date`** — the settlement date (the date queried from the API)

## Notes

**Per-date iteration.** The CardPointe Settlement Status API takes a single date per request (in `MMDD` format). VisiGrid iterates each date in the `--from`/`--to` range and collects transactions from all batches returned.

**Basic Auth.** Requests are authenticated with HTTP Basic Auth using the API username and password.

**Description.** Built from `cardtype` and the last 4 digits of `token` when available.

**Batch grouping.** Transactions are tagged with `group_id` set to the CardPointe batch ID.

**Default URL.** The default API URL points to the UAT sandbox (`fts-uat.cardconnect.com`). For production, pass `--api-url https://fts.cardconnect.com` or set the `FISERV_API_URL` environment variable.