Duffel.Cards (Duffel v0.1.0)

Copy Markdown View Source

Tokenise cards for use in payments and 3DS sessions.

Cards are served from the PCI-scoped host api.duffel.cards, not the main API host. The host is configurable via :cards_base_url on the client.

A card token is single-use and short-lived: create it immediately before the payment that consumes it.

See the Duffel documentation.

Summary

Functions

Tokenises a card, returning a card ID.

Deletes a card token.

Functions

create(client, params, opts \\ [])

@spec create(Duffel.Client.t(), map(), keyword()) ::
  {:ok, map()} | {:error, Duffel.Error.t()}

Tokenises a card, returning a card ID.

Options

  • :idempotency_key - value for the Idempotency-Key header. A key is generated when you do not pass one (see Duffel.Client.post/4).

Examples

Duffel.Cards.create(client, %{
  number: "4242424242424242",
  expiry_month: "03",
  expiry_year: "30",
  cvc: "737",
  name: "Amelia Earhart",
  address_postal_code: "EC2A 4RQ",
  address_country_code: "GB"
})

delete(client, id)

@spec delete(Duffel.Client.t(), String.t()) :: :ok | {:error, Duffel.Error.t()}

Deletes a card token.