# Adyen

Source: https://docs.formance.com/modules/payments/connectors/psp/adyen

Stack: v3.2

Adyen Payments is available in Connectivity. From Stack v4.0, the Connectivity module records Adyen Payments activity directly in Ledger. [See the Adyen Payments connector](https://docs.formance.com/v4.0/modules/connectivity/connectors/adyenpayments)

The Adyen connector syncs merchant accounts from Adyen's Management API and ingests Adyen's webhook stream. It does not poll for payments or balances — Adyen's canonical transaction surface is the webhook feed, which the connector subscribes to at install time.

## Prerequisites

You need an Adyen Management API key with read access to `MerchantAccount` for the company. Webhooks use Basic Auth credentials (`webhookUsername` / `webhookPassword`) set on the webhook config in Adyen's Customer Area and sent as `Authorization: Basic <base64(user:pass)>` on every delivery.

Make sure to create an API key dedicated to Formance. Doing so will improve your auditability and security and will allow you to revoke access to Formance at any time if needed.

## Installation

curl

```bash
curl -X POST $FORMANCE_API_URL/api/payments/v3/connectors/install/adyen \
  -H "Content-Type: application/json" \
  -d @'config.json'
```

fctl

```bash
fctl payments connectors install adyen config.json
```

### Configuration fields

| Field              | Type    | Required | Default |
| ------------------ | ------- | -------- | ------- |
| apiKey             | string  | true     |         |
| companyID          | string  | true     |         |
| liveEndpointPrefix | string  | false    |         |
| pageSize           | integer | false    | 25      |
| pollingPeriod      | string  | false    | 30m     |
| webhookPassword    | string  | false    |         |
| webhookUsername    | string  | false    |         |

`liveEndpointPrefix` only applies in production — copy it from Adyen's Customer Area under **Developers → API URLs** (the company-specific fragment between `https://` and `-checkout-live.adyenpayments.com`). Leave it empty for the test environment.

## Capabilities

- `FETCH_ACCOUNTS` — merchant accounts via `GET /Management/v3/merchants`.
- `CREATE_WEBHOOKS` — provisions a "Standard webhook" on the merchant at install, configured with the Basic Auth credentials from the config.
- `TRANSLATE_WEBHOOKS` — converts `AUTHORISATION`, `CAPTURE`, `REFUND`, `CHARGEBACK`, `CANCELLATION`, etc. to `PSPPayment`s.

Payments, balances, and external accounts are deliberately not polled — Adyen's canonical transaction surface is webhooks. Ensure the webhook is reachable (HTTPS, valid certificate) and the Basic Auth credentials match the config.

## Account model

Every Payments internal account is one Adyen **merchant account** from `GET /Management/v3/merchants`. The `reference` is the merchant ID; `name` is the display name; `defaultAsset` is null (Adyen merchants are multi-currency). No EXTERNAL accounts are emitted — Adyen "destination accounts" are not pulled (see [Known gaps](#known-gaps)). See [Accounts](https://docs.formance.com/modules/payments/accounts) for the cross-connector model.

## Asset model

Currencies are uppercase ISO 4217 (`USD`, `EUR`, `JPY`), formatted to UMN at standard precision. Amounts are already in minor units — no scaling.

## Status mapping

Webhook events combine `success: true|false` with `eventCode`:

| Adyen `eventCode` + `success`                            | Payment `status`          |
| -------------------------------------------------------- | ------------------------- |
| `AUTHORISATION` + `true`                                 | `PENDING` (until capture) |
| `CAPTURE` + `true`, `REFUND` + `true`                    | `SUCCEEDED`               |
| `AUTHORISATION` + `false`, `REFUND_FAILED`, `CHARGEBACK` | `FAILED`                  |
| `CANCELLATION` + `true`                                  | `CANCELLED`               |

Full event-code → type/status mapping in [`webhooks.go`](https://github.com/formancehq/payments/blob/main/ce/plugins/adyen/webhooks.go).

## Metadata keys

Under `com.adyen.spec/`:

- **Account**: `merchant_account_code`, `description`, `data_centers`.
- **Payment**: `event_code`, `psp_reference`, `merchant_reference`, `payment_method`, `payment_method_variant`, `acquirer_code`.

## Workflow tree

```text
FetchAccounts  (periodic — merchant accounts only)
CreateWebhooks (one-shot at install)
```

## Known gaps

- **Balances and payouts** are not exposed — Adyen's payout flow is bank-side, outside the Management API.
- **External accounts** (Adyen "destination accounts") are not pulled.
- **Transfer / Payout Initiation** is not implemented; outbound flows live in Adyen's Customer Area.
