Sample Applications

Explore real-world examples of SubLoop integrations across different platforms.

Web Applications

L

Laravel SaaS App

Complete subscription management

A full-featured Laravel application with Stripe integration and SubLoop analytics.

Features: User registration, subscription plans, payment tracking
Stack: Laravel, Stripe, SubLoop PHP SDK
View on GitHub
N

Next.js E-commerce

Modern e-commerce with analytics

Next.js e-commerce platform with real-time revenue tracking and analytics dashboard.

Features: Product catalog, checkout, revenue analytics
Stack: Next.js, Stripe, SubLoop JavaScript SDK
View on GitHub

React Dashboard

Analytics dashboard with hooks

React application showcasing SubLoop's React hooks and pre-built components.

Features: Real-time analytics, MRR tracking, payment insights
Stack: React, SubLoop React SDK
View on GitHub
W

WordPress Plugin

WooCommerce integration

WordPress plugin that integrates SubLoop with WooCommerce for subscription analytics.

Features: WooCommerce hooks, subscription tracking
Stack: WordPress, WooCommerce, SubLoop PHP SDK
View on GitHub

Mobile Applications

FL

Flutter Subscription App

Cross-platform mobile app

Flutter mobile app with in-app purchases and subscription analytics.

Features: In-app purchases, subscription management, analytics
Stack: Flutter, App Store/Play Store, SubLoop Flutter SDK
View on GitHub
RN

React Native App

Native mobile experience

React Native app demonstrating payment tracking and analytics integration.

Features: Payment processing, real-time analytics
Stack: React Native, SubLoop JavaScript SDK
View on GitHub

Code Snippets

Webhook Integration

Handle payment webhooks from various providers:

// Stripe webhook handler
Route::post('/webhooks/stripe', function (Request $request) {
    $payload = $request->getContent();
    $sig_header = $request->header('Stripe-Signature');
    $endpoint_secret = config('services.stripe.webhook_secret');

    try {
        $event = \Stripe\Webhook::constructEvent($payload, $sig_header, $endpoint_secret);
    } catch(\Exception $e) {
        return response('Webhook signature verification failed.', 400);
    }

    if ($event->type === 'payment_intent.succeeded') {
        $paymentIntent = $event->data->object;
        
        // Track with SubLoop
        $subloop = new SubLoop(config('services.subloop.api_key'));
        $subloop->payments->createSuccessful(
            customerId: $paymentIntent->customer,
            amount: $paymentIntent->amount_received / 100,
            currency: strtoupper($paymentIntent->currency),
            subscriptionId: $paymentIntent->metadata->subscription_id ?? null
        );
    }

    return response('Success', 200);
});

Analytics Dashboard Components

Ready-to-use dashboard components:

// React Analytics Dashboard
import { SubLoopProvider, AnalyticsDashboard } from 'subloop-react';

function App() {
    return (
        
            

Revenue Analytics

); }

Background Job Processing

Process payments in background jobs:

// Laravel Job for processing payments
class ProcessPaymentAnalytics implements ShouldQueue
{
    public function __construct(
        private string $customerId,
        private float $amount,
        private string $currency,
        private ?string $subscriptionId = null
    ) {}

    public function handle()
    {
        $subloop = new SubLoop(config('services.subloop.api_key'));
        
        try {
            $subloop->payments->createSuccessful(
                customerId: $this->customerId,
                amount: $this->amount,
                currency: $this->currency,
                subscriptionId: $this->subscriptionId
            );
        } catch (Exception $e) {
            Log::error('SubLoop payment tracking failed', [
                'customer_id' => $this->customerId,
                'amount' => $this->amount,
                'error' => $e->getMessage()
            ]);
            
            // Retry the job
            $this->fail($e);
        }
    }
}

Testing Examples

Unit Tests

// PHPUnit test example
class SubLoopIntegrationTest extends TestCase
{
    public function test_successful_payment_tracking()
    {
        $subloop = new SubLoop('sk_test_key');
        
        $payment = $subloop->payments->createSuccessful(
            customerId: 'test_customer',
            amount: 29.99,
            currency: 'USD',
            subscriptionId: 'test_subscription'
        );
        
        $this->assertArrayHasKey('id', $payment);
        $this->assertEquals('succeeded', $payment['status']);
        $this->assertEquals(29.99, $payment['amount']);
    }
}

Integration Tests

// Jest test example
describe('SubLoop Integration', () => {
    test('should track payment successfully', async () => {
        const subloop = new SubLoop('sk_test_key');
        
        const payment = await subloop.payments.createSuccessful(
            'test_customer',
            29.99,
            'USD',
            'test_subscription'
        );
        
        expect(payment.id).toBeDefined();
        expect(payment.status).toBe('succeeded');
        expect(payment.amount).toBe(29.99);
    });
});

💡 Pro Tips

  • • Always handle webhook signature verification for security
  • • Use background jobs for payment processing to avoid blocking requests
  • • Implement proper error handling and logging
  • • Test with sandbox/test API keys before going live
  • • Monitor your webhook endpoints for failures

Get Started

Ready to implement SubLoop in your application?