MishkaPay.Ash.Owner (Mishka Pay v0.0.1)

Copy Markdown View Source

How a payment or a subscription row finds its user (belongs_to_user of MishkaPay.Ash.Resource).

:start_checkout names the actor as the checkout's :owner (MishkaPay.Checkout), unless the checkout names one itself. The provider keeps the owner on the payment or the subscription, so every sync, from an action or a webhook, writes it into the user attribute again: the provider's word, like every other synced field. An owner that is not a user id of the host leaves the attribute empty.

Summary

Functions

attrs (a checkout map) with the actor's primary key as its :owner, unless they name one or there is no actor.

The changeset with owner in the resource's user attribute, cast to its type; empty when the resource has no belongs_to_user, or when owner is not a value of that type.

Functions

into(attrs, actor)

@spec into(map(), term()) :: map()

attrs (a checkout map) with the actor's primary key as its :owner, unless they name one or there is no actor.

write(changeset, owner)

@spec write(Ash.Changeset.t(), String.t() | nil) :: Ash.Changeset.t()

The changeset with owner in the resource's user attribute, cast to its type; empty when the resource has no belongs_to_user, or when owner is not a value of that type.