Flutter SDK (faststar_pay)
The official Flutter SDK opens the FastStar hosted checkout in a full-screen WebView inside your app and returns the payment result through callbacks — no WebView plumbing required.
Installation
dependencies:
faststar_pay: ^1.0.0
The package depends on webview_flutter ^4.0.0:
- Android:
minSdkVersion 19(21+ recommended) - iOS: iOS 12.0+, no extra configuration
Opening the checkout
import 'package:faststar_pay/faststar_pay.dart';
await FastStarCheckout.open(
context,
url: checkoutUrl, // Checkout Session url created by your server, or a payment link
onSuccess: (data) {
// Payment succeeded (fulfill orders from the server-side webhook)
debugPrint('paid payment_intent_id=${data['payment_intent_id']}');
},
onCancel: () {
debugPrint('buyer canceled');
},
onError: (data) {
debugPrint('payment failed: ${data['message']}');
},
); open() pushes a full-screen checkout page that includes:
- an AppBar close button (triggers
onCancel) - a page-load progress bar
- system back gesture mapped to
onCancel
Return value instead of callbacks
open() also returns a Future<FastStarCheckoutResult> you can
simply await:
final result = await FastStarCheckout.open(context, url: payUrl);
switch (result.event) {
case FastStarCheckoutEvent.success:
print('success: ${result.data}');
case FastStarCheckoutEvent.cancel:
print('canceled');
case FastStarCheckoutEvent.error:
print('failed: ${result.data}');
} How results come back: FastStarBridge + URL fallback
The SDK receives the checkout result over two channels. Either one completes the flow, and your callback is guaranteed to fire only once:
- JS bridge (primary): the SDK injects a JavaScript channel named
FastStarBridge. The hosted checkout page calls
The channel accepts strings only, so the payload is JSON-stringified; unlike the iframe message format, nowindow.FastStarBridge.postMessage(JSON.stringify({ event: 'checkout.success', // checkout.success | checkout.cancel | checkout.error data: { payment_intent_id: 'pi_xxx' } }));sourcefield is needed because the channel itself is isolated. The shorthand event namessuccess/cancel/errorare also accepted. - URL interception (fallback): when the checkout page redirects to your
success_url/cancel_urlwith afaststar_status=success|cancel|errorquery parameter, the SDK blocks the navigation, closes the checkout page and fires the matching callback. Any other query parameters on the URL (such aspayment_intent_id) are passed through to your callback asdata. So even if a checkout page never calls the bridge, a normal redirect still completes the flow.
Notes
-
onSuccessis for client-side interaction only (closing the page, showing a success screen). Order fulfillment must rely on FastStar's server-side webhooks. - 3-D Secure bank verification happens inside the same WebView; no extra handling is needed.