PaperTiger.Resources.PaymentIntent (PaperTiger v1.1.1)

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
  • POST /v1/payment_intents/:id/confirm - Confirm payment intent
  • POST /v1/payment_intents/:id/cancel - Cancel payment intent
  • POST /v1/payment_intents/:id/capture - Capture manual payment intent

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

Cancels a payment intent that has not reached a terminal successful state.

Captures a payment intent confirmed with capture_method=manual.

Confirms a payment intent, transitioning it to "succeeded" and creating a charge + balance transaction for automatic capture or an uncaptured charge for manual capture.

Creates a new payment intent.

Lists all payment intents with pagination.

Retrieves a payment intent by ID.

Searches payment intents with Stripe-style search query syntax.

Updates a payment intent.

Functions

cancel(conn, id)

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

Cancels a payment intent that has not reached a terminal successful state.

capture(conn, id)

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

Captures a payment intent confirmed with capture_method=manual.

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 for automatic capture or an uncaptured charge for manual capture.

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.

search(conn)

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

Searches payment intents with Stripe-style search query syntax.

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