MPP.Methods.Shared (mpp v0.10.0)

Copy Markdown View Source

Verification helpers shared by the payment-method modules (MPP.Methods.EVM, MPP.Methods.Tempo, MPP.Methods.Stripe).

These are small, method-agnostic building blocks. require_config/3 takes a human-readable method label so its error message names the calling method.

Summary

Functions

Assert an on-chain transaction receipt succeeded (status == 1).

Parse a charge amount string into an integer.

Fetch a required key from a method's config map.

Functions

check_receipt_status(map)

@spec check_receipt_status(map()) :: :ok | {:error, MPP.Errors.t()}

Assert an on-chain transaction receipt succeeded (status == 1).

Returns :ok, or a :verification_failed error when the transaction reverted.

parse_charge_amount(amount)

@spec parse_charge_amount(String.t()) :: {:ok, integer()} | {:error, MPP.Errors.t()}

Parse a charge amount string into an integer.

Returns {:ok, integer}, or a :verification_failed error when amount is not a valid integer string.

require_config(config, key, label)

@spec require_config(map(), term(), String.t()) ::
  {:ok, term()} | {:error, MPP.Errors.t()}

Fetch a required key from a method's config map.

Returns {:ok, value}, or a :verification_failed error naming the method via label (e.g. "EVM", "Tempo", "Stripe") and the missing key.