mix mishka_pay.install (Mishka Pay v0.0.1)

Copy Markdown View Source

Sets a Phoenix project up to take payments with Mishka Pay.

mix igniter.install mishka_pay --ash --pubsub

It adds, and never twice:

  • MishkaPay.Registry first, which starts mishka_installer's plugin registry when nothing else does (as in a project's test run), then a keys plugin (<App>.Pay.Keys) to the application's children; the keys plugin answers each site's Stripe keys at runtime, from the environment until the project keeps them per site;
  • the webhook endpoint (plug MishkaPay.Webhook, at: "/pay/webhooks") before Plug.Parsers in the endpoint, which needs the raw body;
  • MishkaPay.Test.setup!/0 and MishkaPay.Test.await_plugin!/1 before ExUnit.start(), so tests start once Stripe is registered;
  • mishka_installer's plugin registry in .mnesia/<env> (left out of git), where providers, keys and listeners are kept;
  • the test config that lets MishkaPay.Test.stub_http/1 answer every provider call, and config :ex_money, auto_start_exchange_rate_service: false (Mishka Pay converts no currencies).

Options:

  • --ash: the Ash layer: a <App>.Pay domain with the webhook inbox, payments, subscriptions, customers and disputes as resources of the project (MishkaPay.Ash.Resource), the listener the extension makes for each in the application's children, the inbox's Oban queue, config :ash, default_string_length_count: :codepoints when the project has no such setting, and :mishka_pay in the formatter's import_deps (its DSL is written without parentheses). It needs ash_postgres and ash_oban (mix igniter.install ash_postgres ash_oban), then mix ash.codegen mishka_pay.
  • --admin: with --ash (which it turns on), the provider objects a site manages from its admin as resources too: products, prices, coupons, promotion codes, payment links and bills, each synced by its webhooks (MishkaPay.Ash.Object.Spec). Run it again on a project installed without it to add them.
  • --pubsub: <App>.Pay.Broadcast, Mishka Pay's PubSub plugin on the project's <App>.PubSub.