What every provider adapter needs the same way, so each one keeps the same rules: idempotency
keys from a caller's own ids, the site's refund rule (MishkaPay.Credentials, :refunds), and
an :invalid error on a field. Stripe and PayPal use it; a provider a project writes can too.
Summary
Functions
The idempotency key of operation for material (a reference, or anything that names one
request) and tenant: the same inputs always give the same key, so a request sent again is the
same request at the provider. nil material gives nil: no key.
An :invalid class error on field with message, as a builder error would be.
The idempotency key of a refund under the site's rule: a site that refunds once has one refund
per payment, so the payment names it; one that refunds many times names each refund by its
:reference, which it then needs.
Whether refund may go to the provider for payment as it is now: refused when the site
refunds once and the payment has a refund, when nothing is left, or when a part refund is in
another currency or over what is left. What is left counts from what the provider took, a part
when a held payment was captured in part.
Functions
The idempotency key of operation for material (a reference, or anything that names one
request) and tenant: the same inputs always give the same key, so a request sent again is the
same request at the provider. nil material gives nil: no key.
@spec invalid(atom(), String.t()) :: {:error, Splode.Error.t()}
An :invalid class error on field with message, as a builder error would be.
@spec refund_key(MishkaPay.Refund.t(), map()) :: {:ok, String.t()} | {:error, Splode.Error.t()}
The idempotency key of a refund under the site's rule: a site that refunds once has one refund
per payment, so the payment names it; one that refunds many times names each refund by its
:reference, which it then needs.
@spec refundable(MishkaPay.Refund.t(), MishkaPay.Payment.t(), map()) :: :ok | {:error, Splode.Error.t()}
Whether refund may go to the provider for payment as it is now: refused when the site
refunds once and the payment has a refund, when nothing is left, or when a part refund is in
another currency or over what is left. What is left counts from what the provider took, a part
when a held payment was captured in part.