Testing
Guide to testing your crypto payment integration safely before going live.
Overview
Testing is critical before deploying crypto payments to production. Use Rach's sandbox environment to test all scenarios without risking real funds.
Testing Environment
Test API Keys
Use your test API key (prefix: test_sk_) to access testnet blockchains:
bash
export RACH_API_KEY="test_sk_your_test_key_here"Testnet Networks
| Mainnet | Testnet | Explorer |
|---|---|---|
| BSC | BSC Testnet | testnet.bscscan.com |
| Ethereum | Sepolia | sepolia.etherscan.io |
| Polygon | Mumbai | mumbai.polygonscan.com |
| Tron | Shasta | shasta.tronscan.org |
| Solana | Devnet | explorer.solana.com |
Getting Test Tokens
1. Get Native Tokens (for gas)
- BSC Testnet BNB: BSC Faucet
- Sepolia ETH: Sepolia Faucet
- Mumbai MATIC: Mumbai Faucet
- Shasta TRX: Shasta Faucet
- Solana Devnet SOL: Solana Faucet
2. Get Test Stablecoins
Most testnets have test USDT/USDC contracts you can mint from.
Test Scenarios
Scenario 1: Successful Payment ✅
- Create checkout with test API key
- Send exact amount to deposit address
- Wait for confirmations
- Verify webhook received
- Check merchant balance credited
Scenario 2: Multiple Networks 🌐
Test on all supported networks:
- BSC Testnet
- Sepolia (Ethereum)
- Mumbai (Polygon)
- Shasta (Tron)
- Solana Devnet
Scenario 3: Webhook Verification 🔒
- Set up webhook endpoint with signature verification
- Create test checkout
- Make payment
- Verify webhook signature validates correctly
- Test with invalid signature (should reject)
Scenario 4: Expired Checkout ⏱️
- Create checkout with short expiration
- Wait for expiration
- Verify status changes to "expired"
- Attempt payment after expiration
Scenario 5: Error Handling ❌
Test these error cases:
- Invalid API key
- Invalid network
- Invalid currency
- Missing required fields
- Malformed requests
Integration Testing
javascript
// Example test suite
describe('Crypto Payment Integration', () => {
it('should create checkout successfully', async () => {
const checkout = await createCheckout({
amount: 100,
currency: 'USDT',
network: 'BSC'
});
expect(checkout.checkout_id).toBeDefined();
expect(checkout.deposit_address).toBeDefined();
expect(checkout.qr_code).toBeDefined();
});
it('should verify webhook signatures', () => {
const payload = { event: 'payment.confirmed' };
const signature = generateHMAC(payload, webhookSecret);
expect(verifySignature(payload, signature)).toBe(true);
});
it('should handle payment confirmation', async () => {
const webhook = {
event: 'payment.confirmed',
checkout_id: 'test_123',
amount: '100.00'
};
await handleWebhook(webhook);
const order = await getOrder('test_123');
expect(order.status).toBe('paid');
});
});Load Testing
Test your integration under load:
javascript
// Load test example
async function loadTest() {
const promises = [];
for (let i = 0; i < 100; i++) {
promises.push(createCheckout({
amount: 10,
currency: 'USDT',
network: 'BSC',
reference: `LOAD-TEST-${i}`
}));
}
const results = await Promise.all(promises);
console.log(`Created ${results.length} checkouts`);
}Checklist
Testing Checklist
- ✅ Test checkout creation on all networks
- ✅ Test payment detection and confirmation
- ✅ Test webhook signature verification
- ✅ Test error handling
- ✅ Test edge cases (underpayment, overpayment, expiration)
- ✅ Test concurrent checkouts
- ✅ Load test with expected traffic
- ✅ Review logs for errors
- ✅ Verify merchant balance updates
Going to Production
Once testing is complete:
- Switch to production API key
- Update webhook URLs to production
- Start with small real transactions
- Monitor closely for first few days
- Set up alerts and monitoring
