# Authorize.net

Fetch settled batch transactions from Authorize.net's Transaction Reporting API, with automatic batch grouping.

## Setup

Use your API Login ID and Transaction Key from the [Authorize.net Merchant Interface](https://account.authorize.net/) under Account > Security Settings > API Credentials & Keys.

```bash
export AUTHORIZENET_API_LOGIN_ID=your_login_id
export AUTHORIZENET_TRANSACTION_KEY=your_transaction_key
```

## Usage

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

To test against the sandbox:

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

## Options

| Flag | Description | Default |
|------|-------------|---------|
| `--from` | Start date inclusive (YYYY-MM-DD) | required |
| `--to` | End date exclusive (YYYY-MM-DD) | required |
| `--api-login-id` | API Login ID | `AUTHORIZENET_API_LOGIN_ID` env |
| `--transaction-key` | Transaction Key | `AUTHORIZENET_TRANSACTION_KEY` env |
| `--out` | Output CSV path | stdout |
| `-q` / `--quiet` | Suppress progress messages | off |
| `--sandbox` | Use sandbox API endpoint | off |

## Type mapping

| Authorize.net type | Canonical type |
|---|---|
| `authCaptureTransaction`, `captureOnlyTransaction` | `charge` |
| `refundTransaction` | `refund` |
| `voidTransaction` | `void` |
| `priorAuthCaptureTransaction` | `capture` |
| _anything else_ | `adjustment` |

## Date handling

- **`effective_date`** — `submitTimeUTC` converted to YYYY-MM-DD
- **`posted_date`** — batch `settlementTimeUTC` converted to YYYY-MM-DD

## Notes

**Two-phase fetch.** VisiGrid first calls `getSettledBatchListRequest` to get all batches in the date range, then calls `getTransactionListRequest` for each batch to retrieve individual transactions.

**Signed amounts.** Refunds and voids are emitted with negative `amount_minor`. All other types use positive amounts.

**Description.** Built from `accountType` and `accountNumber` (e.g. `Visa XXXX1234`).

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

**Sandbox.** Pass `--sandbox` to hit `apitest.authorize.net` instead of the production endpoint. Useful for testing with sandbox credentials.