skipcash 0.0.9 copy "skipcash: ^0.0.9" to clipboard
skipcash: ^0.0.9 copied to clipboard

SkipCash SDK.

example/lib/main.dart

import 'dart:async';
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:skipcash/skipcash.dart';
import 'package:skipcash/skipcash_apple_pay_button.dart';

void main() {
  runApp(const MaterialApp(home: MyApp()));
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _skipcash = Skipcash(
    merchantIdentifier: '',
    createPaymentLinkEndPoint: '',
    authorizationHeader: '',
  );

  StreamSubscription<dynamic>? _sheetResultSubscription;

  @override
  void initState() {
    super.initState();

    _sheetResultSubscription = _skipcash.paymentSheetResultStream.listen((result) {
      debugPrint('Payment sheet result: $result');
      showDialog(
        context: context,
        builder: (ctx) => AlertDialog(
          title: const Text('Payment Sheet Result'),
          content: Text('$result'),
          actions: [
            TextButton(
              onPressed: () => Navigator.of(ctx).pop(),
              child: const Text('OK'),
            ),
          ],
        ),
      );
    });
  }

  @override
  void dispose() {
    _sheetResultSubscription?.cancel();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('SkipCash SDK Example')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton.icon(
              onPressed: () {
                _skipcash.showPaymentSheet(
                  sessionId: 'd6bebb80-47c7-4b34-8702-67770dbbdb3c',
                  creditCard: true,
                  applePay: true,
                  backgroundColor: '#ffffff',
                  closeButtonColor: '#121212',
                  cardFormPaddingTop: 20,
                );
              },
              icon: const Icon(Icons.payment),
              label: const Text('Launch Payment Sheet'),
              style: ElevatedButton.styleFrom(
                padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 16),
                textStyle: const TextStyle(fontSize: 16),
              ),
            ),
            const SizedBox(height: 24),
            ApplePayButton(
              sessionId: 'dd5f866d-6166-417e-8abe-998596d4cb67',
              width: 270,
              height: 36,
              cornerRadius: 5.0,
              onResult: (result) {
                showDialog(
                  context: context,
                  builder: (ctx) => Platform.isIOS
                      ? CupertinoAlertDialog(
                          title: const Text('Apple Pay Result'),
                          content: Text('$result'),
                          actions: [
                            CupertinoDialogAction(
                              onPressed: () => Navigator.of(ctx).pop(),
                              child: const Text('OK'),
                            ),
                          ],
                        )
                      : AlertDialog(
                          title: const Text('Apple Pay Result'),
                          content: Text('$result'),
                          actions: [
                            TextButton(
                              onPressed: () => Navigator.of(ctx).pop(),
                              child: const Text('OK'),
                            ),
                          ],
                        ),
                );
              },
            ),
          ],
        ),
      ),
    );
  }
}
2
likes
120
points
450
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

SkipCash SDK.

Homepage

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on skipcash

Packages that implement skipcash