Skip to content

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

MainnetTestnetExplorer
BSCBSC Testnettestnet.bscscan.com
EthereumSepoliasepolia.etherscan.io
PolygonMumbaimumbai.polygonscan.com
TronShastashasta.tronscan.org
SolanaDevnetexplorer.solana.com

Getting Test Tokens

1. Get Native Tokens (for gas)

2. Get Test Stablecoins

Most testnets have test USDT/USDC contracts you can mint from.


Test Scenarios

Scenario 1: Successful Payment ✅

  1. Create checkout with test API key
  2. Send exact amount to deposit address
  3. Wait for confirmations
  4. Verify webhook received
  5. 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 🔒

  1. Set up webhook endpoint with signature verification
  2. Create test checkout
  3. Make payment
  4. Verify webhook signature validates correctly
  5. Test with invalid signature (should reject)

Scenario 4: Expired Checkout ⏱️

  1. Create checkout with short expiration
  2. Wait for expiration
  3. Verify status changes to "expired"
  4. 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:

  1. Switch to production API key
  2. Update webhook URLs to production
  3. Start with small real transactions
  4. Monitor closely for first few days
  5. Set up alerts and monitoring

Next Steps

Built with ❤️ by Rach Finance