Skip to content

Errors

aiopayme provides a set of built-in errors that map directly to Payme error codes. All errors are available via the Errors class.

Usage

from aiopayme.exceptions import Errors

@router.check_perform_transaction()
async def check_perform(ctx: CheckPerformTransactionCtx):
    order = await db.get_order(ctx.account.order_id)
    if not order:
        raise Errors.invalid_account()
    if order.amount * 100 != ctx.amount:
        raise Errors.invalid_amount()
    return ctx.ok(allow=True)

Available Errors

Method Payme Error Code Description
Errors.invalid_amount() -31001 Amount is incorrect
Errors.invalid_account() -31050 Account not found
Errors.transaction_not_found() -31003 Transaction does not exist
Errors.unable_to_perform() -31008 Transaction cannot be performed
Errors.internal_error() -32400 Internal server error