MishkaPay.Event (Mishka Pay v0.0.1)

Copy Markdown View Source

A provider's webhook message after its signature was checked, as MishkaPay.Webhook hands it to the mishka_pay:webhook:received listeners. A guarded_struct the provider fills in.

  • :provider, :tenant: whose message, with whose keys it was checked.
  • :id: the provider's event id (evt_... at Stripe). A provider may send one event more than once: a listener keeps what it did by this id.
  • :type: the provider's own name for what happened, such as "checkout.session.completed".
  • :object_id, :object_type: what it is about ("pi_...", "payment_intent"); an entitlement summary has no id of its own.
  • :payment_id: the payment it concerns, when it concerns one: the object itself for a payment, or the payment a checkout, charge, refund or dispute belongs to. The id MishkaPay.fetch_payment/3 takes.
  • :subscription_id: the subscription it concerns, when it concerns one: the object itself for a subscription, or the subscription an invoice belongs to. The id MishkaPay.fetch_subscription/3 takes.
  • :dispute_id: the dispute it concerns, for a charge.dispute.* event (MishkaPay.fetch_dispute/3).
  • :customer_id: the customer it changes: the customer itself, or the one a tax id, a saved payment method, a setup or an entitlement summary belongs to (customer.*, customer.tax_id.*, payment_method.*, setup_intent.*, entitlements.active_entitlement_summary.updated on Stripe). The id MishkaPay.fetch_customer/3 takes.
  • :livemode: whether it came from live or test mode.
  • :account: the connected account it is for, when the provider has those.
  • :created_at: when the provider made it.

Only the ids matter: a listener reads the object again from the provider (MishkaPay.fetch_payment/3), which stays the source of truth, and never trusts the order events arrive in.

Summary

Types

t()

The struct that builder/1 returns.

Functions

A sample %MishkaPay.Event{} populated from defaults + type-based fallbacks.

Types

t()

@type t() :: %MishkaPay.Event{
  account: String.t() | nil,
  created_at: DateTime.t() | nil,
  customer_id: String.t() | nil,
  dispute_id: String.t() | nil,
  id: String.t(),
  livemode: boolean() | nil,
  object_id: String.t() | nil,
  object_type: String.t() | nil,
  payment_id: String.t() | nil,
  provider: String.t(),
  subscription_id: String.t() | nil,
  tenant: term() | nil,
  type: String.t()
}

The struct that builder/1 returns.

FieldTypeRequiredDefaultDescriptionDerives
:providerString.t()yesvalidate(not_nil_value, string)
:tenantterm() | nilno
:idString.t()yesvalidate(not_nil_value, string, not_empty)
:typeString.t()yesvalidate(not_nil_value, string, not_empty)
:object_idString.t() | nilnovalidate(string)
:object_typeString.t() | nilnovalidate(string)
:payment_idString.t() | nilnovalidate(string)
:subscription_idString.t() | nilnovalidate(string)
:dispute_idString.t() | nilnovalidate(string)
:customer_idString.t() | nilnovalidate(string)
:livemodeboolean() | nilnofalsevalidate(boolean)
:accountString.t() | nilnovalidate(string)
:created_atDateTime.t() | nilnovalidate(struct)

Functions

builder(attrs_or_input, error \\ false)

enforce_keys()

enforce_keys(field)

example()

A sample %MishkaPay.Event{} populated from defaults + type-based fallbacks.

keys()

keys(field)