> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orsunpay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sandbox vs Production

> Understand the key differences between sandbox and production environments

# Sandbox vs Production

Orsunpay provides separate environments for testing and live transactions. Understanding the differences between these environments is crucial for proper integration and testing.

## Environment Overview

| Aspect                | Sandbox                 | Production            |
| --------------------- | ----------------------- | --------------------- |
| **Purpose**           | Testing and development | Live transactions     |
| **API Keys**          | `sk_test_...`           | `sk_live_...`         |
| **Money Movement**    | No real money           | Real money processing |
| **Payment Providers** | Test/Mock providers     | Live providers        |
| **Rate Limits**       | 1000 requests/minute    | 5000 requests/minute  |
| **Data Retention**    | 30 days                 | Permanent             |

## Base URLs

### API Endpoints

```bash theme={null}
# Sandbox
https://sandbox-api.orsunpay.com/v1

# Production  
https://api.orsunpay.com/v1
```

### Checkout URLs

```bash theme={null}
# Sandbox
https://sandbox-checkout.orsunpay.com

# Production
https://checkout.orsunpay.com
```

### BackOffice

```bash theme={null}
# Sandbox
https://office-sandbox.orsunpay.com

# Production
https://office.orsunpay.com
```

## API Key Differences

### Sandbox Keys

* **Format**: `sk_test_abc123...`
* **Access**: Sandbox environment only
* **Security**: Less stringent for testing
* **Regeneration**: Can be regenerated freely

### Production Keys

* **Format**: `sk_live_abc123...`
* **Access**: Production environment only
* **Security**: High security requirements
* **Regeneration**: Requires verification process

<Warning>
  Never use production API keys in development environments or commit them to version control.
</Warning>

## Transaction Behavior

### Sandbox Transactions

<CodeGroup>
  ```json Test Card Success theme={null}
  {
    "amount": 5000,
    "currency": "USD",
    "paymentMethod": "card",
    "paymentMethodInput": {
      "cardNumber": "4242424242424242",
      "expiryMonth": "12",
      "expiryYear": "2025",
      "cvv": "123"
    }
  }
  // Result: SUCCESS
  ```

  ```json Test Card Decline theme={null}
  {
    "amount": 5000,
    "currency": "USD", 
    "paymentMethod": "card",
    "paymentMethodInput": {
      "cardNumber": "4000000000000002",
      "expiryMonth": "12",
      "expiryYear": "2025",
      "cvv": "123"
    }
  }
  // Result: DECLINED
  ```

  ```json Test Card Insufficient Funds theme={null}
  {
    "amount": 5000,
    "currency": "USD",
    "paymentMethod": "card", 
    "paymentMethodInput": {
      "cardNumber": "4000000000009995",
      "expiryMonth": "12",
      "expiryYear": "2025",
      "cvv": "123"
    }
  }
  // Result: DECLINED (insufficient_funds)
  ```
</CodeGroup>

### Test Cards

Use these test card numbers in sandbox:

| Card Number        | Brand      | Result           | Error Code           |
| ------------------ | ---------- | ---------------- | -------------------- |
| `4242424242424242` | Visa       | Success          | -                    |
| `5555555555554444` | Mastercard | Success          | -                    |
| `4000000000000002` | Visa       | Declined         | `card_declined`      |
| `4000000000009995` | Visa       | Declined         | `insufficient_funds` |
| `4000000000000069` | Visa       | Expired          | `expired_card`       |
| `4000000000000127` | Visa       | Incorrect CVC    | `incorrect_cvc`      |
| `4000000000000119` | Visa       | Processing Error | `processing_error`   |

<Note>
  You can use any future expiry date and any 3-digit CVC for test cards.
</Note>

### Alternative Payment Methods Testing

#### PayPal Sandbox

```json theme={null}
{
  "paymentMethod": "paypal",
  "paymentMethodInput": {
    "email": "sb-test@personal.example.com"
  }
}
```

#### Bank Transfer Testing

```json theme={null}
{
  "paymentMethod": "bank_transfer",
  "paymentMethodInput": {
    "iban": "DE89370400440532013000",
    "accountHolderName": "Test User"
  }
}
```

## Webhook Testing

### Sandbox Webhooks

Sandbox webhooks are triggered immediately for testing purposes:

```bash theme={null}
# Test webhook endpoint
curl -X POST https://your-test-server.com/webhooks/orsunpay \
  -H "Content-Type: application/json" \
  -H "X-Orsunpay-Signature: sha256=test_signature" \
  -d '{
    "event": "transaction.succeeded",
    "data": {
      "id": "tr_test_123",
      "status": "SUCCESS",
      "amount": 5000
    }
  }'
```

### Webhook Development Tools

Use tools like ngrok for local webhook testing:

```bash theme={null}
# Install ngrok
npm install -g ngrok

# Expose local server
ngrok http 3000

# Use the HTTPS URL for webhook endpoint
# https://abc123.ngrok.io/webhooks/orsunpay
```

## Rate Limits

### Sandbox Limits

* **General API**: 1,000 requests per minute
* **Burst Limit**: 100 requests per second
* **Webhook Retries**: 5 attempts over 24 hours

### Production Limits

* **General API**: 5,000 requests per minute
* **Burst Limit**: 500 requests per second
* **Webhook Retries**: 10 attempts over 48 hours

<Tip>
  Contact support if you need higher rate limits for production use.
</Tip>

## Data Differences

### Sandbox Data

* **Retention**: 30 days rolling
* **Reset**: Data can be cleared upon request
* **Privacy**: Lower privacy requirements
* **Compliance**: Testing compliance flows

### Production Data

* **Retention**: Permanent (per regulatory requirements)
* **Backup**: Multiple geographic backups
* **Privacy**: Full PCI DSS and GDPR compliance
* **Compliance**: Live compliance monitoring

## Feature Availability

### Feature Parity

Most features are available in both environments:

✅ **Available in Both**

* Transaction creation and processing
* Webhook notifications
* Customer management
* Payment method routing
* Error handling and retries

⚠️ **Sandbox Limitations**

* Limited payment provider sandbox availability
* Simplified 3DS flows
* Mock risk scoring
* Test-only payment methods

🔴 **Production Only**

* Real money processing
* Full compliance monitoring
* Advanced fraud detection
* Priority support channels

## Testing Strategies

### Unit Testing

Test your integration logic with mocked responses:

```javascript theme={null}
// Mock successful transaction response
const mockTransaction = {
  id: 'tr_test_123',
  status: 'SUCCESS',
  amount: 5000,
  currency: 'USD'
};

// Test your business logic
function handleTransactionSuccess(transaction) {
  expect(transaction.status).toBe('SUCCESS');
  // Your success logic here
}
```

### Integration Testing

Use sandbox environment for end-to-end testing:

```javascript theme={null}
describe('Payment Integration', () => {
  it('should create transaction successfully', async () => {
    const response = await orsunpay.transactions.create({
      amount: 5000,
      currency: 'USD',
      // ... other fields
    });
    
    expect(response.status).toBe('CREATED');
    expect(response.amount).toBe(5000);
  });
});
```

### Load Testing

Test your integration under load in sandbox:

```bash theme={null}
# Using Apache Bench
ab -n 1000 -c 10 -H "Authorization: Bearer sk_test_your_key" \
   -H "Content-Type: application/json" \
   -p transaction.json \
   https://sandbox-api.orsunpay.com/v1/transactions
```

## Migration Checklist

Before moving to production:

### Code Review

* [ ] Remove all test API keys
* [ ] Update base URLs to production
* [ ] Verify webhook endpoint security
* [ ] Test error handling thoroughly

### Configuration

* [ ] Set production API keys in environment variables
* [ ] Update webhook URLs to production endpoints
* [ ] Configure proper logging and monitoring
* [ ] Set up alerting for failures

### Testing

* [ ] Complete end-to-end testing in sandbox
* [ ] Test webhook signature verification
* [ ] Verify error scenarios handle gracefully
* [ ] Load test your webhook endpoints

### Security

* [ ] Audit API key storage and rotation
* [ ] Verify HTTPS enforcement
* [ ] Check webhook signature validation
* [ ] Review access logs and monitoring

## Monitoring and Debugging

### Sandbox Tools

* **Transaction logs**: Detailed debugging information
* **Webhook inspector**: Real-time webhook monitoring
* **API explorer**: Interactive API testing
* **Event timeline**: Step-by-step transaction flow

### Production Monitoring

* **Dashboard metrics**: Real-time performance monitoring
* **Alert notifications**: Automated failure detection
* **Audit logs**: Comprehensive activity tracking
* **Health checks**: Proactive system monitoring

## Best Practices

### Development Workflow

1. **Develop** against sandbox environment
2. **Test** thoroughly with various scenarios
3. **Deploy** to staging with production-like data
4. **Migrate** to production with proper configuration

### Environment Separation

```javascript theme={null}
// Good: Environment-based configuration
const config = {
  apiKey: process.env.NODE_ENV === 'production' 
    ? process.env.ORSUNPAY_LIVE_KEY 
    : process.env.ORSUNPAY_TEST_KEY,
  baseURL: process.env.NODE_ENV === 'production'
    ? 'https://api.orsunpay.com/v1'
    : 'https://sandbox-api.orsunpay.com/v1'
};
```

### Error Handling

```javascript theme={null}
// Handle environment-specific behavior
try {
  const transaction = await createTransaction(data);
} catch (error) {
  if (process.env.NODE_ENV === 'production') {
    // Log securely, alert monitoring
    logger.error('Transaction failed', { 
      transactionId: data.orderId,
      error: error.code 
    });
  } else {
    // More verbose logging for debugging
    console.error('Transaction failed:', error);
  }
}
```

## Support and Resources

### Sandbox Support

* **Documentation**: This comprehensive guide
* **Community**: Developer Discord channel
* **Email**: [sandbox-support@orsunpay.com](mailto:sandbox-support@orsunpay.com)

### Production Support

* **Dedicated support**: Priority response times
* **Phone support**: 24/7 for critical issues
* **Email**: [support@orsunpay.com](mailto:support@orsunpay.com)
* **Status page**: [https://status.orsunpay.com](https://status.orsunpay.com)

<Note>
  Production support includes proactive monitoring and faster response times for business-critical issues.
</Note>
