A Flutter plugin for Alipay payment integration, supporting Android platform.
- ✅ Android platform Alipay payment integration
- ✅ Alipay app installation detection
- ✅ Payment result callback handling
- ✅ Order query functionality
- ❌ iOS platform (not supported yet)
Add dependency to your pubspec.yaml
file:
dependencies:
flutter_alipay_plugin: ^0.0.1
import 'package:flutter_alipay_plugin/flutter_alipay_plugin.dart';
final alipayPlugin = FlutterAlipayPlugin();
// Initialize Alipay
final success = await alipayPlugin.initAlipay(
appId: 'your_app_id',
isSandbox: false,
);
// Order info is usually generated by server
final orderInfo = 'your_order_info_from_server';
final result = await alipayPlugin.pay(
orderInfo: orderInfo,
isShowPayLoading: true, // Whether to show payment loading UI
);
// Handle payment result
if (result['success'] == true) {
print('Payment successful');
} else {
print('Payment failed: ${result['memo']}');
}
These status codes are officially defined by Alipay SDK, not custom defined. They are returned by the PayTask.payV2()
method from Alipay Android SDK.
Status Code | Description | Source |
---|---|---|
9000 | Order payment successful | Alipay SDK Official |
8000 | Processing, payment result unknown | Alipay SDK Official |
4000 | Order payment failed | Alipay SDK Official |
5000 | Duplicate request | Alipay SDK Official |
6001 | User cancelled | Alipay SDK Official |
6002 | Network connection error | Alipay SDK Official |
6004 | Payment result unknown | Alipay SDK Official |
Note: These status codes are standard Alipay SDK responses and do not need to be negotiated with your backend service.
Add to android/app/src/main/AndroidManifest.xml
:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
- Server Integration: This plugin only provides client-side integration, order information needs to be generated by the server
- Signature Verification: Payment completion requires signature verification on the server
- Test Environment: Use Alipay sandbox environment for development testing
- Production Environment: Apply for formal application on Alipay Open Platform before going live
MIT License
Copyright (c) 2025 PlaudAI. All rights reserved.