Stripe.Card (stripity_stripe v2.17.3) View Source

Work with Stripe card objects.

You can:

  • Create a card
  • Retrieve a card
  • Update a card
  • Delete a card

If you have been using an old version of the library, note that the functions which take an owner_type argument are now deprecated.

The owner type is indicated by setting either the recipient or customer


Stripe API reference: https://stripe.com/docs/api#cards

Link to this section Summary

Link to this section Types

Specs

t() :: %Stripe.Card{
  account: Stripe.id() | Stripe.Account.t() | nil,
  address_city: String.t() | nil,
  address_country: String.t() | nil,
  address_line1: String.t() | nil,
  address_line1_check: String.t() | nil,
  address_line2: String.t() | nil,
  address_state: String.t() | nil,
  address_zip: String.t() | nil,
  address_zip_check: String.t() | nil,
  available_payout_methods: [String.t()] | nil,
  brand: String.t(),
  country: String.t() | nil,
  currency: String.t() | nil,
  customer: Stripe.id() | Stripe.Customer.t() | nil,
  cvc_check: String.t() | nil,
  default_for_currency: boolean() | nil,
  deleted: boolean() | nil,
  dynamic_last4: String.t() | nil,
  exp_month: integer(),
  exp_year: integer(),
  fingerprint: String.t() | nil,
  funding: String.t(),
  id: Stripe.id(),
  last4: String.t(),
  metadata: Stripe.Types.metadata(),
  name: String.t() | nil,
  object: String.t(),
  recipient: Stripe.id() | Stripe.Recipient.t() | nil,
  tokenization_method: String.t() | nil
}

Link to this section Functions

Link to this function

create(params, opts \\ [])

View Source

Specs

create(params, Keyword.t()) :: {:ok, t()} | {:error, Stripe.Error.t()}
when params: %{
       :customer => Stripe.id() | Stripe.Customer.t(),
       :source => Stripe.id() | Stripe.Source.t(),
       optional(:metadata) => Stripe.Types.metadata()
     }

Create a card.

This requires a token created by a library like Stripe.js.

For PCI compliance reasons you should not send a card's number or CVC to your own server.

If you want to create a card with your server without a token, you can use the low-level API.

Link to this function

delete(id, params, opts \\ [])

View Source

Specs

delete(Stripe.id() | t(), map(), Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}

Delete a card.

Link to this function

list(params, opts \\ [])

View Source

Specs

list(params, Stripe.options()) ::
  {:ok, Stripe.List.t(t())} | {:error, Stripe.Error.t()}
when params: %{
       :customer => Stripe.id() | Stripe.Customer.t(),
       optional(:ending_before) => t() | Stripe.id(),
       optional(:limit) => 1..100,
       optional(:starting_after) => t() | Stripe.id()
     }

List all cards.

Link to this function

retrieve(id, params, opts \\ [])

View Source

Specs

retrieve(Stripe.id() | t(), map(), Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}

Retrieve a card.

Link to this function

update(id, params, opts \\ [])

View Source

Specs

update(Stripe.id() | t(), params, Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}
when params: %{
       :id => String.t(),
       :customer => String.t(),
       optional(:address_city) => String.t(),
       optional(:address_country) => String.t(),
       optional(:address_line1) => String.t(),
       optional(:address_line2) => String.t(),
       optional(:address_state) => String.t(),
       optional(:address_zip) => String.t(),
       optional(:exp_month) => String.t(),
       optional(:exp_year) => String.t(),
       optional(:metadata) => Stripe.Types.metadata(),
       optional(:name) => String.t()
     }

Update a card.

Takes the id and a map of changes