Skip to content

mrdavidrees/flutter-apple-pay

 
 

Repository files navigation

Example

 Future<void> makePayment() async {
    dynamic paymentToken;
    PaymentItem paymentItems = PaymentItem(label: "Item Name", amount: 100.0);
    try {
      await Future.delayed(Duration(milliseconds: 100));

      // wait because apple pay will put whole app in pause
      paymentToken = await FlutterApplePay.getStripeToken(
        stripePublishedKey: "pk_test_00000000000000000000000000",
        countryCode: "US",
        currencyCode: "USD",
        paymentNetworks: [
          PaymentNetwork.visa,
          PaymentNetwork.mastercard,
          PaymentNetwork.amex,
          PaymentNetwork.quicPay,
          PaymentNetwork.discover
        ],
        shippingFields: [
          ShippingField.emailAddress,
          ShippingField.name,
          ShippingField.phoneNumber,
          ShippingField.emailAddress,
        ],
        merchantIdentifier: "com.example.exampleapp",
        paymentItems: [paymentItems],
        merchantName: "Example",
      );

      if (paymentToken is String) {
        await FlutterApplePay.closeApplePaySheet(isSuccess: true);

        /**
           * Apple pay & stripe purchase complete
           */

      } else {
        await FlutterApplePay.closeApplePaySheet(isSuccess: false);
      }
    } on PlatformException {
      throw Exception('Failed to get platform version.');
    }
  }

About

Flutter apple pay

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 56.5%
  • Dart 27.3%
  • Ruby 10.2%
  • Java 4.6%
  • Objective-C 1.4%