flutter_applepay_sdk 0.0.1 copy "flutter_applepay_sdk: ^0.0.1" to clipboard
flutter_applepay_sdk: ^0.0.1 copied to clipboard

This is Wallet SDK for Apple Pay. It is a Flutter plugin that provides functionality to integrate Apple Pay into Flutter applications. Powered by Bonum.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:convert';
import 'package:flutter_applepay_sdk/flutter_applepay_sdk.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

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

class _MyAppState extends State<MyApp> {
  String _walletInfo = 'Unknown';
  String _secureCheckResult = 'Not checked';
  List<dynamic> _paymentPasses = [];

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

  // Retrieve Wallet Information
  Future<void> _retrieveWalletInformation() async {
    String walletInfo;
    try {
      walletInfo = await FlutterApplepaySdk.retrieveWalletInformation();
    } catch (e) {
      walletInfo = 'Failed to retrieve wallet information';
    }

    if (!mounted) return;

    setState(() {
      _walletInfo = walletInfo;
    });
  }

  // Add Payment Pass
  Future<void> _addPaymentPass() async {
    final cardDetails = {
      'cardholderName': 'TUVSHINSAIKHAN',
      'primaryAccountSuffix': '8015',
      'primaryAccountIdentifier': '',
      'paymentNetwork': 'masterCard',
    };

    final networkDetails = {
      'url': 'https://uat.bonum.mn/tokenization/v1/connect',
      'method': 'POST',
      'header': [
        "Content-Type: application/json",
        "Authorization: Bearer eyJraWQiOiJib251bV9rZXlfdjEiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJtYmFua3Rlc3QiLCJhdWQiOiJtYmFua3Rlc3QiLCJuYmYiOjE3NDczODA4MDgsInNjb3BlIjpbIm1kZXMiXSwiaXNzIjoiaHR0cDovL2xvY2FsaG9zdDo4MDgwIiwiZXhwIjoxNzQ3NDY3MjA4LCJpYXQiOjE3NDczODA4MDgsImp0aSI6IjQzMmE3MzM2LWQwZGYtNGZkNy1iNTNmLThlY2U4OGIxYjYyZCJ9.IfSuojfcaNdZ1G54T7WDKxw_9KNewdwLbChM_ud0NiFZPZoBKefw9Qa1mNSe0DornqjYWUQSpA_QaexnssV1zeyizB0bpjcYsM3cX8BD_OhWW--srBjG10ltprBPgYeLSi31Fjc6JBcGX4SCmI7FQzRggE2g1dN4lnF3goUPz9bwJcffO0UGpJvzxgdXb3sZTueAbgOk2s5tpbCln_FDymA-TgUVtcmxTAb2GaZbidj0jdjNTayQ_Vqchy--nG41xCcD7CXlZjr2xtN7Jj2QPVPDtrgnJSOVw0u3y0FASPom8E-pF_VOpQkUuBDG-oNDn-zgGAs41avuzs7pcYz9nw"
      ],
      'body': jsonEncode({
        'data':
            "8F58C0C79EA2A2CF4CA86F7CC73AD384ED7255AE156D296449612148FB2AD759236DB2ACFE5AD320F535505AFA209273E370FD302C610C22ED04D2CCE0D39EB6224D2DDA99D68C060159C1BF916646713B478AE91DB1295ABFA375D6E40D4225",
        'holderName': "TUVSHINSAIKHAN",
        'phoneNumber': "99131111"
      }),
    };

    final success =
        await FlutterApplepaySdk.presentAddPaymentPassViewController(
            cardDetails, networkDetails);

    if (success) {
      setState(() {
        _walletInfo = 'Payment Pass added successfully!';
      });
    } else {
      setState(() {
        _walletInfo = 'Failed to add Payment Pass.';
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Flutter Apple Pay SDK Example'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                'Wallet Information:',
                style: Theme.of(context).textTheme.titleLarge,
              ),
              const SizedBox(height: 8),
              Text(_walletInfo),
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: _addPaymentPass,
                child: const Text('Add Payment Pass'),
              ),
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: () async {
                  try {
                    final exists =
                        await FlutterApplepaySdk.secureElementPassExists(
                            "8015");
                    setState(() {
                      _secureCheckResult = exists
                          ? 'Pass already exists in Wallet.'
                          : 'Pass not found in Wallet.';
                    });
                  } catch (e) {
                    setState(() {
                      _secureCheckResult = 'Error: ${e.toString()}';
                    });
                  }
                },
                child: const Text('Check Secure'),
              ),
              const SizedBox(height: 10),
              Text('Secure Check Result: $_secureCheckResult'),
              // const SizedBox(height: 20),
              // Text('Payment Passes:'),
              // ..._paymentPasses.map((pass) => Text(pass.toString())),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
0
points
23
downloads

Publisher

unverified uploader

Weekly Downloads

This is Wallet SDK for Apple Pay. It is a Flutter plugin that provides functionality to integrate Apple Pay into Flutter applications. Powered by Bonum.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_applepay_sdk

Packages that implement flutter_applepay_sdk