Sure! Here's the complete README.md file content you can copy and save directly:
A Flutter plugin that opens the Apple Pay payment setup screen when Apple Pay is not yet configured on the user's device.
Note: This plugin currently supports iOS only and is useful when you need to prompt users to configure Apple Pay before proceeding with a payment flow.
Features
- ✅ Opens Apple Pay setup natively
- ✅ Simple Dart interface
- ✅ Custom platform interface with method channel implementation
Getting Started
1. Add Dependency
Add this to your pubspec.yaml:
dependencies:
open_apple_pay_payment_setup: ^1.0.0
Then run:
flutter pub get
2. iOS Setup
Make sure your iOS app:
- Has Apple Pay capability enabled in Xcode
- Includes a valid Merchant ID
- Targets iOS 11.0+
You may optionally add supported payment networks to your Info.plist if you need fine-tuned control, but this is not required for the setup screen to show.
Usage
import 'package:open_apple_pay_payment_setup/open_apple_pay_payment_setup.dart';
final setup = OpenApplePayPaymentSetup();
await setup.openPaymentSetup();
This will open the native Apple Pay setup flow.
Example
You can run the included example app:
cd example
flutter run
Here's a quick snippet:
ElevatedButton(
onPressed: () async {
try {
await OpenApplePayPaymentSetup().openPaymentSetup();
} catch (e) {
print('Failed to open Apple Pay setup: $e');
}
},
child: const Text('Open Apple Pay Setup'),
);
Platform Support
| Platform | Supported |
|---|---|
| iOS | ✅ Yes |
| Android | ❌ No |
| macOS | ❌ No |
| Web | ❌ No |
Limitations
- This plugin only works on iOS.
- You must test on a real device. Apple Pay setup cannot be tested on the simulator.
- This is designed for Vault use cases. It does not support Apple Pay Checkout (e.g., for immediate payments).
- Will throw
MissingPluginExceptionon unsupported platforms if you don’t guard your calls.
Contributing
Feel free to open issues or pull requests to improve the plugin!