pok_payments_flutter 0.0.2 copy "pok_payments_flutter: ^0.0.2" to clipboard
pok_payments_flutter: ^0.0.2 copied to clipboard

Flutter payment SDK with native JWE encryption and native modal 3DS.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:pok_payments_flutter/pok_payments_flutter.dart';

void main() => runApp(const _DemoApp());

class _DemoApp extends StatelessWidget {
  const _DemoApp();

  @override
  Widget build(BuildContext context) => MaterialApp(
        title: 'pok_payments_flutter demo',
        home: Scaffold(
          appBar: AppBar(title: const Text('pok payments demo')),
          body: const _Home(),
        ),
      );
}

class _Home extends StatelessWidget {
  const _Home();

  @override
  Widget build(BuildContext context) => ListView(
        children: [
          ListTile(
            title: const Text('Guest checkout'),
            subtitle: const Text(
                'Replace _kStagingOrderId with a real staging order id'),
            onTap: () => Navigator.of(context).push(MaterialPageRoute(
              builder: (_) => Scaffold(
                appBar: AppBar(title: const Text('Guest checkout')),
                body: GuestCheckout(
                  env: Environment.staging,
                  orderId: _kStagingOrderId,
                  onSuccess: (r) => debugPrint('success: $r'),
                  onError: (e) => debugPrint('error: $e'),
                ),
              ),
            )),
          ),
          ListTile(
            title: const Text('Add card'),
            onTap: () => Navigator.of(context).push(MaterialPageRoute(
              builder: (_) => Scaffold(
                appBar: AppBar(title: const Text('Add card')),
                body: AddCardForm(
                  env: Environment.staging,
                  onComplete: (d) => debugPrint('add card: $d'),
                  onError: (e) => debugPrint('error: $e'),
                ),
              ),
            )),
          ),
          ListTile(
            title: const Text('Pay by token'),
            subtitle: const Text(
                'Replace _kStagingOrderId / _kStagingCreditDebitCardId / '
                '_kStagingPayerAuthSetupReferenceId with real values'),
            onTap: () async {
              final ctx = context; // capture before async gap
              try {
                final r = await PokPayments.payByToken(
                  PayByTokenOptions(
                    env: Environment.staging,
                    orderId: _kStagingOrderId,
                    payerAuth: PayerAuthentication(
                      creditDebitCardId: _kStagingCreditDebitCardId,
                      payerAuthSetupReferenceId:
                          _kStagingPayerAuthSetupReferenceId,
                    ),
                  ),
                );
                debugPrint('result: $r');
              } catch (e) {
                if (isPokError(e)) {
                  debugPrint('pok error: $e');
                } else {
                  rethrow;
                }
              }
              if (!ctx.mounted) return;
            },
          ),
        ],
      );
}

// ---------------------------------------------------------------------------
// Placeholder constants — replace with real staging values before testing.
// ---------------------------------------------------------------------------

const _kStagingOrderId = 'f04a284c-3195-4a0d-8761-083d6d4ebde0';
const _kStagingCreditDebitCardId = 'REPLACE_WITH_STAGING_CREDIT_DEBIT_CARD_ID';
const _kStagingPayerAuthSetupReferenceId =
    'REPLACE_WITH_STAGING_PAYER_AUTH_SETUP_REFERENCE_ID';
0
likes
140
points
100
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter payment SDK with native JWE encryption and native modal 3DS.

Repository (GitHub)

License

ISC (license)

Dependencies

dio, flutter, socket_io_client

More

Packages that depend on pok_payments_flutter

Packages that implement pok_payments_flutter