PaperTiger.Resources.PaymentIntent (PaperTiger v1.0.2)

Copy Markdown View Source

Handles PaymentIntent resource endpoints.

Endpoints

  • POST /v1/payment_intents - Create payment intent
  • GET /v1/payment_intents/:id - Retrieve payment intent
  • POST /v1/payment_intents/:id - Update payment intent
  • GET /v1/payment_intents - List payment intents

Note: Payment intents cannot be deleted (only canceled).

PaymentIntent Object

%{
  id: "pi_...",
  object: "payment_intent",
  created: 1234567890,
  amount: 2000,  # Amount in cents
  currency: "usd",
  status: "requires_payment_method",
  customer: "cus_...",
  payment_method: "pm_...",
  metadata: %{},
  # ... other fields
}

Summary

Functions

Confirms a payment intent, transitioning it to "succeeded" and creating a charge + balance transaction.

Creates a new payment intent.

Lists all payment intents with pagination.

Retrieves a payment intent by ID.

Updates a payment intent.

Functions

confirm(conn, id)

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

Confirms a payment intent, transitioning it to "succeeded" and creating a charge + balance transaction.

create(conn)

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

Creates a new payment intent.

Required Parameters

  • amount - Amount in cents (e.g., 2000 for $20.00)
  • currency - Three-letter ISO currency code (e.g., "usd")

Optional Parameters

  • customer - Customer ID this payment is for
  • payment_method - Payment method ID to use
  • metadata - Key-value metadata
  • description - Payment description
  • statement_descriptor - Descriptor for bank statements

list(conn)

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

Lists all payment intents with pagination.

Parameters

  • limit - Number of items (default: 10, max: 100)
  • starting_after - Cursor for pagination
  • ending_before - Reverse cursor
  • customer - Filter by customer ID
  • status - Filter by status

retrieve(conn, id)

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

Retrieves a payment intent by ID.

update(conn, id)

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

Updates a payment intent.

Updatable Fields

  • amount
  • customer
  • payment_method
  • metadata
  • description
  • statement_descriptor