VnPaymentGen
A Flutter package for Vietnamese payment solutions, supporting VietQR generation, bank information lookup, and business tax code verification.
Features
- Bank List API Integration: Fetch and cache the list of all Vietnamese banks
- VietQR Generation: Create VietQR images for bank transfers with customizable parameters
- Business Tax Code Lookup: Verify and retrieve business information by tax code
- Multiple QR Templates: Support for various QR templates (compact, compact2, qr, qr-only)
- Responsive UI Components: Ready-to-use Flutter widgets for QR code display
Demo
Check out this demo to see the package in action:
Installation
Add this to your package's pubspec.yaml
file:
dependencies:
vn_payment_gen: ^0.0.1
Then run:
flutter pub get
Usage
Initialization
Initialize the package before using any features, typically in your main.dart
:
import 'package:vn_payment_gen/vn_payment_gen.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize VnPaymentGen
await VnPaymentGen.init();
runApp(MyApp());
}
Get Bank List
// Get the list of banks
final response = await VnPaymentGen.instance.getBanks();
if (response.isSuccess) {
final banks = response.data;
// Use bank data
}
Generate QR Code URL
// Generate QR URL with bank code
final qrUrl = VnPaymentGen.instance.generateQrUrlFromBankCode(
bankCode: 'ACB',
accountNo: '123456789',
amount: 100000, // optional
addInfo: 'Payment for order #123', // optional
);
// Or directly with bank BIN
final qrUrl = VnPaymentGen.instance.generateQrUrl(
bankId: '970416', // Bank BIN
accountNo: '123456789',
template: VnPaymentGen.templateCompact,
);
Display QR Widget
// Display QR code in your UI
VietQrImage(
bankId: '970416', // Bank BIN
accountNo: '123456789',
template: VnPaymentGen.templateCompact,
amount: 100000, // optional
addInfo: 'Payment for order #123', // optional
width: 250,
height: 250,
)
Business Tax Code Lookup
// Look up business information by tax code
final response = await VnPaymentGen.instance.getBusinessByTaxCode('0316794479');
if (response.isSuccess && response.data != null) {
final business = response.data;
print('Business name: ${business.name}');
print('Address: ${business.address}');
}
Available Templates
VnPaymentGen.templateCompact
- Compact QR with bank infoVnPaymentGen.templateCompact2
- Alternative compact templateVnPaymentGen.templateQr
- Standard QR code with bank infoVnPaymentGen.templateQrOnly
- QR code only
Example App
The package includes a complete example app demonstrating all features:
- Displaying the bank list
- Generating QR codes for payments
- Looking up business information by tax code
Run the example app:
cd example
flutter run
API Reference
VnPaymentGen
static Future<VnPaymentGen> init()
- Initialize the pluginFuture<ApiResponse<List<Bank>>> getBanks({bool forceRefresh = false})
- Get bank listBank? findBankByCode(String code)
- Find bank by codeBank? findBankByBin(String bin)
- Find bank by BINString generateQrUrl({...})
- Generate QR URL with parametersVietQrImage getQrImage({...})
- Get QR image widgetFuture<ApiResponse<Business?>> getBusinessByTaxCode(String taxCode)
- Look up business by tax code
Models
Bank
- Bank information modelBusiness
- Business information modelApiResponse<T>
- Generic API response wrapper
Credits
This package uses the following APIs:
- VietQR API for bank information and QR generation
- VietQR Business API for tax code verification
License
This project is licensed under the MIT License - see the LICENSE file for details.
Libraries
- api/index
- api/vn_payment_api
- models/api_response
- models/bank
- models/business
- models/index
- network/api_client
- network/api_constants
- repository/bank_repository
- repository/business_repository
- viet_qr/index
- viet_qr/viet_qr_generator
- vn_payment_gen
- vn_payment_gen_method_channel
- vn_payment_gen_platform_interface
- widgets/index
- widgets/viet_qr_image