# `Worldpay.CardPayments`
[🔗](https://github.com/iamkanishka/worldpay/blob/v1.0.0/lib/worldpay/access/card_payments.ex#L1)

Worldpay **Card Payments API** — modular card authorization.

Supports CITs, MITs, partial auth, fast refunds, AFTs, account updater,
PayFac, Level 2/3, airline data, MOTO, co-badged card routing, and more.

Use `Worldpay.CardPayments.Features` to build advanced instruction maps.

## CIT example

    body = Worldpay.CardPayments.build_cit(
      transaction_reference: "txn-001",
      narrative: "My Store",
      amount: 1999,
      currency: "GBP",
      payment_instrument: %{"type" => "card/plain", ...}
    )
    {:ok, auth} = Worldpay.CardPayments.authorize(body, config)

## MIT (subscription) example

    body = Worldpay.CardPayments.build_mit(
      transaction_reference: "sub-002",
      narrative: "Monthly Plan",
      amount: 999,
      currency: "USD",
      payment_instrument: %{"type" => "card/token", "href" => token_href},
      scheme_reference: scheme_ref
    )
    {:ok, _} = Worldpay.CardPayments.mit(body, config)

# `authorize`

```elixir
@spec authorize(map(), Worldpay.Config.t(), keyword()) ::
  {:ok, map()} | {:error, Worldpay.Error.t()}
```

Customer Initiated Transaction (CIT) authorization.

# `authorize_with_account_updater`

```elixir
@spec authorize_with_account_updater(map(), Worldpay.Config.t(), keyword()) ::
  {:ok, map()} | {:error, Worldpay.Error.t()}
```

Subsequent CIT with real-time Account Updater (Visa).

Sets `requestAccountUpdater: true` in the instruction body.
If the card was reissued, the response includes `updatedPaymentInstrument`.

# `build_cit`

```elixir
@spec build_cit(keyword()) :: %{required(String.t()) =&gt; term()}
```

Build a standard CIT instruction map.

# `build_mit`

```elixir
@spec build_mit(keyword()) :: %{required(String.t()) =&gt; term()}
```

Build a standard MIT subscription instruction map.

# `cancel`

```elixir
@spec cancel(String.t(), Worldpay.Config.t(), keyword()) ::
  {:ok, map()} | {:error, Worldpay.Error.t()}
```

Cancel an authorization.

# `events`

```elixir
@spec events(String.t(), Worldpay.Config.t()) ::
  {:ok, map()} | {:error, Worldpay.Error.t()}
```

Retrieve payment events.

# `fast_refund`

```elixir
@spec fast_refund(String.t(), map(), Worldpay.Config.t(), keyword()) ::
  {:ok, map()} | {:error, Worldpay.Error.t()}
```

Fast refund (≤30 min credit to eligible cards).

# `get`

```elixir
@spec get(String.t(), Worldpay.Config.t()) ::
  {:ok, map()} | {:error, Worldpay.Error.t()}
```

Retrieve a single payment by ID.

# `mit`

```elixir
@spec mit(map(), Worldpay.Config.t(), keyword()) ::
  {:ok, map()} | {:error, Worldpay.Error.t()}
```

Merchant Initiated Transaction (MIT) — subscription / installment / unscheduled.

# `partial_refund`

```elixir
@spec partial_refund(
  String.t(),
  non_neg_integer(),
  String.t(),
  Worldpay.Config.t(),
  keyword()
) ::
  {:ok, map()} | {:error, Worldpay.Error.t()}
```

Partial refund.

# `partial_settle`

```elixir
@spec partial_settle(
  String.t(),
  non_neg_integer(),
  String.t(),
  Worldpay.Config.t(),
  keyword()
) ::
  {:ok, map()} | {:error, Worldpay.Error.t()}
```

Partial settlement.

# `refund`

```elixir
@spec refund(String.t(), Worldpay.Config.t(), keyword()) ::
  {:ok, map()} | {:error, Worldpay.Error.t()}
```

Full refund.

# `settle`

```elixir
@spec settle(String.t(), Worldpay.Config.t(), keyword()) ::
  {:ok, map()} | {:error, Worldpay.Error.t()}
```

Full settlement of an authorized payment.

---

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