Reference: Error Codes
Complete reference for all error codes, messages, and resolution steps in the ConnexPay payments SDK
Error Categories
All SDK errors fall into two main categories:
- VALIDATION_ERROR - Form field validation and input errors
- PAYMENT_ERROR - Payment processing and system errors
Validation Errors (VALIDATION_ERROR)
Card Number Validation
| Error Message | Cause | Resolution |
|---|---|---|
"Card number is required" | Empty card number field | Prompt user to enter card number |
"Invalid card number" | Invalid card number format or fails Luhn algorithm | Guide user to check card number |
"Card type not supported" | Card network not accepted | Display accepted card types |
"Card number too short" | Incomplete card number | Prompt user to complete entry |
"Card number too long" | Card number exceeds maximum length | Guide user to check entry |
Field Name: cardNumber
Example Handling:
connexpay.on('error', (error) => {
if (error.category === 'VALIDATION_ERROR') {
const cardNumberError = error.fields?.find(f => f.field === 'cardNumber');
if (cardNumberError) {
showFieldError('card-number', cardNumberError.message);
}
}
});Expiration Date Validation
| Error Message | Cause | Resolution |
|---|---|---|
"Expiration date is required" | Empty expiration field | Prompt user to enter expiration date |
"Invalid expiration date" | Invalid date format | Show expected format (MM/YY) |
"Card has expired" | Expiration date is in the past | Request different payment method |
"Invalid expiration month" | Month not between 01-12 | Guide user to correct month |
"Invalid expiration year" | Year format invalid | Show expected year format |
"Expiration date too far in future" | Date more than 20 years ahead | Guide user to check date |
Field Name: expirationDate
Expected Formats:
MM/YY(preferred)MM/YYYYMMYY
Example Handling:
function handleExpirationError(fieldError) {
const input = document.getElementById('expiry-input');
const errorDiv = document.getElementById('expiry-error');
errorDiv.textContent = fieldError.message;
errorDiv.style.display = 'block';
input.classList.add('error');
// Show format hint for format errors
if (fieldError.message.includes('Invalid expiration date')) {
errorDiv.textContent += ' (Use MM/YY format)';
}
}Security Code Validation
| Error Message | Cause | Resolution |
|---|---|---|
"Security code is required" | Empty CVV field | Prompt user to enter security code |
"Invalid security code" | Wrong CVV format for card type | Show where to find CVV on card |
"Security code too short" | CVV shorter than expected | Guide user to complete entry |
"Security code too long" | CVV longer than expected | Guide user to check entry |
Field Name: securityCode
Expected Formats:
- Visa, Mastercard, Discover: 3 digits
- American Express: 4 digits
Example Handling:
function showCVVHelp(cardType) {
const helpText = cardType === 'amex'
? 'Enter the 4-digit code on the front of your card'
: 'Enter the 3-digit code on the back of your card';
showTooltip('cvv-help', helpText);
}General Form Validation
| Error Message | Cause | Resolution |
|---|---|---|
"Please complete all required fields" | Multiple fields missing | Highlight missing fields |
"Form contains invalid data" | Multiple validation errors | Show field-specific errors |
"Payment method validation failed" | Overall form validation failed | Review all field errors |
Payment Errors (PAYMENT_ERROR)
Payment Method and Transaction Errors
Based on the actual SDK implementation, these are the real error messages:
| Error Message | Cause | Resolution |
|---|---|---|
"No payment method has been selected" | User hasn't selected payment method | Show payment method options |
"Payment already performed" | Checkout session already used | Create new checkout session |
"ConnexPay SDK is not ready" | SDK not initialized | Wait for 'ready' event |
"Apple Pay: User canceled." | User canceled Apple Pay | Allow retry with different method |
"Google Pay: User canceled." | User canceled Google Pay | Allow retry with different method |
Example Handling:
function handlePaymentError(error) {
switch (error.message) {
case 'No payment method has been selected':
showPaymentMethodSelection();
break;
case 'Payment already performed':
// Create new checkout session
window.location.reload();
break;
case 'ConnexPay SDK is not ready':
// Wait for SDK to be ready
connexpay.on('ready', () => processPayment());
break;
case 'Apple Pay: User canceled.':
case 'Google Pay: User canceled.':
// Don't show error for user cancellation
resetPaymentForm();
break;
default:
showGenericError('Payment error: ' + error.message);
}
}Example Prevention:
let paymentInProgress = false;
async function processPayment() {
if (paymentInProgress) {
console.log('Payment already in progress');
return;
}
try {
paymentInProgress = true;
const result = await connexpay.confirmPayment();
// Handle success
} catch (error) {
if (error.message === 'Payment already performed') {
// Create new checkout session
window.location.reload();
}
} finally {
paymentInProgress = false;
}
}Digital Wallet Errors
| Error Message | Cause | Resolution |
|---|---|---|
"Apple Pay: User canceled." | User canceled Apple Pay | Allow retry with different method |
"Google Pay: User canceled." | User canceled Google Pay | Allow retry with different method |
Example Handling:
function handleWalletError(error) {
switch (error.message) {
case 'Apple Pay: User canceled.':
case 'Google Pay: User canceled.':
// Don't show error for user cancellation
resetPaymentForm();
break;
default:
showError('Payment method error: ' + error.message);
}
}SDK State Management
| Error Message | Cause | Resolution |
|---|---|---|
"ConnexPay SDK is not ready" | SDK not initialized | Wait for 'ready' event |
"Payment already performed" | Checkout session already used | Create new checkout session |
Error Response Structure
Complete Error Object
interface UserError extends Error {
category: 'VALIDATION_ERROR' | 'PAYMENT_ERROR';
message: string; // Human-readable error message
fields?: FieldError[]; // Field-specific errors (validation only)
}
interface FieldError {
field: 'cardNumber' | 'expirationDate' | 'securityCode';
message: string;
}Example Error Responses
Validation Error:
{
"category": "VALIDATION_ERROR",
"message": "Please correct the following errors",
"fields": [
{
"field": "cardNumber",
"message": "Invalid card number"
},
{
"field": "expirationDate",
"message": "Card has expired"
}
]
}Payment Error:
{
"category": "PAYMENT_ERROR",
"message": "No payment method has been selected"
}Next Steps
- Check API Reference for method details
- Explore Error Handling implementation patterns
Updated 3 months ago