Skip to Content
Error Codes

Error Codes

Complete reference for all QPay V2 API error codes, HTTP status codes, and SDK error handling patterns. Use this page to diagnose issues and implement robust error handling in your application.


Error Response Format

When the QPay V2 API returns an error, the response body contains a JSON object with two fields:

{ "error_code": "INVOICE_NOTFOUND", "message": "Invoice not found" }

The HTTP status code is included in the response headers. Every SDK parses this into a structured error type that exposes:

PropertyDescription
Status CodeThe HTTP status code (e.g., 401, 404, 422)
Error CodeThe QPay error code string (e.g., INVOICE_NOTFOUND)
MessageA human-readable description of the error
Raw BodyThe full response body as a string, for debugging

HTTP Status Codes

QPay V2 uses standard HTTP status codes to indicate the result of an API request.

StatusMeaningWhen It Happens
200OKRequest succeeded
400Bad RequestInvalid request body, missing required fields, or invalid field values
401UnauthorizedMissing or invalid authentication credentials, expired token
403ForbiddenValid credentials but insufficient permissions for this operation
404Not FoundThe requested resource (invoice, payment, merchant) does not exist
409ConflictResource state conflict (e.g., invoice already paid, already cancelled)
422Unprocessable EntityRequest is well-formed but contains semantic errors (e.g., invalid amount)
500Internal Server ErrorSomething went wrong on QPay’s side — retry after a short delay
502Bad GatewayQPay upstream service is temporarily unavailable
503Service UnavailableQPay API is temporarily down for maintenance

SDK Error Handling

Every SDK provides a structured error type and named constants for all QPay error codes. Here is how to handle errors in each language:

Go

import qpay "github.com/qpay-sdk/qpay-go" invoice, err := client.CreateSimpleInvoice(ctx, req) if err != nil { if qErr, ok := qpay.IsQPayError(err); ok { fmt.Printf("Status: %d\n", qErr.StatusCode) fmt.Printf("Code: %s\n", qErr.Code) fmt.Printf("Message: %s\n", qErr.Message) switch qErr.Code { case qpay.ErrAuthenticationFailed: // Handle authentication failure case qpay.ErrInvoiceCodeInvalid: // Handle invalid invoice code case qpay.ErrInvalidAmount: // Handle invalid amount default: // Handle other errors } } else { // Network error, timeout, etc. fmt.Printf("Error: %v\n", err) } }

JavaScript / TypeScript

import { QPayError, isQPayError, ERR_INVOICE_NOT_FOUND } from 'qpay-js'; try { await client.createSimpleInvoice(request); } catch (err) { if (isQPayError(err)) { console.log(err.statusCode); // 404 console.log(err.code); // "INVOICE_NOTFOUND" console.log(err.message); // Human-readable message console.log(err.rawBody); // Raw response for debugging if (err.code === ERR_INVOICE_NOT_FOUND) { // Handle specific error } } }

Python

from qpay import QPayError, ERR_INVOICE_NOT_FOUND try: client.create_simple_invoice(request) except QPayError as e: print(f"Status: {e.status_code}") # 404 print(f"Code: {e.code}") # "INVOICE_NOTFOUND" print(f"Message: {e.message}") # Human-readable message print(f"Raw: {e.raw_body}") # Raw response if e.code == ERR_INVOICE_NOT_FOUND: # Handle specific error pass

PHP

use QPay\Exceptions\QPayException; try { $client->createSimpleInvoice($request); } catch (QPayException $e) { echo $e->statusCode; // 404 echo $e->errorCode; // "INVOICE_NOTFOUND" echo $e->errorMessage; // Human-readable message echo $e->rawBody; // Raw response match ($e->errorCode) { QPayException::INVOICE_NOTFOUND => handleNotFound(), QPayException::AUTHENTICATION_FAILED => handleAuthError(), default => handleUnknown($e), }; }

Authentication Errors

These errors occur during token acquisition (POST /v2/auth/token) or when using an expired/invalid token.

Error CodeHTTP StatusDescriptionResolution
AUTHENTICATION_FAILED401Invalid username or passwordVerify your QPAY_USERNAME and QPAY_PASSWORD credentials
NO_CREDENDIALS401Missing credentials in the requestEnsure the Basic Auth header is present. SDKs handle this automatically
PERMISSION_DENIED403Valid credentials but insufficient permissionsContact QPay support to verify your account permissions

[!NOTE] All SDKs handle token management automatically. If you receive AUTHENTICATION_FAILED, the issue is with your merchant credentials, not your code.


Invoice Errors

These errors relate to creating, retrieving, or cancelling invoices.

Error CodeHTTP StatusDescriptionResolution
INVOICE_NOTFOUND404Invoice does not existVerify the invoice ID. The invoice may have been deleted
INVOICE_PAID409Invoice has already been paidPaid invoices cannot be cancelled or modified. Create a refund instead
INVOICE_ALREADY_CANCELED409Invoice was already cancelledNo action needed — the invoice is already in the desired state
INVOICE_CODE_INVALID400Invalid invoice codeVerify your QPAY_INVOICE_CODE. Contact QPay if you need a new code
INVOICE_CODE_REGISTERED409Invoice code is already registeredUse your existing invoice code or request a new one from QPay
INVOICE_LINE_REQUIRED400Invoice lines are requiredEbarimt invoices must include at least one line item in the lines array
INVOICE_RECEIVER_DATA_REQUIRED400Invoice receiver data is missingProvide receiver data in the invoice request
INVOICE_RECEIVER_DATA_EMAIL_REQUIRED400Receiver email is missingInclude the receiver’s email address
INVOICE_RECEIVER_DATA_PHONE_REQUIRED400Receiver phone is missingInclude the receiver’s phone number
INVOICE_RECEIVER_DATA_ADDRESS_REQUIRED400Receiver address is missingInclude the receiver’s address

Payment Errors

These errors relate to checking, cancelling, or refunding payments.

Error CodeHTTP StatusDescriptionResolution
PAYMENT_NOTFOUND404Payment does not existVerify the payment ID. Use checkPayment with the invoice ID instead
PAYMENT_NOT_PAID409Payment has not been completedThe customer has not yet completed the payment. Wait and check again
PAYMENT_ALREADY_CANCELED409Payment was already cancelledNo action needed — the payment is already cancelled

Amount Errors

These errors are returned when the invoice amount is invalid.

Error CodeHTTP StatusDescriptionResolution
INVALID_AMOUNT422Invalid payment amountAmount must be a positive number. Check for zero, negative, or non-numeric values
MIN_AMOUNT_ERR422Amount is below the minimumIncrease the amount to meet QPay’s minimum payment threshold
MAX_AMOUNT_ERR422Amount exceeds the maximumDecrease the amount or split into multiple invoices

Merchant Errors

These errors relate to merchant account status and registration.

Error CodeHTTP StatusDescriptionResolution
MERCHANT_NOTFOUND404Merchant not foundVerify your credentials. Your account may not exist or may have been removed
MERCHANT_INACTIVE403Merchant account is inactiveContact QPay support to reactivate your account
MERCHANT_ALREADY_REGISTERED409Merchant is already registeredUse your existing merchant credentials

Ebarimt (Tax Receipt) Errors

These errors relate to creating or cancelling electronic tax receipts (ebarimt).

Error CodeHTTP StatusDescriptionResolution
EBARIMT_NOT_REGISTERED400Ebarimt service not registeredRegister for ebarimt service with QPay before creating tax receipts
EBARIMT_CANCEL_NOTSUPPERDED400Ebarimt cancellation not supportedThis specific receipt type cannot be cancelled
EBARIMT_QR_CODE_INVALID400Invalid ebarimt QR codeThe QR code data is malformed or expired

Customer Errors

Error CodeHTTP StatusDescriptionResolution
CUSTOMER_NOTFOUND404Customer not foundVerify the customer identifier
CUSTOMER_DUPLICATE409Duplicate customer entryA customer with this identifier already exists
CUSTOMER_REGISTER_INVALID400Invalid customer register numberCheck the register number format (Mongolian national register)

Client Errors

Error CodeHTTP StatusDescriptionResolution
CLIENT_NOTFOUND404API client not foundVerify your API client configuration
CLIENT_USERNAME_DUPLICATED409Client username already takenChoose a different username

Account and Terminal Errors

Error CodeHTTP StatusDescriptionResolution
BANK_ACCOUNT_NOTFOUND404Bank account not foundVerify the bank account is linked to your merchant
ACCOUNT_BANK_DUPLICATED409Duplicate bank accountThis bank account is already registered
ACCOUNT_SELECTION_INVALID400Invalid account selectionSelect a valid bank account for the operation
CARD_TERMINAL_NOTFOUND404Card terminal not foundVerify the terminal ID
P2P_TERMINAL_NOTFOUND404P2P terminal not foundVerify the P2P terminal ID

QR and Transaction Errors

Error CodeHTTP StatusDescriptionResolution
QRCODE_NOTFOUND404QR code not foundThe QR code does not exist or has expired
QRCODE_USED409QR code has already been usedGenerate a new QR code by creating a new invoice
QRACCOUNT_NOTFOUND404QR account not foundVerify the QR account configuration
QRACCOUNT_INACTIVE403QR account is inactiveContact QPay to activate the QR account
TRANSACTION_NOT_APPROVED422Transaction was not approvedThe payment was declined by the bank. Customer should try again
TRANSACTION_REQUIRED400Transaction data is requiredInclude the required transaction data in the request

Other Errors

Error CodeHTTP StatusDescriptionResolution
OBJECT_DATA_ERROR400Invalid object dataCheck the request body for malformed fields
INVALID_OBJECT_TYPE400Invalid object typeUse "INVOICE" for invoice-related queries
INPUT_NOTFOUND404Input not foundVerify the input identifier
INPUT_CODE_REGISTERED409Input code already registeredUse the existing code or request a new one
INFORM_NOTFOUND404Information not foundThe requested information does not exist
SENDER_BRANCH_DATA_REQUIRED400Sender branch data is missingInclude the sender branch information
TAX_LINE_REQUIRED400Tax line items are requiredAdd at least one line item for tax calculation
TAX_PRODUCT_CODE_REQUIRED400Tax product code is missingEach line item must include a product code
BANK_MCC_ALREADY_ADDED409Bank MCC code already addedThis MCC code is already associated
BANK_MCC_NOT_FOUND404Bank MCC code not foundVerify the MCC code is valid
MCC_NOTFOUND404MCC code not foundThe MCC (Merchant Category Code) does not exist

Full Error Code Reference

A complete alphabetical listing of all QPay V2 error codes with their categories.

Error CodeCategoryHTTP Status
ACCOUNT_BANK_DUPLICATEDAccount409
ACCOUNT_SELECTION_INVALIDAccount400
AUTHENTICATION_FAILEDAuthentication401
BANK_ACCOUNT_NOTFOUNDAccount404
BANK_MCC_ALREADY_ADDEDOther409
BANK_MCC_NOT_FOUNDOther404
CARD_TERMINAL_NOTFOUNDTerminal404
CLIENT_NOTFOUNDClient404
CLIENT_USERNAME_DUPLICATEDClient409
CUSTOMER_DUPLICATECustomer409
CUSTOMER_NOTFOUNDCustomer404
CUSTOMER_REGISTER_INVALIDCustomer400
EBARIMT_CANCEL_NOTSUPPERDEDEbarimt400
EBARIMT_NOT_REGISTEREDEbarimt400
EBARIMT_QR_CODE_INVALIDEbarimt400
INFORM_NOTFOUNDOther404
INPUT_CODE_REGISTEREDOther409
INPUT_NOTFOUNDOther404
INVALID_AMOUNTAmount422
INVALID_OBJECT_TYPEOther400
INVOICE_ALREADY_CANCELEDInvoice409
INVOICE_CODE_INVALIDInvoice400
INVOICE_CODE_REGISTEREDInvoice409
INVOICE_LINE_REQUIREDInvoice400
INVOICE_NOTFOUNDInvoice404
INVOICE_PAIDInvoice409
INVOICE_RECEIVER_DATA_ADDRESS_REQUIREDInvoice400
INVOICE_RECEIVER_DATA_EMAIL_REQUIREDInvoice400
INVOICE_RECEIVER_DATA_PHONE_REQUIREDInvoice400
INVOICE_RECEIVER_DATA_REQUIREDInvoice400
MAX_AMOUNT_ERRAmount422
MCC_NOTFOUNDOther404
MERCHANT_ALREADY_REGISTEREDMerchant409
MERCHANT_INACTIVEMerchant403
MERCHANT_NOTFOUNDMerchant404
MIN_AMOUNT_ERRAmount422
NO_CREDENDIALSAuthentication401
OBJECT_DATA_ERROROther400
P2P_TERMINAL_NOTFOUNDTerminal404
PAYMENT_ALREADY_CANCELEDPayment409
PAYMENT_NOT_PAIDPayment409
PAYMENT_NOTFOUNDPayment404
PERMISSION_DENIEDAuthentication403
QRACCOUNT_INACTIVEQR403
QRACCOUNT_NOTFOUNDQR404
QRCODE_NOTFOUNDQR404
QRCODE_USEDQR409
SENDER_BRANCH_DATA_REQUIREDOther400
TAX_LINE_REQUIREDTax400
TAX_PRODUCT_CODE_REQUIREDTax400
TRANSACTION_NOT_APPROVEDTransaction422
TRANSACTION_REQUIREDTransaction400

Troubleshooting

”AUTHENTICATION_FAILED” on every request

  1. Verify QPAY_USERNAME and QPAY_PASSWORD are correct.
  2. Make sure you are using the right base URL — sandbox credentials do not work on production, and vice versa.
  3. Check that your merchant account is active by contacting QPay support.

”INVOICE_CODE_INVALID” when creating invoices

  1. Confirm your QPAY_INVOICE_CODE value matches exactly what QPay provided.
  2. Invoice codes are case-sensitive.
  3. If you recently received new credentials, your old invoice code may be invalid.

”INVALID_AMOUNT” errors

  1. Amount must be a positive number greater than zero.
  2. Amount must meet QPay’s minimum threshold (varies by merchant configuration).
  3. Do not send string values for the amount field — use a numeric type.

Timeout or network errors

  1. Check your internet connection and firewall rules.
  2. QPay API endpoints must be reachable from your server.
  3. Consider increasing the HTTP client timeout (default is usually 30 seconds).
  4. If the error persists, check QPay’s status  or contact support.

Token expiration issues

All SDKs handle token refresh automatically. If you are still seeing 401 errors:

  1. Ensure your SDK is at the latest version.
  2. Check that your system clock is synchronized (token expiry checks rely on accurate time).
  3. If using manual token management, call refreshToken() before the access token expires.

Callback (webhook) not received

  1. Verify your QPAY_CALLBACK_URL is a publicly accessible HTTPS URL.
  2. Check that your server returns a 200 status code within a reasonable time.
  3. Ensure your firewall allows incoming POST requests from QPay’s servers.
  4. Use checkPayment as a fallback — always verify payment status server-side.
Last updated on