PlexySDK DOCS

Flutter SDK

Integrate Plexy with Flutter mobile applications

Flutter SDK

The official Plexy SDK for Flutter (iOS and Android).

Installation

Add to your pubspec.yaml:

dependencies:
  plexy_flutter: ^1.0.0

Then run:

flutter pub get

Quick Start

import 'package:plexy_flutter/plexy_flutter.dart';

final plexy = Plexy(
  apiKey: const String.fromEnvironment('PLEXY_API_KEY'),
);

// Create a payment
final payment = await plexy.payments.create(
  amount: 10000,
  currency: 'KZT',
  description: 'Order #12345',
);

Configuration

final plexy = Plexy(
  apiKey: apiKey,
  // Optional configuration
  environment: PlexyEnvironment.test, // or .live
  timeout: const Duration(seconds: 30),
);

Payments

Create and Open Payment

// Create payment
final payment = await plexy.payments.create(
  amount: 10000,
  currency: 'KZT',
  description: 'Order #12345',
  metadata: {
    'orderId': '12345',
  },
);

// Open checkout in WebView
final result = await plexy.checkout.open(
  context: context,
  payment: payment,
);

if (result.status == PaymentStatus.completed) {
  // Payment successful
} else if (result.status == PaymentStatus.cancelled) {
  // User cancelled
}

Using the Checkout Widget

PlexyCheckoutButton(
  plexy: plexy,
  amount: 10000,
  currency: 'KZT',
  description: 'Order #12345',
  onSuccess: (payment) {
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(content: Text('Payment successful!')),
    );
  },
  onError: (error) {
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(content: Text('Payment failed: $error')),
    );
  },
  child: const Text('Pay Now'),
)

Native Payment Methods

Apple Pay (iOS)

if (await plexy.applePay.isAvailable()) {
  final result = await plexy.applePay.pay(
    amount: 10000,
    currency: 'KZT',
    merchantName: 'Your Store',
  );
}

Google Pay (Android)

if (await plexy.googlePay.isAvailable()) {
  final result = await plexy.googlePay.pay(
    amount: 10000,
    currency: 'KZT',
  );
}

Error Handling

try {
  final payment = await plexy.payments.create(...);
} on PlexyApiException catch (e) {
  print('API Error: ${e.message}');
  print('Error Code: ${e.code}');
} on PlexyException catch (e) {
  print('SDK Error: $e');
}

Platform Configuration

iOS

Add to ios/Runner/Info.plist for Apple Pay:

<key>com.apple.developer.in-app-payments</key>
<array>
  <string>merchant.com.yourcompany.app</string>
</array>

Android

Add to android/app/build.gradle:

dependencies {
    implementation 'com.google.android.gms:play-services-wallet:19.1.0'
}

Осы бетте