# Mishka Pay v0.0.1 - Table of Contents > A payment SDK for Elixir: plugin-based providers, Stripe in full, PayPal included, with or without Ash. ## Pages - [README](readme.md) - [License](license.md) - Guides - [Getting started](getting-started.md) - [Webhooks](webhooks.md) - [The Ash layer](ash.md) - [Many sites](multi-tenant.md) - [Testing](testing.md) - [Errors](errors.md) - [Telemetry](telemetry.md) - [Production checklist](production.md) - DSLs - [MishkaPay.Ash.Resource](dsl-mishkapay-ash-resource.md) ## Modules - [MishkaPay](MishkaPay.md): The calls a project makes to take money: open a checkout, read a payment, refund one; for a subscription (started by a checkout in `mode: :subscription`) read it, cancel it, take a cancel back and list its invoices; keep customers (create, read, update, list, delete) and open their billing portal; save a customer's card with a checkout in `mode: :setup` and keep their saved payment methods; keep coupons and promotion codes; keep a catalog of products and prices; make payment links that sell them; end an open checkout; list payments, subscriptions, invoices, customers, coupons, codes, products and prices page by page (`MishkaPay.Page`). - [MishkaPay.Address](MishkaPay.Address.md): A postal address: where a buyer lives for the tax (`MishkaPay.TaxCalculation`), or where a checkout ships to (`MishkaPay.Checkout`'s `:shipping_address`). A guarded_struct. - [MishkaPay.Application](MishkaPay.Application.md): Mishka Pay's own processes: the task supervisor `MishkaPay.Credentials.fetch/3` runs a host's keys plugins under, so a plugin that exits, throws or hangs never takes the caller with it; the owner of the providers' token cache (`MishkaPay.Helpers.TokenCache`); and the providers (`plugins/0`), each a mishka_installer plugin it starts itself, as every Mishka CMS package starts its own. - [MishkaPay.ApplicationFee](MishkaPay.ApplicationFee.md): The platform's cut of a sale made for a connected account (an application fee, `fee_...` at Stripe): what a checkout's `:application_fee` or `:application_fee_percent` took. Read with `MishkaPay.fetch_application_fee/3` and `MishkaPay.list_application_fees/3`, and given back to the seller, all or part, with `MishkaPay.refund_application_fee/4`. A guarded_struct the provider fills in. - [MishkaPay.Ash](MishkaPay.Ash.md): The Ash layer, for projects that use Ash: the `MishkaPay.Ash.Resource` extension a host adds to resources of its own domain and data layer, and the listeners that keep them current. Without Ash none of it compiles, and the rest of Mishka Pay works on plain structs. - [MishkaPay.Ash.Customer.Listener](MishkaPay.Ash.Customer.Listener.md): Makes a module the `mishka_pay:event:process` listener that syncs the customer an event is about (`customer.created`, `customer.updated`, `customer.deleted` on Stripe, the `setup_intent.*` and `payment_method.*` events of the customer's saved cards, and `customer.tax_id.*` for one of its tax ids) into a customer resource (the `:customer` kind of `MishkaPay.Ash.Resource`) - [MishkaPay.Ash.Customer.Portal](MishkaPay.Ash.Customer.Portal.md): The `:portal` action of the `:customer` kind (`MishkaPay.Ash.Resource`): reads the row (with the caller's actor and tenant) and opens its provider's customer portal with `MishkaPay.portal_session/1`. - [MishkaPay.Ash.Customer.Sync](MishkaPay.Ash.Customer.Sync.md): The `:register`, `:sync`, `:edit` and `:remove` actions of the `:customer` kind (`MishkaPay.Ash.Resource`): asks the provider before the action's transaction starts, writes the customer as the provider answered it, and fires `mishka_pay:customer:changed` after. A customer the provider cannot give is an error on the action, and nothing is written; one the provider deleted, by `:remove` or elsewhere, keeps its row with `:deleted_at`. - [MishkaPay.Ash.Dispute.Listener](MishkaPay.Ash.Dispute.Listener.md): Makes a module the `mishka_pay:event:process` listener that syncs the dispute an event is about (`charge.dispute.*` on Stripe) into a dispute resource (the `:dispute` kind of `MishkaPay.Ash.Resource`) - [MishkaPay.Ash.Dispute.Sync](MishkaPay.Ash.Dispute.Sync.md): The `:sync`, `:submit_evidence` and `:accept` actions of the `:dispute` kind (`MishkaPay.Ash.Resource`): asks the provider before the action's transaction starts, writes the dispute as the provider answered it, and fires `mishka_pay:dispute:changed` after. A dispute the provider cannot give is an error on the action, and nothing is written. - [MishkaPay.Ash.Inbox.Fail](MishkaPay.Ash.Inbox.Fail.md): After the inbox's last try: marks the event `:failed` and keeps why, from the `:error` argument AshOban gives its `on_error` action, and emits `[:mishka_pay, :inbox, :failed]` with the event's `:provider`, `:tenant`, `:type` and `:event_id`. - [MishkaPay.Ash.Inbox.Listener](MishkaPay.Ash.Inbox.Listener.md): Makes a module the `mishka_pay:webhook:received` listener that stores each checked event in an inbox resource (the `:inbox` kind of `MishkaPay.Ash.Resource`) - [MishkaPay.Ash.Inbox.Process](MishkaPay.Ash.Inbox.Process.md): Works one inbox event: fires `mishka_pay:event:process` with it before the action's transaction starts, since the listeners may call the provider, and marks it processed when every listener took it. Otherwise it keeps the reason in `:last_error` and the action fails, so its AshOban job tries again. - [MishkaPay.Ash.Object.Change](MishkaPay.Ash.Object.Change.md): The change of every action of a site-managed object kind (`MishkaPay.Ash.Object.Spec`): before the transaction it reads the object again (`:sync`), or makes or changes it at the provider (`:add`, `:edit`, `:archive`, an invoice's steps), and writes what the provider answered; after it, fires `mishka_pay::changed` with `%{ => struct, record: record}`. An object the provider deleted (a coupon, a draft bill) is kept with `deleted_at`. - [MishkaPay.Ash.Object.Listener](MishkaPay.Ash.Object.Listener.md): Makes a module the `mishka_pay:event:process` listener that syncs the provider object an event is about into a resource of a site-managed kind (`MishkaPay.Ash.Object.Spec`): a `product.updated` into the `:product` resource, an `invoice.paid` into the `:invoice` one. - [MishkaPay.Ash.Object.Spec](MishkaPay.Ash.Object.Spec.md): What the provider objects a site manages from its admin keep and do, kind by kind: products, prices, coupons, promotion codes, payment links and one-off bills (the `:product`, `:price`, `:coupon`, `:promotion_code`, `:payment_link` and `:invoice` kinds of `MishkaPay.Ash.Resource`). Each kind names the provider object its webhook events are about, how to read one again, the row it writes from the provider's answer, and the `MishkaPay` call of each of its actions. `MishkaPay.Ash.Object.Change` and `MishkaPay.Ash.Object.Listener` run them. - [MishkaPay.Ash.Owner](MishkaPay.Ash.Owner.md): How a payment or a subscription row finds its user (`belongs_to_user` of `MishkaPay.Ash.Resource`). - [MishkaPay.Ash.Payment.Listener](MishkaPay.Ash.Payment.Listener.md): Makes a module the `mishka_pay:event:process` listener that syncs the payment an event concerns into a payment resource (the `:payment` kind of `MishkaPay.Ash.Resource`) - [MishkaPay.Ash.Payment.Money](MishkaPay.Ash.Payment.Money.md): The `:money` calculations of `MishkaPay.Ash.Resource`'s kinds: a stored amount with its currency, as `Money`. - [MishkaPay.Ash.Payment.Refund](MishkaPay.Ash.Payment.Refund.md): The `:refund` action of the `:payment` kind (`MishkaPay.Ash.Resource`): refunds the stored payment through its provider before the transaction starts (as often as the tenant allows, see `MishkaPay.Refund`), reads the payment again and writes it, keeps the `MishkaPay.Refund` in the record's `:refund` metadata, and fires `mishka_pay:payment:changed`. When the payment cannot be read again, the row counts the refund itself (never past the payment's amount), and the announcement waits for the next sync. - [MishkaPay.Ash.Payment.StartCheckout](MishkaPay.Ash.Payment.StartCheckout.md): The `:start_checkout` action of the `:payment` kind (`MishkaPay.Ash.Resource`): `MishkaPay.checkout/1` with Ash errors, in the action's tenant, with the actor as the checkout's owner unless it names one (`MishkaPay.Ash.Owner`). - [MishkaPay.Ash.Payment.Sync](MishkaPay.Ash.Payment.Sync.md): Reads a payment from its provider before the action's transaction starts and writes what the provider said; after the transaction, fires `mishka_pay:payment:changed`. A payment the provider cannot give is an error on the action, and nothing is written. - [MishkaPay.Ash.Resource](MishkaPay.Ash.Resource.md): Mishka Pay's Ash layer as a resource extension: a host's resource, in its own domain and data layer, says what it keeps, and gets the attributes, identities, calculations, actions, code interface and webhook listener of that kind. - [MishkaPay.Ash.Resource.ApplyKind](MishkaPay.Ash.Resource.ApplyKind.md): The transformer of `MishkaPay.Ash.Resource`: adds the resource's kind (`MishkaPay.Ash.Resource.Kinds`) with `Ash.Resource.Builder`, before any transformer of Ash and AshOban sees the resource, and skips whatever the host defines itself. - [MishkaPay.Ash.Resource.Info](MishkaPay.Ash.Resource.Info.md): Reads the `mishka_pay` setup of a resource (`MishkaPay.Ash.Resource`): each option as `mishka_pay_