sablepay_flutter 1.0.0 copy "sablepay_flutter: ^1.0.0" to clipboard
sablepay_flutter: ^1.0.0 copied to clipboard

SablePay Flutter SDK for crypto payment integration with QR codes, polling, payment flow management, and pre-built UI helpers.

sablepay-flutter-sdk #

Official SablePay Flutter SDK for crypto payment integration with QR codes, automatic polling, and end-to-end payment flow management.

Pub package name: sablepay_flutter. Repository/project name: sablepay-flutter-sdk.

Features #

  • Full Dart typing for requests and responses
  • Singleton SDK initialization (SablePay.initialize)
  • Payment create / status / list APIs
  • Automatic retry with exponential backoff for retryable errors
  • Polling utility for payment status
  • Unified PaymentFlow lifecycle manager
  • QR support with reusable Flutter widget
  • Example app mirroring the React Native SDK process

Installation #

flutter pub add sablepay_flutter

Or in pubspec.yaml:

dependencies:
  sablepay_flutter: ^1.0.0

Quick Start #

1. Initialize the SDK #

import 'package:sablepay_flutter/sablepay_flutter.dart';

void init() {
  SablePay.initialize(
    const SablePayConfig(
      apiKey: 'sable_sk_sand_...',
      merchantId: '00000000-0000-0000-0000-000000000000',
      enableLogging: true,
    ),
  );
}

2. Create a Payment #

final sdk = SablePay.getInstance();
final response = await sdk.createPayment(
  const CreatePaymentRequest(amount: 10.50),
);

final paymentLink = response.paymentLink; // use for QR display

3. Render QR in Flutter #

if (response.paymentLink != null) {
  QrCodeWidget(data: response.paymentLink!);
}
final flow = SablePay.createPaymentFlow();

await flow.startPayment(
  10.50,
  listener: PaymentFlowListener(
    onPaymentCreated: (response, qrData) {
      // Display qrData in QrCodeWidget
    },
    onStatusUpdate: (status) {
      // Update UI
    },
    onPaymentCompleted: (status) {
      // Success
    },
    onPaymentFailed: (error) {
      // Error handling
    },
  ),
);

API Reference #

SablePay #

SablePay.initialize(SablePayConfig(...));
SablePay.getInstance();
SablePay.isInitialized();
SablePay.createPaymentFlow();
SablePay.release();

Instance methods:

sdk.createPayment(CreatePaymentRequest(...));
sdk.getPaymentStatus('payment-id');
sdk.listPayments(limit: 20, offset: 0);
sdk.getEnvironment(); // sandbox | production | unknown
sdk.isConfigured();

Status Helpers #

isPending(status);
isCompleted(status);
isFailed(status);
isExpired(status);
isTerminal(status);

Error Handling #

try {
  await sdk.createPayment(const CreatePaymentRequest(amount: 10.50));
} catch (error) {
  if (error is ApiException) {
    print(error.statusCode);
    print(error.message);
    print(error.requestId);
    print(error.isRetryable);
  }
}

Example App #

Path: example-app/

Contains:

  • Coffee Shop POS payment flow
  • Payment status lookup and polling
  • Environment-based SDK initialization

Run it:

cd example-app
cp .env.example .env
flutter pub get
flutter run

Environment URLs #

  • Sandbox API: https://sandbox-api.sablepay.io/api/v1/
  • Production API: https://api.sablepay.io/api/v1/
  • Sandbox web: https://sandbox.sablepay.io/
  • Production web: https://www.sablepay.io/

Publish to pub.dev #

1. Verify metadata #

Ensure in pubspec.yaml:

  • name, description, version
  • homepage, repository, issue_tracker
  • valid SDK constraints

2. Validate package #

flutter pub get
dart format --set-exit-if-changed .
dart analyze
dart pub publish --dry-run

3. Authenticate and publish #

dart pub login
dart pub publish

4. Tag release in git #

git tag v1.0.0
git push origin v1.0.0

License #

MIT

0
likes
140
points
88
downloads

Documentation

Documentation
API reference

Publisher

verified publishersablepay.io

Weekly Downloads

SablePay Flutter SDK for crypto payment integration with QR codes, polling, payment flow management, and pre-built UI helpers.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, http, qr_flutter

More

Packages that depend on sablepay_flutter