StripeManaged
Elixir client for Stripe Managed Payments - sell digital products with Stripe as your merchant of record.
Handles tax compliance (80+ countries), fraud prevention, and dispute management out of the box.
Installation
Add to your mix.exs:
{:stripe_managed, "~> 0.1"}Configuration
config :stripe_managed,
api_key: System.get_env("STRIPE_SECRET_KEY"),
api_version: "2025-03-31.basil",
webhook_secret: System.get_env("STRIPE_WEBHOOK_SECRET")Quick start
# Create a product with a monthly price
{:ok, product} = StripeManaged.Product.create(%{
name: "Pro Plan",
tax_code: "txcd_10103001",
default_price_data: %{
unit_amount: 2900,
currency: "usd",
recurring: %{interval: "month"}
}
})
# Start a checkout session (Stripe as merchant of record)
{:ok, session} = StripeManaged.CheckoutSession.create(%{
line_items: [%{price: product.default_price, quantity: 1}],
mode: "subscription",
managed_payments: %{enabled: true},
success_url: "https://yourapp.com/success"
})
# Redirect customer to session.urlSupported resources
StripeManaged.Product- products (digital goods, SaaS)StripeManaged.Price- pricing (one-time and recurring)StripeManaged.CheckoutSession- checkout sessions with managed paymentsStripeManaged.Subscription- subscription lifecycleStripeManaged.Invoice- invoices and hosted invoice URLsStripeManaged.Refund- refund managementStripeManaged.Customer- customer recordsStripeManaged.Webhook- webhook signature verification and event parsingStripeManaged.TaxCode- eligible tax codes for digital products
Webhook handling
# In your Phoenix controller
def webhook(conn, _params) do
payload = conn.assigns.raw_body
signature = Plug.Conn.get_req_header(conn, "stripe-signature") |> List.first()
case StripeManaged.Webhook.construct_event(payload, signature) do
{:ok, event} ->
handle_event(event)
send_resp(conn, 200, "ok")
{:error, reason} ->
send_resp(conn, 400, reason)
end
endLicense
MIT