PlexySDK DOCS

Error Codes

API error types and codes

Error Codes

Understand and handle errors returned by the Plexy API.

Error structure

{
  "error": {
    "type": "invalid_request_error",
    "code": "parameter_missing",
    "message": "Missing required parameter: amount",
    "param": "amount",
    "request_id": "req_abc123"
  }
}
FieldDescription
typeError category
codeSpecific error code
messageHuman-readable description
paramParameter that caused error (if applicable)
request_idUnique request identifier

Error types

api_error

Server-side errors. Usually temporary - retry with backoff.

CodeDescription
api_errorGeneral API error

invalid_request_error

Client-side request errors. Fix the request and retry.

CodeDescription
parameter_missingRequired parameter not provided
parameter_invalidParameter value is invalid
parameter_unknownUnrecognized parameter
resource_missingReferenced resource doesn't exist
idempotency_errorIdempotency key reused with different params

authentication_error

API key or authentication problems.

CodeDescription
api_key_invalidInvalid API key
api_key_expiredAPI key has expired
api_key_revokedAPI key was revoked

card_error

Payment card issues. Display message to customer.

CodeDescription
card_declinedCard was declined
expired_cardCard has expired
incorrect_cvcCVC is incorrect
incorrect_numberCard number is incorrect
insufficient_fundsCard has insufficient funds
processing_errorError processing card

Handling errors

try {
  const payment = await plexy.payments.create({ /* ... */ });
} catch (error) {
  switch (error.type) {
    case 'card_error':
      // Show message to customer
      displayError(error.message);
      break;

    case 'invalid_request_error':
      // Log and fix integration
      console.error('Integration error:', error.code, error.param);
      break;

    case 'authentication_error':
      // Check API key configuration
      console.error('Auth error:', error.code);
      break;

    case 'api_error':
      // Retry with exponential backoff
      await retryWithBackoff(() => createPayment());
      break;
  }
}

Customer-facing messages

Map error codes to user-friendly messages:

CodeCustomer Message
card_declined"Your card was declined. Please try a different card."
expired_card"Your card has expired. Please use a valid card."
incorrect_cvc"The security code is incorrect. Please check and try again."
insufficient_funds"Your card has insufficient funds. Please try a different card."
processing_error"An error occurred processing your card. Please try again."

See also

На этой странице