Skip to main content

Testing Your Integration

This guide covers testing strategies and common scenarios for Finternet integration.

Sandbox Testing

๐Ÿงช Testing Environment: All testing examples use the sandbox environment (api.fmm.finternetlab.io).

๐Ÿš€ Production API will be available once deployed.

Test vs Live Keysโ€‹

Finternet provides separate environments for testing and production:

EnvironmentAPI Key PrefixUse Case
Testsk_test_Development, testing, staging
Livesk_live_Production transactions

โš ๏ธ Important: Always use test keys during development. Live keys process real transactions with real money.

Test Scenariosโ€‹

Scenario 1: Successful Paymentโ€‹

Create a payment intent and confirm it normally:

# Create intent
curl https://api.fmm.finternetlab.io/v1/payment-intents \
-H "X-API-Key: sk_test_your_key" \
-X POST \
-d '{
"amount": "100.00",
"currency": "USDC",
"type": "DELIVERY_VS_PAYMENT",
"settlementMethod": "OFF_RAMP_MOCK",
"settlementDestination": "test_account"
}'

# Confirm payment
curl https://api.fmm.finternetlab.io/v1/payment-intents/intent_xxx/confirm \
-H "X-API-Key: sk_test_your_key" \
-X POST \
-d '{
"signature": "0x...",
"payerAddress": "0x..."
}'

Scenario 2: Failed Transactionโ€‹

Test error handling by providing an invalid signature:

curl https://api.fmm.finternetlab.io/v1/payment-intents/intent_xxx/confirm \
-H "X-API-Key: sk_test_your_key" \
-X POST \
-d '{
"signature": "0xinvalid",
"payerAddress": "0x742d35Cc6634C0532925a3b844Bc9e7595f42318"
}'

Expected Response:

{
"error": {
"code": "signature_verification_failed",
"message": "Invalid EIP-712 signature",
"type": "invalid_request_error"
}
}

Scenario 3: Invalid State Transitionโ€‹

Test state machine validation:

# Try to confirm an already confirmed payment
curl https://api.fmm.finternetlab.io/v1/payment-intents/intent_xxx/confirm \
-H "X-API-Key: sk_test_your_key" \
-X POST \
-d '{
"signature": "0x...",
"payerAddress": "0x..."
}'

Expected Response:

{
"error": {
"code": "invalid_state_transition",
"message": "Cannot transition from SUCCEEDED to PROCESSING",
"type": "invalid_request_error"
}
}

Test Dataโ€‹

Test Amountsโ€‹

Use small amounts for testing:

  • "10.00" - Small test payment
  • "100.00" - Standard test payment
  • "1000.00" - Large test payment

Test Currenciesโ€‹

Supported test currencies:

  • "USDC" - USD Coin (most common)
  • "USDT" - Tether USD
  • "DAI" - Dai Stablecoin

Test Settlement Destinationsโ€‹

Use test account identifiers:

  • "test_account_123"
  • "bank_test_456"
  • "mock_settlement_789"

Integration Testingโ€‹

Example: Node.js/TypeScriptโ€‹

// Test payment creation using direct API calls
async function testPayment() {
const response = await fetch('https://api.fmm.finternetlab.io/v1/payment-intents', {
method: 'POST',
headers: {
'X-API-Key': process.env.FINTERNET_TEST_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
amount: '10.00',
currency: 'USDC',
type: 'DELIVERY_VS_PAYMENT',
settlementMethod: 'OFF_RAMP_MOCK',
settlementDestination: 'test_account',
}),
});

const intent = await response.json();
console.log('Created intent:', intent.id);
console.log('Status:', intent.status);

// Verify status
if (intent.status !== 'INITIATED') {
throw new Error('Expected INITIATED status');
}

return intent;
}

Example: Pythonโ€‹

import os
import requests

API_KEY = os.environ.get('FINTERNET_TEST_API_KEY')
BASE_URL = 'https://api.fmm.finternetlab.io/v1'

def test_payment():
# Create payment intent
response = requests.post(
f'{BASE_URL}/payment-intents',
headers={
'X-API-Key': API_KEY,
'Content-Type': 'application/json',
},
json={
'amount': '10.00',
'currency': 'USDC',
'type': 'DELIVERY_VS_PAYMENT',
'settlementMethod': 'OFF_RAMP_MOCK',
'settlementDestination': 'test_account',
}
)

intent = response.json()
assert intent['status'] == 'INITIATED'
return intent

Mock Modeโ€‹

In test mode, Finternet uses mock implementations for:

  • Blockchain transactions - Simulated confirmations
  • Settlement processing - Mock bank transfers
  • Delivery proofs - Test delivery verification

This allows you to test the complete flow without real blockchain transactions.

Test Checklistโ€‹

Before going live, test:

  • Payment intent creation
  • Payment confirmation
  • Status polling
  • Error handling
  • Invalid signatures
  • State transitions
  • Settlement completion
  • Webhook delivery (if using)
  • Rate limiting
  • Authentication errors

Rate Limits (Test Mode)โ€‹

Test mode has relaxed rate limits for development:

  • 100 requests per minute per API key
  • 1000 requests per hour per API key

These limits are higher than production to support rapid testing.

Next Stepsโ€‹

  • ๐Ÿ“– Read Error Handling for all error scenarios
  • ๐Ÿ”„ Learn about Webhooks for event notifications
  • ๐Ÿš€ Review Going Live checklist before production