# `Teya.Capture`
[🔗](https://github.com/sgerrand/ex_teya/blob/v0.4.0/lib/teya/capture.ex#L1)

Capture pre-authorised funds.

After a `PRE_AUTHORISATION` transaction succeeds, call `create/2` to settle
the funds. Uncaptured pre-authorisations are released automatically by the
issuer after a network-defined period (typically 7 days).

Required OAuth scope: `captures/create`.

# `create`

```elixir
@spec create(String.t(), map(), keyword()) :: {:ok, map()} | {:error, Teya.Error.t()}
```

Captures a pre-authorised transaction.

`transaction_id` is the `transaction_id` from the `PRE_AUTHORISATION` response.

Returns `{:ok, response}` where status is `"SUCCESS"`, `"FAILURE"`, or `"PENDING"`.
A `"PENDING"` response (HTTP 202) means the capture is still being processed;
poll `Teya.Transaction.get/1` until the status is final.

## Options

- `idempotency_key` — override the auto-generated idempotency key

## Examples

    {:ok, _} = Teya.Capture.create(transaction_id)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
