Skip to main content

Overview

This guide covers proven integration patterns, architectural best practices, and common implementation approaches for Request Network. Whether you’re building a simple invoicing system or a complex multi-tenant platform, these patterns will help you implement robust, scalable payment infrastructure.

Common Integration Architectures

Server-Side Integration Pattern

Recommended for production applications requiring security and control.
  • Architecture
  • Implementation
  • Security
Server-Side Flow:
Frontend β†’ Backend API β†’ Request Network β†’ Blockchain
     ↓
Webhook Handler ← Request Network ← Payment Confirmation
     ↓
Business Logic β†’ Database β†’ Frontend Updates
Benefits:
  • Secure API key management
  • Centralized business logic
  • Reliable webhook handling
  • Scalable architecture

Client-Side Integration Pattern

Suitable for simple applications and rapid prototyping.
  • Architecture
  • Implementation
  • Limitations
Client-Side Flow:
Frontend App β†’ Request Network SDK β†’ Blockchain
     ↓
Payment Widget β†’ Wallet Connection β†’ Transaction
     ↓
Confirmation β†’ Frontend Updates β†’ Backend Sync
Benefits:
  • Faster development
  • Reduced backend complexity
  • Real-time user feedback
  • Lower infrastructure costs

E-commerce Integration Patterns

Shopify Integration

Connect Request Network with Shopify for crypto payment acceptance.
Integration Components:
  • Shopify App with payment gateway registration
  • Backend service for Request Network integration
  • Webhook handlers for payment confirmation
  • Admin dashboard for configuration
Flow:
  1. Customer selects crypto payment at checkout
  2. Shopify redirects to Request Network payment page
  3. Customer completes crypto payment
  4. Webhook confirms payment to Shopify
  5. Order status updated automatically
// Shopify payment gateway endpoint
app.post('/shopify/payment/create', async (req, res) => {
  const { order, return_url, cancel_url } = req.body;
  
  // Create Request Network payment request
  const paymentRequest = await requestNetwork.createRequest({
    requestInfo: {
      currency: 'USD',
      expectedAmount: order.total_price,
      payee: { type: 'ethereumAddress', value: merchantAddress }
    },
    contentData: {
      reason: `Shopify Order #${order.order_number}`,
      shopifyOrderId: order.id,
      returnUrl: return_url,
      cancelUrl: cancel_url
    }
  });
  
  // Redirect to payment page
  res.redirect(`/pay/${paymentRequest.requestId}`);
});

// Payment confirmation webhook
app.post('/webhook/payment-confirmed', async (req, res) => {
  const { requestId, paymentHash } = req.body;
  
  // Get order info from Request Network
  const request = await requestNetwork.getRequest(requestId);
  const shopifyOrderId = request.contentData.shopifyOrderId;
  
  // Update Shopify order status
  await shopifyAPI.orders.update(shopifyOrderId, {
    financial_status: 'paid',
    transactions: [{
      kind: 'sale',
      status: 'success',
      amount: request.expectedAmount,
      gateway: 'request-network'
    }]
  });
  
  res.status(200).send('OK');
});

WooCommerce Integration

Enable crypto payments in WordPress/WooCommerce stores.
WordPress Plugin Structure:
  • Payment gateway plugin registration
  • Admin settings page for configuration
  • Checkout integration hooks
  • Order status management
Key Features:
  • Seamless checkout experience
  • Automatic order fulfillment
  • Refund handling
  • Multi-currency support
<?php
// WooCommerce payment gateway class
class WC_Request_Network_Gateway extends WC_Payment_Gateway {
    
    public function __construct() {
        $this->id = 'request_network';
        $this->method_title = 'Request Network';
        $this->method_description = 'Accept crypto payments via Request Network';
        
        $this->init_form_fields();
        $this->init_settings();
        
        // Hook into WooCommerce
        add_action('woocommerce_update_options_payment_gateways_' . $this->id, 
                  array($this, 'process_admin_options'));
        add_action('woocommerce_api_request_network_webhook', 
                  array($this, 'handle_webhook'));
    }
    
    public function process_payment($order_id) {
        $order = wc_get_order($order_id);
        
        // Create Request Network payment request
        $response = wp_remote_post($this->api_endpoint . '/create-request', array(
            'body' => json_encode(array(
                'amount' => $order->get_total(),
                'currency' => $order->get_currency(),
                'order_id' => $order_id,
                'return_url' => $this->get_return_url($order)
            )),
            'headers' => array(
                'Content-Type' => 'application/json',
                'Authorization' => 'Bearer ' . $this->api_key
            )
        ));
        
        $payment_data = json_decode(wp_remote_retrieve_body($response), true);
        
        // Redirect to payment page
        return array(
            'result' => 'success',
            'redirect' => $payment_data['payment_url']
        );
    }
}

SaaS & Subscription Patterns

Multi-Tenant SaaS Architecture

Scale Request Network for multiple customers in a SaaS platform.
  • Tenant Isolation
  • Webhook Routing
  • Billing Integration
Isolation Strategy:
  • Separate API keys per tenant
  • Namespace separation for requests
  • Isolated webhook endpoints
  • Tenant-specific fee structures
// Tenant-aware request creation
async function createTenantRequest(tenantId, requestData) {
  const tenantConfig = await getTenantConfig(tenantId);
  
  const request = await requestNetwork.createRequest({
    ...requestData,
    contentData: {
      ...requestData.contentData,
      tenantId,
      tenantDomain: tenantConfig.domain
    },
    paymentNetwork: {
      id: 'erc20-fee-proxy-contract',
      parameters: {
        paymentAddress: tenantConfig.walletAddress,
        feeAddress: platformFeeAddress,
        feeAmount: tenantConfig.platformFeePercentage
      }
    }
  }, {
    apiKey: tenantConfig.requestNetworkApiKey
  });
  
  return request;
}

Enterprise Integration Patterns

ERP System Integration

Connect Request Network with enterprise resource planning systems.
SAP S/4HANA Integration:
  • Invoice creation from SAP sales orders
  • Payment status synchronization
  • Automatic accounting document creation
  • Multi-company and multi-currency support
// SAP integration service
class SAPRequestNetworkIntegration {
  async createInvoiceFromSalesOrder(salesOrderId) {
    // Fetch sales order from SAP
    const salesOrder = await this.sapAPI.getSalesOrder(salesOrderId);
    
    // Create Request Network payment request
    const paymentRequest = await requestNetwork.createRequest({
      requestInfo: {
        currency: salesOrder.currency,
        expectedAmount: salesOrder.totalAmount,
        payee: { type: 'ethereumAddress', value: companyWalletAddress }
      },
      contentData: {
        reason: `Invoice for Sales Order ${salesOrderId}`,
        sapSalesOrderId: salesOrderId,
        sapCustomerId: salesOrder.customerId,
        sapCompanyCode: salesOrder.companyCode
      }
    });
    
    // Update SAP with Request Network details
    await this.sapAPI.updateSalesOrder(salesOrderId, {
      paymentRequestId: paymentRequest.requestId,
      paymentStatus: 'pending'
    });
    
    return paymentRequest;
  }
}
NetSuite Integration Pattern:
  • SuiteScript for Request Network communication
  • Custom records for payment tracking
  • Automated journal entry creation
  • Revenue recognition automation
Dynamics 365 Integration:
  • Power Platform connectors
  • Custom API integration
  • Automated invoice processing
  • Financial reporting integration

Development Best Practices

Error Handling Strategies

class RequestNetworkClient {
  async createRequestWithRetry(requestData, maxRetries = 3) {
    let lastError;
    
    for (let attempt = 1; attempt <= maxRetries; attempt++) {
      try {
        return await requestNetwork.createRequest(requestData);
      } catch (error) {
        lastError = error;
        
        // Don't retry on permanent errors
        if (error.code === 'INVALID_REQUEST' || error.code === 'UNAUTHORIZED') {
          throw error;
        }
        
        // Exponential backoff
        const delay = Math.pow(2, attempt) * 1000;
        await new Promise(resolve => setTimeout(resolve, delay));
        
        console.log(`Request creation attempt ${attempt} failed, retrying...`);
      }
    }
    
    throw lastError;
  }
}

Performance Optimization

  • Caching Strategies
  • Batch Processing
  • Connection Pooling
Cache Request Data:
// Redis caching for request data
const redis = new Redis(process.env.REDIS_URL);

async function getCachedRequest(requestId) {
  const cacheKey = `request:${requestId}`;
  const cached = await redis.get(cacheKey);
  
  if (cached) {
    return JSON.parse(cached);
  }
  
  const request = await requestNetwork.getRequest(requestId);
  await redis.setex(cacheKey, 300, JSON.stringify(request)); // 5 min cache
  
  return request;
}

What’s Next?

⌘I