siftsciex_plug v0.3.0 Siftsciex.DecisionPlug

This Plug simplifies the handling of Decisions from Sift Science.

The Decision Plug basically performs three functions:

  1. Mapping specific endpoints to specific handlers in your code
  2. Verifying the signature in the request
  3. Processing the Decision body and automatically converting it to a Siftsciex.Decision.t/0 struct

Configuration

There is a single piece of configuration to set. Sift Science sends a “signature” with each WebHook. It is recommended that you verify this signature, in fact this Plug will not process any requests that are not properly “signed”. The signature should be set in the :hook_key attribute for the :siftsciex_plug application.

config :siftsciex_plug,
  hook_key: <sift_hook_sig>

Example

  forward "/sift_science", Siftsciex.DecisionPlug, %{
    "bad_listing" => {ListingHandler, :process}}
  }

Link to this section Summary

Link to this section Types

Link to this type opts()
opts() :: %{required(String.t()) => {module(), atom()}}

Link to this section Functions

Link to this function call(conn, opts)
call(Plug.Conn.t(), map()) :: Plug.Conn.t()
Link to this function init(opts)
init(opts()) :: map()
Link to this function process(conn, opts)
process(Plug.Conn.t(), map()) :: Plug.Conn.t()
Link to this function sig_key()
sig_key() :: String.t()
Link to this function valid?(conn)
valid?(Plug.Conn.t()) :: boolean()