Testing Your Integration

Learn how to test your ZEUSXPAY integration safely

Testing Your Integration

ZEUSXPAY provides a comprehensive testing environment so you can develop and test your integration without using real money or cryptocurrency.

Test Mode vs Live Mode

ZEUSXPAY has two separate environments:

Test Mode (Sandbox)

  • Use for development and testing
  • No real money or crypto involved
  • Payments auto-complete for testing
  • API keys start with sk_test_ or pk_test_
  • API endpoint: https://sandbox-api.zeusxpay.io

Live Mode (Production)

  • Use for real transactions
  • Real money and cryptocurrency
  • API keys start with sk_live_ or pk_live_
  • API endpoint: https://api.zeusxpay.io

Getting Test API Keys

  1. Log in to your Dashboard
  2. Toggle to Test Mode (top right)
  3. Go to SettingsAPI Keys
  4. Copy your test keys
# Test keys
ZEUSXPAY_PUBLIC_KEY=pk_test_abc123...
ZEUSXPAY_SECRET_KEY=sk_test_xyz789...

Creating Test Payments

Test payments work exactly like live payments:

const zeusxpay = new ZeusXPay('sk_test_YOUR_TEST_KEY');

const order = await zeusxpay.orders.create({
	amount: 100.0,
	currency: 'USD',
	crypto_currency: 'BTC',
	description: 'Test payment'
});

console.log('Test payment URL:', order.payment_url);

Test Payment Behavior

Automatic Completion

In test mode, payments automatically complete after 1 minute:

  1. Create test order
  2. Wait 60 seconds
  3. Order status changes to completed
  4. Webhook is sent (if configured)

Manual Completion

Force immediate completion via Dashboard:

  1. Go to Payments in test mode
  2. Find your test order
  3. Click Complete Payment

Test Cryptocurrencies

Use these test addresses for manual testing:

BTC (Bitcoin):
bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh

ETH (Ethereum):
0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb

USDT (ERC-20):
0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb

Testing Different Scenarios

Successful Payment

// Create order
const order = await zeusxpay.orders.create({
	amount: 100.0,
	currency: 'USD',
	crypto_currency: 'BTC'
});

// Wait 60 seconds or complete manually
// Order will become 'completed'

Failed Payment

// Create order with very short expiration
const order = await zeusxpay.orders.create({
	amount: 100.0,
	currency: 'USD',
	crypto_currency: 'BTC',
	expires_in: 60 // 1 minute
});

// Wait for expiration
// Order will become 'expired'

Partial Payment

// In test mode, you can simulate partial payments
// via the Dashboard "Simulate Payment" tool

Underpayment

// Test handling of underpayments
// Use Dashboard to simulate sending less crypto than required

Testing Webhooks

Local Development

Use ngrok to receive webhooks locally:

# Install ngrok
npm install -g ngrok

# Start your local server
npm run dev

# Expose your server
ngrok http 3000

# Update webhook URL in Dashboard
https://abc123.ngrok.io/webhooks/zeusxpay

Webhook Logs

View webhook delivery logs in Dashboard:

  1. Go to SettingsWebhooks
  2. Select your webhook endpoint
  3. View Recent Deliveries
  4. See request/response details

Send Test Webhooks

Trigger test webhooks manually:

  1. Go to SettingsWebhooks
  2. Click Send Test Event
  3. Select event type
  4. Click Send

Verify Signatures

Test signature verification:

const crypto = require('crypto');

function testWebhookSignature() {
	const payload = JSON.stringify({
		id: 'evt_test_123',
		type: 'order.completed',
		data: { id: 'ord_test_123' }
	});

	const signature = crypto
		.createHmac('sha256', process.env.WEBHOOK_SECRET)
		.update(payload)
		.digest('hex');

	// Test your verification function
	const isValid = verifyWebhook(payload, signature, process.env.WEBHOOK_SECRET);
	console.log('Signature valid:', isValid);
}

Testing API Endpoints

Use the API Playground

Test API calls interactively:

  1. Visit API Playground
  2. Enter your test API key
  3. Select an endpoint
  4. Customize parameters
  5. Click “Try it”

cURL Commands

Test with cURL:

# Create order
curl -X POST https://sandbox-api.zeusxpay.io/v1/orders 
  -H "Authorization: Bearer sk_test_YOUR_KEY" 
  -H "Content-Type: application/json" 
  -d '{
    "amount": 100.00,
    "currency": "USD",
    "crypto_currency": "BTC"
  }'

# Get order
curl https://sandbox-api.zeusxpay.io/v1/orders/ord_test_123 
  -H "Authorization: Bearer sk_test_YOUR_KEY"

# List orders
curl https://sandbox-api.zeusxpay.io/v1/orders 
  -H "Authorization: Bearer sk_test_YOUR_KEY"

Test Data

Test Cards (for fiat on-ramps)

Success: 4242 4242 4242 4242
Decline: 4000 0000 0000 0002
Expired: 4000 0000 0000 0069

Test Email Addresses

success@zeusxpay.io - Always succeeds
fail@zeusxpay.io - Always fails
slow@zeusxpay.io - Takes 2 minutes to complete

Testing Error Handling

Test Different Error Scenarios

// Invalid API key
try {
  const zeusxpay = new ZeusXPay('sk_invalid_key');
  await zeusxpay.orders.create({ ... });
} catch (error) {
  console.log('Auth error:', error.message);
}

// Invalid amount
try {
  await zeusxpay.orders.create({
    amount: -10, // Invalid
    currency: 'USD'
  });
} catch (error) {
  console.log('Validation error:', error.message);
}

// Network error
try {
  // Simulate network timeout
  await zeusxpay.orders.create(
    { ... },
    { timeout: 1 } // 1ms timeout
  );
} catch (error) {
  console.log('Network error:', error.message);
}

Handle Rate Limits

// Test rate limiting behavior
async function testRateLimit() {
	const promises = [];

	// Send 200 requests quickly
	for (let i = 0; i < 200; i++) {
		promises.push(zeusxpay.orders.list().catch((e) => e));
	}

	const results = await Promise.all(promises);
	const rateLimited = results.filter((r) => r.status === 429);

	console.log(`Rate limited: ${rateLimited.length}/200`);
}

Automated Testing

Unit Tests

// Jest example
describe('ZEUSXPAY Integration', () => {
  let zeusxpay;

  beforeAll(() => {
    zeusxpay = new ZeusXPay(process.env.ZEUSXPAY_TEST_KEY);
  });

  test('creates order successfully', async () => {
    const order = await zeusxpay.orders.create({
      amount: 100.00,
      currency: 'USD',
      crypto_currency: 'BTC'
    });

    expect(order.id).toBeTruthy();
    expect(order.status).toBe('pending');
    expect(order.amount).toBe(100.00);
  });

  test('retrieves order by ID', async () => {
    const created = await zeusxpay.orders.create({ ... });
    const retrieved = await zeusxpay.orders.retrieve(created.id);

    expect(retrieved.id).toBe(created.id);
  });

  test('handles invalid API key', async () => {
    const invalid = new ZeusXPay('sk_invalid');

    await expect(
      invalid.orders.list()
    ).rejects.toThrow('Invalid API key');
  });
});

Integration Tests

// Test full payment flow
describe('Payment Flow', () => {
	test('complete payment flow', async () => {
		// 1. Create order
		const order = await createOrder();
		expect(order.status).toBe('pending');

		// 2. Complete payment (in test mode)
		await completeTestPayment(order.id);

		// 3. Verify webhook received
		const webhook = await waitForWebhook(order.id);
		expect(webhook.type).toBe('order.completed');

		// 4. Verify order status updated
		const updated = await zeusxpay.orders.retrieve(order.id);
		expect(updated.status).toBe('completed');
	});
});

Pre-Production Checklist

Before going live, verify:

  • All test scenarios pass
  • Webhooks are received and processed correctly
  • Error handling works properly
  • Refunds can be issued
  • Payment links work
  • Checkout UI displays correctly
  • Mobile experience is good
  • Email notifications are sent
  • Database updates happen correctly
  • Logging is in place

Going Live

When ready to go live:

  1. Get live API keys from Dashboard
  2. Update environment variables:
    ZEUSXPAY_SECRET_KEY=sk_live_YOUR_LIVE_KEY
    ZEUSXPAY_PUBLIC_KEY=pk_live_YOUR_LIVE_KEY
  3. Update API endpoint to https://api.zeusxpay.io
  4. Register live webhook URL
  5. Enable live mode in your application
  6. Monitor first transactions closely

Testing Tools

Common Testing Issues

Webhooks Not Received

  • Check ngrok is running
  • Verify webhook URL is correct
  • Check server logs for errors
  • Ensure endpoint returns 200

Payments Don’t Complete

  • Wait full 60 seconds in test mode
  • Or use “Complete Payment” in Dashboard
  • Check order hasn’t expired

Signature Verification Fails

  • Use raw request body
  • Check webhook secret is correct
  • Verify header name is exact

Need Help?