foo_apple_pay_sdk 1.0.3 copy "foo_apple_pay_sdk: ^1.0.3" to clipboard
foo_apple_pay_sdk: ^1.0.3 copied to clipboard

PlatformiOS

Foo Apple Pay plugin.

example/lib/main.dart

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

import 'package:foo_apple_pay_sdk/foo_apple_pay.dart';
import 'package:foo_apple_pay_sdk/apple_pay_event.dart';
import 'package:foo_apple_pay_sdk/pk_pass.dart';
import 'package:foo_apple_pay_sdk/pk_payment_pass.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    try {
      FooApplePay.setHostNameAndPath('SqHost', 'SqPath');

      bool supportsAppleWallet = await FooApplePay.deviceSupportsAppleWallet();
      print('$supportsAppleWallet');

      List<PKPass>? localPasses = await FooApplePay.getLocalPasses();
      if (localPasses != null) {
        print('$localPasses');
      }
      else {
        print('localPasses is null');
      }

      List<PKPaymentPass>? remotePasses = await FooApplePay.getRemotePasses();
      print('$remotePasses');

      bool isCardAddedToLocalWithSuffix = await FooApplePay.isCardAddedToLocalWalletWithCardSuffix("1");
      print('$isCardAddedToLocalWithSuffix');

      bool isCardAddedToRemoteWithSuffix = await FooApplePay.isCardAddedToRemoteWalletWithCardSuffix("1");
      print('$isCardAddedToRemoteWithSuffix');

      bool isCardAddedToLocalWithPrimaryAccountIdentifier = await FooApplePay.isCardAddedToLocalWalletWithPrimaryAccountIdentifier("1");
      print('$isCardAddedToLocalWithPrimaryAccountIdentifier');

      bool isCardAddedToRemoteWithPrimaryAccountIdentifier = await FooApplePay.isCardAddedToRemoteWalletWithPrimaryAccountIdentifier("1");
      print('$isCardAddedToRemoteWithPrimaryAccountIdentifier');

      FooApplePay.applePayCallBack = testCallBack;

      FooApplePay.addCard('1', '2', '3', '4', '6');
      FooApplePay.addCard('1', '2', '3', '4', '6', '7', '8');

      platformVersion = 'Called all methods';

    } catch (e) {
      platformVersion = 'Failed due to $e';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Running on: $_platformVersion\n'),
        ),
      ),
    );
  }
}

void testCallBack(ApplePayEvent event) {
  if (event.errorMessage != null) {
    print("Error message: " + event.errorMessage!);
  } else {
    print("Error message is empty");
  }

  if (event.pass != null && event.pass!.description != null) {
    print("PKPaymentPass: " + event.pass!.description!);
  } else {
    print("PKPaymentPass is Empty");
  }

  print("Error: " + event.error.toString());
}
1
likes
110
pub points
23%
popularity

Publisher

unverified uploader

Foo Apple Pay plugin.

Homepage

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on foo_apple_pay_sdk