PaperTiger.Resources.Card (PaperTiger v0.9.21)

View Source

Handles Card resource endpoints.

DEPRECATED: Cards are deprecated in favor of PaymentMethod, but still supported for backward compatibility.

Endpoints

  • POST /v1/customers/:customer_id/sources - Create card (attach to customer)
  • GET /v1/customers/:customer_id/sources/:id - Retrieve card
  • POST /v1/customers/:customer_id/sources/:id - Update card
  • DELETE /v1/customers/:customer_id/sources/:id - Delete card (detach from customer)
  • GET /v1/customers/:customer_id/sources - List cards (filtered by customer)

Card Object

%{
  id: "card_...",
  object: "card",
  created: 1234567890,
  customer: "cus_...",
  brand: "Visa",
  last4: "4242",
  exp_month: 12,
  exp_year: 2025,
  fingerprint: "hash...",
  funding: "credit",
  metadata: %{},
  # ... other fields
}

Summary

Functions

Creates a new card (attaches to customer).

Deletes a card (detaches from customer).

Lists all cards for a customer with pagination.

Retrieves a card by ID.

Updates a card.

Functions

create(conn)

@spec create(Plug.Conn.t()) :: Plug.Conn.t()

Creates a new card (attaches to customer).

Required Parameters

  • customer - Customer ID to attach card to

Optional Parameters

  • source - Token ID or map of card details
  • brand - Card brand (Visa, Mastercard, American Express, Discover)
  • last4 - Last 4 digits
  • exp_month - Expiration month
  • exp_year - Expiration year
  • funding - Funding type (credit, debit, prepaid)
  • metadata - Key-value metadata

delete(conn, id)

@spec delete(Plug.Conn.t(), String.t()) :: Plug.Conn.t()

Deletes a card (detaches from customer).

Returns a deletion confirmation object.

list(conn)

@spec list(Plug.Conn.t()) :: Plug.Conn.t()

Lists all cards for a customer with pagination.

Parameters

  • customer - Customer ID (required for filtering)
  • limit - Number of items (default: 10, max: 100)
  • starting_after - Cursor for pagination
  • ending_before - Reverse cursor

retrieve(conn, id)

@spec retrieve(Plug.Conn.t(), String.t()) :: Plug.Conn.t()

Retrieves a card by ID.

update(conn, id)

@spec update(Plug.Conn.t(), String.t()) :: Plug.Conn.t()

Updates a card.

Updatable Fields

  • exp_month
  • exp_year
  • metadata
  • address_city
  • address_country
  • address_line1
  • address_line2
  • address_state
  • address_zip