# `Worldpay.WPG`
[🔗](https://github.com/iamkanishka/worldpay/blob/v1.0.0/lib/worldpay/wpg/wpg.ex#L387)

Worldpay **WPG (Worldpay Payment Gateway)** — XML-based gateway client.

Supports: Direct, HPP, Direct Elements, tokenisation, 3DS, FraudSight,
split funding, modifications (capture/cancel/refund), and inquiries.

## Example

    config = Worldpay.Config.new()

    xml =
      Worldpay.WPG.Builder.order(
        order_code: "order-001",
        amount: 1999,
        currency: "GBP",
        card_number: "4444333322221111",
        exp_month: "05",
        exp_year: "2035",
        card_holder: "Jane Doe",
        cvc: "123"
      )
      |> Worldpay.WPG.Builder.envelope(merchant_code: config.wpg_merchant_code)

    {:ok, response} = Worldpay.WPG.submit(xml, config)
    Worldpay.WPG.Parser.last_event(response)  # => "AUTHORISED"

# `authorize`

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

Authorize a card payment via WPG Direct.

# `cancel`

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

Cancel a WPG authorization.

# `capture`

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

Capture (settle) a WPG authorization.

# `inquiry`

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

Inquire on a WPG order.

# `refund`

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

Refund a WPG payment.

# `submit`

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

Submit a WPG XML document and return a parsed map.

# `submit_raw`

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

Submit and return the raw XML body without parsing.

---

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