Test Mode
Use test mode to develop and test your integration without processing real payments.
Test vs Live
| Test Mode | Live Mode | |
|---|---|---|
| API Key Prefix | sk_test_... | sk_live_... |
| Base URL | api.sandbox.fyber.one | api.fyber.one |
| Real Charges | No | Yes |
| Test Cards | Required | Real cards only |
Test Cards
Use these card numbers in test mode:
Successful Payments
| Card | Number | Description |
|---|---|---|
| Visa | 4242 4242 4242 4242 | Always succeeds |
| Mastercard | 5555 5555 5555 4444 | Always succeeds |
| Amex | 3782 822463 10005 | Always succeeds |
Declined Payments
| Card | Number | Description |
|---|---|---|
| Declined | 4000 0000 0000 0002 | Always declined |
| Insufficient Funds | 4000 0000 0000 9995 | Insufficient funds |
| Expired Card | 4000 0000 0000 0069 | Expired card error |
| Incorrect CVC | 4000 0000 0000 0127 | CVC check fails |
3D Secure
| Card | Number | Description |
|---|---|---|
| 3DS Required | 4000 0027 6000 3184 | Requires 3D Secure |
| 3DS Authenticated | 4000 0000 0000 3220 | 3DS succeeds |
| 3DS Failed | 4000 0000 0000 3063 | 3DS fails |
Special Cases
| Card | Number | Description |
|---|---|---|
| Processing Error | 4000 0000 0000 0119 | Processing error |
| Rate Limited | 4000 0000 0000 6975 | Rate limit error |
Card Details
For all test cards, use:
| Field | Value |
|---|---|
| Expiry Date | Any future date (e.g., 12/25) |
| CVC | Any 3 digits (e.g., 123) |
| ZIP/Postal | Any value |
Example Usage
Hosted Checkout
Create a checkout session and use test cards on the hosted page:
javascript
const session = await fyber.checkout.sessions.create({
mode: 'payment',
amount: 5000,
currency: 'JMD',
successUrl: 'https://yoursite.com/success',
cancelUrl: 'https://yoursite.com/cancel',
});
// Redirect to session.url
// Enter test card: 4242 4242 4242 4242Testing Webhooks
Test webhook signatures with your test webhook secret:
javascript
// Use your test webhook secret (whsec_test_...)
const event = Fyber.webhooks.verify(
payload,
signature,
'whsec_test_your_secret'
);Local Development
Use ngrok to receive webhooks locally:
bash
# Start ngrok
ngrok http 3000
# Use the ngrok URL for webhooks
# https://abc123.ngrok.io/webhooks/fyberTesting Subscriptions
- Create a subscription with a test card
- Use the Console to simulate billing cycles
- Test payment failure scenarios with decline cards
javascript
// Create subscription with successful card
const sub = await fyber.subscriptions.create({
customerId: 'cus_test_123',
tokenId: 'tok_test_456', // From 4242... card
amount: 999,
interval: 'month',
});Testing Installments
- Check eligibility (always returns eligible in test mode)
- Create an installment plan
- Payments are simulated on schedule
javascript
// Check eligibility in test mode
const eligibility = await fyber.installments.checkEligibility({
customerId: 'cus_test_123',
amount: 50000,
});
// eligibility.eligible = true in test modeGoing Live
When ready to accept real payments:
- Get live API keys from the Console
- Replace
sk_test_...withsk_live_... - Update base URL to
api.fyber.one - Test with real cards in small amounts
- Monitor the Console dashboard
javascript
// Development
const fyber = new Fyber({
apiKey: process.env.FYBER_TEST_KEY,
environment: 'test',
});
// Production
const fyber = new Fyber({
apiKey: process.env.FYBER_LIVE_KEY,
environment: 'live',
});Best Practices
- Use environment variables for API keys
- Test all scenarios - success, decline, 3DS, errors
- Verify webhook handling with test events
- Test edge cases - refunds, cancellations, retries
- Start small in live mode - test with small amounts first