Search documentation of stripe_elixir

# StripeElixir.Error (stripe_elixir v0.1.0)

Copy Markdown View Source

Stripe API error.

All API errors are returned as `{:error, %StripeElixir.Error{}}` tuples.

## Error Types

- `:api_error` - Generic API error
- `:authentication_error` - Invalid API key (401)
- `:card_error` - Card was declined
- `:idempotency_error` - Idempotency key conflict
- `:invalid_request_error` - Invalid parameters (400/404)
- `:permission_error` - Insufficient permissions (403)
- `:rate_limit_error` - Too many requests (429)
- `:api_connection_error` - Network/connection failure
- `:signature_verification_error` - Webhook signature mismatch

## Summary

### Types

error_type()
t()

### Functions

connection_error(message)

Build a network/connection error.

from_response(status, body, headers)

Build an error from an HTTP response.

retryable?(arg1)

Returns true if this error is retryable.

signature_verification_error(message)

Build a webhook signature verification error.

## Types

# error_type()

    @type error_type() ::
      :api_error
      | :authentication_error
      | :card_error
      | :idempotency_error
      | :invalid_request_error
      | :permission_error
      | :rate_limit_error
      | :api_connection_error
      | :signature_verification_error

# t()

    @type t() :: %StripeElixir.Error{
      charge: String.t() | nil,
      code: String.t() | nil,
      decline_code: String.t() | nil,
      doc_url: String.t() | nil,
      http_body: String.t() | nil,
      http_headers: [{String.t(), String.t()}] | nil,
      http_status: integer() | nil,
      message: String.t() | nil,
      param: String.t() | nil,
      payment_intent: map() | nil,
      payment_method: map() | nil,
      request_id: String.t() | nil,
      retry_after: number() | nil,
      setup_intent: map() | nil,
      type: error_type()
    }

## Functions

# connection_error(message)

    @spec connection_error(String.t()) :: t()

Build a network/connection error.

# from_response(status, body, headers)

    @spec from_response(integer(), String.t(), [{String.t(), String.t()}]) :: t()

Build an error from an HTTP response.

# retryable?(arg1)

    @spec retryable?(t()) :: boolean()

Returns true if this error is retryable.

# signature_verification_error(message)

    @spec signature_verification_error(String.t()) :: t()

Build a webhook signature verification error.