Worldpay.WPG (Worldpay v1.0.0)

Copy Markdown View Source

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"

Summary

Functions

Authorize a card payment via WPG Direct.

Cancel a WPG authorization.

Capture (settle) a WPG authorization.

Inquire on a WPG order.

Submit a WPG XML document and return a parsed map.

Submit and return the raw XML body without parsing.

Functions

authorize(opts, config)

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

Authorize a card payment via WPG Direct.

cancel(order_code, config)

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

Cancel a WPG authorization.

capture(order_code, amount, currency, config)

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

Capture (settle) a WPG authorization.

inquiry(order_code, config)

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

Inquire on a WPG order.

refund(order_code, amount, currency, config)

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

Refund a WPG payment.

submit(xml, config)

@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(xml, config)

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

Submit and return the raw XML body without parsing.