Testing Guide
Learn how to properly test your ZenPay integration before deploying to production.
Test Mode Overview
ZenPay provides a dedicated test environment that mirrors our production system. This allows you to test your integration thoroughly without processing real payments or affecting your live data.
Test Mode Features
- Full API access with test credentials
- Simulated payment processing
- Test webhooks and events
- Separate test dashboard
Test vs Live Keys
API keys are prefixed to indicate their environment:pk_test_xxxxx
- Test publishable keysk_test_xxxxx
- Test secret keypk_live_xxxxx
- Live publishable keysk_live_xxxxx
- Live secret key
Test Cards and Payment Methods
Use these test cards to simulate various payment scenarios without processing real transactions.
Card Number | Brand | CVC | Date | Result |
---|---|---|---|---|
4242 4242 4242 4242 | Visa | Any 3 digits | Any future date | Success |
4000 0025 0000 3155 | Visa | Any 3 digits | Any future date | Requires Authentication |
4000 0000 0000 9995 | Visa | Any 3 digits | Any future date | Insufficient Funds |
4000 0000 0000 0002 | Visa | Any 3 digits | Any future date | Card Declined |
5555 5555 5555 4444 | Mastercard | Any 3 digits | Any future date | Success |
3782 8224 6310 005 | American Express | Any 4 digits | Any future date | Success |
Note: For testing international payments, use test card numbers with postal codes from different countries. Each test card can be used with any valid expiration date in the future and any random CVC number.
Testing Webhooks
To properly test your webhook integration, you need to:
Set up a webhook endpoint
Create an endpoint on your server to receive webhook events. For local development, you can use tools like ngrok or localtunnel to expose your local server to the internet.
# Example: Exposing a local server on port 3000
ngrok http 3000
Register your endpoint in the dashboard
Go to the Developers → Webhooks section in your ZenPay Dashboard and add your webhook URL. Make sure to select the events you want to receive.
Trigger test events
You can trigger test webhook events in several ways:
- Create test payments from the API
- Use the "Send test webhook" button in the dashboard
- Manually create resources through the dashboard
Verify webhook signatures
Always verify that the webhooks you receive are sent by ZenPay by checking the signature:
// Node.js example
const event = zenpay.webhooks.constructEvent(
payload,
signature,
webhookSecret
);
// If the signature is invalid, constructEvent will throw an error
Testing Best Practices
Test the customer experience
Use our checkout testing tools to simulate the full payment flow from the customer's perspective, including form validation, error handling, and success states.
Test error scenarios
Don't just test the happy path. Use our test cards to trigger various error scenarios and ensure your application handles them gracefully, providing appropriate feedback to users.
Test your integration end-to-end
Confirm that the entire payment flow works as expected, from collecting payment information to fulfilling orders or granting access to content after successful payments.
Use automated testing
Implement automated tests for your ZenPay integration to catch regressions early. Our API is designed to be testable, with predictable responses for test cards and scenarios.
Moving to Production
Once you've thoroughly tested your integration, follow these steps to go live:
Complete your ZenPay account setup
Ensure all required business information is provided and verified in your ZenPay account.
Switch to live API keys
Replace your test API keys with live keys. Make sure to update all instances, including your webhook endpoints.
Perform a live test
Make a small real payment to verify that your production setup works correctly. You can refund this payment immediately after verification.
Monitor your integration
Set up monitoring and alerting for payment failures, webhook delivery issues, and other critical events to quickly identify and resolve any problems.
Next Steps
Ensure your integration is secure and compliant by reviewing our security guidelines: