Worldpay.CardPayments (Worldpay v1.0.0)

Copy Markdown View Source

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)

Summary

Functions

Customer Initiated Transaction (CIT) authorization.

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

Build a standard CIT instruction map.

Build a standard MIT subscription instruction map.

Cancel an authorization.

Retrieve payment events.

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

Retrieve a single payment by ID.

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

Full settlement of an authorized payment.

Functions

authorize(body, config, opts \\ [])

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

Customer Initiated Transaction (CIT) authorization.

authorize_with_account_updater(body, config, opts \\ [])

@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(fields)

@spec build_cit(keyword()) :: %{required(String.t()) => term()}

Build a standard CIT instruction map.

build_mit(fields)

@spec build_mit(keyword()) :: %{required(String.t()) => term()}

Build a standard MIT subscription instruction map.

cancel(payment_id, config, opts \\ [])

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

Cancel an authorization.

events(payment_id, config)

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

Retrieve payment events.

fast_refund(payment_id, body \\ %{}, config, opts \\ [])

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

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

Retrieve a single payment by ID.

mit(body, config, opts \\ [])

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

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

partial_refund(payment_id, amount, currency, config, opts \\ [])

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

Partial refund.

partial_settle(payment_id, amount, currency, config, opts \\ [])

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

Partial settlement.

refund(payment_id, config, opts \\ [])

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

Full refund.

settle(href_or_id, config, opts \\ [])

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

Full settlement of an authorized payment.