Testing Guide
Comprehensive guide to testing your EPaySe integration before going live.
Thorough testing is critical for a successful payment integration. Use our sandbox environment to test all scenarios before processing real payments.
Sandbox Environment
Accessing Sandbox
The sandbox environment provides full API functionality with test data
Sandbox Dashboard
https://sandbox.epayse.comAPI Base URL
https://sandbox.epayse.com/v1 API Keys
Get sandbox API keys from the dashboard under Settings → API Keys
Sandbox Limitations
Test Scenarios
Test these critical scenarios to ensure your integration handles all payment flows correctly.
Successful Payment
Test successful payment flow with various card types
Failed Payment
Test declined cards and insufficient funds scenarios
3D Secure Flow
Test 3D Secure authentication process
Webhook Delivery
Test webhook notification reception and handling
Webhook Testing
Webhooks require a publicly accessible HTTPS URL. For local development, use ngrok to create a secure tunnel.
Use ngrok for Local Testing
<?php
// Use ngrok for local webhook testing
// 1. Start ngrok: ngrok http 8000
// 2. Copy the HTTPS URL (e.g., https://abc123.ngrok.io)
// 3. Set as webhook_url in transaction creation
$transaction = $client->transactions->create([
'amount' => 10000,
'currency' => 'USD',
'customer_email' => '[email protected]',
'webhook_url' => 'https://abc123.ngrok.io/webhooks/payment',
// ... other parameters
]);
// Your webhook endpoint
// POST /webhooks/payment
$payload = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_EPAYSE_SIGNATURE'] ?? '';
// Log for debugging
error_log('Webhook received: ' . $payload);
error_log('Signature: ' . $signature);
try {
$event = $client->webhooks->verify($payload, $signature);
error_log('Event type: ' . $event->type);
error_log('Event data: ' . json_encode($event->data));
// Handle event...
} catch (Exception $e) {
error_log('Webhook error: ' . $e->getMessage());
}Webhook Testing Tips
- Always verify webhook signatures before processing
- Return HTTP 200 status code within 5 seconds
- Handle webhook retries (EPaySe retries up to 3 times)
- Log all webhook payloads for debugging
Debugging
Enable debug mode in the SDK to get detailed information about API requests and responses.
<?php
// Enable detailed error logging
ini_set('display_errors', 1);
ini_set('log_errors', 1);
error_reporting(E_ALL);
use EPaySe\Client;
$client = new Client([
'api_key' => 'sk_sandbox_...',
'api_secret' => '...',
'environment' => 'sandbox',
'debug' => true // Enable debug mode
]);
try {
$transaction = $client->transactions->create([...]);
// Log successful response
error_log('Transaction created: ' . $transaction->id);
error_log('Checkout URL: ' . $transaction->checkout_url);
} catch (\EPaySe\Exception\ApiException $e) {
// Log detailed error information
error_log('API Error: ' . $e->getMessage());
error_log('Status Code: ' . $e->getStatusCode());
error_log('Response Body: ' . $e->getResponseBody());
error_log('Request ID: ' . $e->getRequestId());
}Common Errors
Unauthorized
Invalid API key or signature
Solution: Verify your API credentials and HMAC signature generation
Bad Request
Invalid or missing parameters
Solution: Check the API documentation for required parameters
Validation Error
Parameters failed validation
Solution: Review validation error messages in the response
Rate Limit
Too many requests
Solution: Implement exponential backoff and respect rate limits
API Testing Tools
Testing with Postman
Use Postman to test API endpoints without writing code. Import our collection to get started.
{
"info": {
"name": "EPaySe API",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Create Transaction",
"request": {
"method": "POST",
"header": [
{
"key": "X-Api-Key-Id",
"value": "{{api_key}}"
},
{
"key": "X-Signature",
"value": "{{signature}}"
},
{
"key": "X-Timestamp",
"value": "{{timestamp}}"
},
{
"key": "X-Nonce",
"value": "{{nonce}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"amount\": 10000,\n \"currency\": \"USD\",\n \"customer_email\": \"[email protected]\"\n}"
},
"url": {
"raw": "{{base_url}}/v1/transaction/create",
"host": ["{{base_url}}"],
"path": ["v1", "transaction", "create"]
}
}
}
]
}Testing with cURL
Use cURL commands to test API endpoints from the command line.
# Test transaction creation with cURL
curl -X POST https://sandbox.epayse.com/v1/transaction/create \
-H "Content-Type: application/json" \
-H "X-Api-Key-Id: sk_sandbox_your_api_key" \
-H "X-Signature: sha256=generated_signature" \
-H "X-Timestamp: $(date +%s)" \
-H "X-Nonce: $(uuidgen)" \
-d '{
"amount": 10000,
"currency": "USD",
"customer_email": "[email protected]",
"customer_name": "Test User",
"description": "Test Transaction",
"return_url": "https://yoursite.com/success",
"cancel_url": "https://yoursite.com/cancel"
}'Testing Best Practices
Test All Scenarios
Test successful payments, failures, refunds, and edge cases
Verify Webhooks
Always verify webhook signatures before processing
Handle Errors
Implement proper error handling and logging
Use Idempotency
Include idempotency keys to prevent duplicate transactions
