Shopifex.Plug.PaymentGuard (Shopifex v3.0.0)

Copy Markdown View Source

Add payment guards to your routes or controllers!

Examples:

defmodule MyAppWeb.AdminLinkController do
  use MyAppWeb, :controller
  require Logger

  plug Shopifex.Plug.PaymentGuard, "premium_plan" when action in [:premium_function]

  def premium_function(conn, _params) do
    # Wow, much premium.
    conn
    |> send_resp(200, "success")
  end
end

Summary

Functions

This makes sure the shop in the session contains a payment which unlocks the guard.

Functions

call(conn, guard_identifier)

This makes sure the shop in the session contains a payment which unlocks the guard.

If no payment is present which unlocks the guard (or remaining usages are exhausted), the conn will be redirected to your application's PaymentController.show_plans route.

init(options)