Skip to content

Plaud-AI/flutter_alipay_plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flutter_alipay_plugin

A Flutter plugin for Alipay payment integration, supporting Android platform.

Features

  • ✅ Android platform Alipay payment integration
  • ✅ Alipay app installation detection
  • ✅ Payment result callback handling
  • ✅ Order query functionality
  • ❌ iOS platform (not supported yet)

Installation

Add dependency to your pubspec.yaml file:

dependencies:
  flutter_alipay_plugin: ^0.0.1

Usage

1. Initialize Alipay

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,
);

2. Initiate payment

// 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']}');
}

Payment Result Status Codes

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.

Android Configuration

1. Add permissions

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" />

Notes

  1. Server Integration: This plugin only provides client-side integration, order information needs to be generated by the server
  2. Signature Verification: Payment completion requires signature verification on the server
  3. Test Environment: Use Alipay sandbox environment for development testing
  4. Production Environment: Apply for formal application on Alipay Open Platform before going live

License

MIT License

Copyright

Copyright (c) 2025 PlaudAI. All rights reserved.

Author

Neo.Wang@plaud.ai

Alipay Documents

支付宝开放平台文档

支付宝 Android SDK 文档

About

Flutter Plugin For AliPay

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •