Skip to content

Payment Basics

ShipFlutter provides a flexible payment system that adapts to different platforms:

  1. Mobile: RevenueCat for App Store and Google Play
  2. Web: LemonSqueezy for web payments

Structure

The payment system is organized into client and server components:

  • Directoryapp/
    • Directorylib/core/account/payments/
      • Directorymobile/ // RevenueCat implementation
      • Directoryweb/ // LemonSqueezy implementation
      • Directorymodels/ // Shared payment models
      • Directoryui/ // Payment UI components
      • payments_service.dart // Platform-agnostic interface
    • Directoryweb/payment/
      • lemon_squeezy.js // LemonSqueezy SDK interop
  • Directoryfunctions/src/payment/
    • revenue_cat.ts // Mobile webhooks
    • lemon_squeezy.ts // Web webhooks
    • payments_schema.ts // Shared types

Basic Usage

// Get paywall with available packages
final paywall = await paymentsService.instance.getPaywall();
// Access packages
final packages = paywall.packages;

Payment Models

The system uses these core models:

// Package represents a purchasable item
class PaymentPackage {
final String id;
final String productId;
final String title;
final String description;
final String price;
final String currency;
final int? subscriptionDuration;
final int? trialDuration;
}
// Paywall groups packages with presentation
class PaymentPaywall {
final String id;
final String title;
final List<PaymentPackage> packages;
}

Paywall and Trial UI

ShipFlutter includes responsive and ready-to-use payment UI components that are compliant with Apple App Store and Google Play store. The UI automatically adapts to the platform (mobile/web) and handles all payment flows.

// Show paywall
context.go('/paywall');
// Show trial
context.go('/trial');
// Or use the widget directly
PaywallView(
onClose: (isSuccessful) {
// Handle result
},
);

Webhooks Integration

The payment system uses Firebase Functions to handle webhooks from both providers:

  1. RevenueCat - /api/v1/payment/event/rc

    • Handles subscription events
    • Updates entitlements
    • Manages trial periods
  2. LemonSqueezy - /api/v1/payment/event/ls

    • Processes web payments
    • Manages subscription lifecycle
    • Syncs product data

Next Steps

  1. Set up payment providers:

  2. Configure Entitlements to manage user access

  3. Customize the payment UI to match your app’s design