Shopifex.PaymentGuard behaviour (Shopifex v2.2.1) View Source
Context behaviour responsible for fetching and using payment grants.
Link to this section Summary
Callbacks
After payment has been accepted, this function is meant to persist the
payment. Default behaviour is to create a grant schema record. charge_id
is
the external id for the Shopify charge record.
Gets a plan with a given identifier
Returns a payment record which grants access to the payment guard.
Default behaviour filters where remaining_usages
is greater than
0 or has a nil value (unlimited usage). You can also provide a list of
grants in place of the first parameter in order to avoid a trip to the
database.
Returns a list of valid grants which are associated with the store.
Get a list of plans for shop based on provided guard
Updates the grant to reflect the usage of it in some way. Defaults to decrementing
the remaining_usages
property if it's not nil. If it is nil, the grant has
unlimited usages
Link to this section Types
Specs
grant() :: %{ charge_id: pos_integer(), grants: [String.t()], remaining_usages: pos_integer(), total_usages: pos_integer() }
Specs
guard() :: String.t()
Specs
Specs
Link to this section Callbacks
Specs
create_grant(shop :: shop(), plan :: plan(), charge_id :: pos_integer()) :: {:ok, any()}
After payment has been accepted, this function is meant to persist the
payment. Default behaviour is to create a grant schema record. charge_id
is
the external id for the Shopify charge record.
Specs
get_plan(plan_id :: String.t() | pos_integer()) :: plan()
Gets a plan with a given identifier
Specs
Returns a payment record which grants access to the payment guard.
Default behaviour filters where remaining_usages
is greater than
0 or has a nil value (unlimited usage). You can also provide a list of
grants in place of the first parameter in order to avoid a trip to the
database.
Specs
Returns a list of valid grants which are associated with the store.
Specs
Get a list of plans for shop based on provided guard
Specs
Updates the grant to reflect the usage of it in some way. Defaults to decrementing
the remaining_usages
property if it's not nil. If it is nil, the grant has
unlimited usages