transaction_sms_parser 0.0.1 copy "transaction_sms_parser: ^0.0.1" to clipboard
transaction_sms_parser: ^0.0.1 copied to clipboard

A powerful Dart/Flutter package for parsing transaction SMS messages from banks, payment apps, and digital wallets. Extract amounts, account info, card details, wallet providers, merchant names, and balances.

example/example.dart

/// Example usage of the transaction_sms_parser package
library;

import 'package:transaction_sms_parser/transaction_sms_parser.dart';

void main() {
  // Example 1: Bank Account Transaction
  print('=== Example 1: Bank Account Transaction ===');
  const bankMessage =
      'Your VPA 9876543210@ybl linked to Indian Bank a/c no. XXXXXX1234 is debited for Rs.499.00 and credited to amazon@apl  (UPI Ref no  105201221633).';
  final bankTransaction = TransactionEngine.getTransactionInfo(bankMessage);
  print('Account Type: ${bankTransaction.account.type}');
  print('Account Number: ${bankTransaction.account.number}');
  print('Account Name (UPI ID): ${bankTransaction.account.name}');
  print('Transaction Type: ${bankTransaction.transaction.type}');
  print('Amount: ${bankTransaction.transaction.amount}');
  print('Merchant: ${bankTransaction.transaction.merchant}');
  print('References: ${bankTransaction.transaction.referenceNo}');

  print('Balance: ${bankTransaction.balance?.available}\n');

  // Example 2: PhonePe UPI Transaction
  print('=== Example 2: PhonePe UPI Transaction ===');
  const phonePeMessage =
      'Rs 150.00 debited from account ending 1234 to 9876543210@ybl on 04-11-25. UPI Ref: 432198765';
  final phonePeTransaction = TransactionEngine.getTransactionInfo(
    phonePeMessage,
  );
  print('Account Type: ${phonePeTransaction.account.type}');
  print('Account Name (UPI ID): ${phonePeTransaction.account.name}');
  print('Amount: ${phonePeTransaction.transaction.amount}\n');

  // Example 3: Google Pay UPI Transaction
  print('=== Example 3: Google Pay UPI Transaction ===');
  const googlePayMessage =
      'Rs.299.00 paid to merchant@okicici via UPI. Avbl bal Rs.5000';
  final googlePayTransaction = TransactionEngine.getTransactionInfo(
    googlePayMessage,
  );
  print('Account Type: ${googlePayTransaction.account.type}');
  print('Account Name (UPI ID): ${googlePayTransaction.account.name}');
  print('Amount: ${googlePayTransaction.transaction.amount}\n');

  // Example 4: Paytm UPI Transaction
  print('=== Example 4: Paytm UPI Transaction ===');
  const paytmMessage = 'You have paid Rs 75.50 to store123@paytm on 04-Nov-25';
  final paytmTransaction = TransactionEngine.getTransactionInfo(paytmMessage);
  print('Account Type: ${paytmTransaction.account.type}');
  print('Account Name (UPI ID): ${paytmTransaction.account.name}');
  print('Amount: ${paytmTransaction.transaction.amount}\n');

  //   // Example 2: Credit Card Transaction
  //   print('=== Example 2: Credit Card Transaction ===');
  //   const cardMessage =
  //       'Rs.2000 spent on Credit Card 4321. Avbl credit limit Rs.50000. Outstanding Rs.10000';
  //   final cardTransaction = TransactionEngine.getTransactionInfo(cardMessage);
  // print('Account Type: ${cardTransaction.account.type}');
  //   print('Card Number: ${cardTransaction.account.number}');
  //   print('Transaction Type: ${cardTransaction.transaction.type}');
  //   print('Amount: ${cardTransaction.transaction.amount}');
  //   print('Available Limit: ${cardTransaction.balance?.available}');
  //   print('Outstanding: ${cardTransaction.balance?.outstanding}\n');

  //   // Example 3: Digital Wallet Transaction
  //   print('=== Example 3: Digital Wallet Transaction ===');
  //   const walletMessage =
  //       'Rs.250 debited from Paytm wallet. Available bal Rs.750';
  //   final walletTransaction = TransactionEngine.getTransactionInfo(walletMessage);
  //   print('Account Type: ${walletTransaction.account.type}');
  //   print('Wallet Name: ${walletTransaction.account.name}');
  //   print('Transaction Type: ${walletTransaction.transaction.type}');
  //   print('Amount: ${walletTransaction.transaction.amount}');
  //   print('Balance: ${walletTransaction.balance?.available}\n');

  //   // Example 4: UPI Transaction
  //   print('=== Example 4: UPI Transaction ===');
  //   const upiMessage =
  //       'Rs.500 sent to merchant@upi via UPI. UPI Ref No 123456789. Avbl bal Rs.5000';
  //   final upiTransaction = TransactionEngine.getTransactionInfo(upiMessage);
  //   print('Transaction Type: ${upiTransaction.transaction.type}');
  //   print('Amount: ${upiTransaction.transaction.amount}');
  //   print('Merchant: ${upiTransaction.transaction.merchant}');
  //   print('Reference No: ${upiTransaction.transaction.referenceNo}');
  //   print('Balance: ${upiTransaction.balance?.available}\n');

  //   // Example 5: Using Individual Parsers
  //   print('=== Example 5: Using Individual Parsers ===');
  //   const message = 'Rs.1500.50 debited from AC 9876. Available balance Rs.25000';

  //   final amount = TransactionParser.getTransactionAmount(message);
  //   print('Transaction Amount: $amount');

  //   final type = TransactionParser.getTransactionType(message);
  //   print('Transaction Type: $type');

  //   final account = AccountParser.getAccountInfo(message);
  //   print('Account Type: ${account.type}');
  //   print('Account Number: ${account.number}');

  //   final balance = BalanceParser.getBalance(message);
  //   print('Available Balance: $balance\n');

  //   // Example 6: Handling Invalid Messages
  //   print('=== Example 6: Handling Invalid Messages ===');
  //   const invalidMessage = 'This is not a transaction message';
  //   final invalidTransaction = TransactionEngine.getTransactionInfo(
  //     invalidMessage,
  //   );
  //   print('Account Type: ${invalidTransaction.account.type}');
  //   print('Transaction Type: ${invalidTransaction.transaction.type}');
  //   print('Amount: ${invalidTransaction.transaction.amount}');
}
1
likes
150
points
12
downloads

Publisher

verified publishermabud.dev

Weekly Downloads

A powerful Dart/Flutter package for parsing transaction SMS messages from banks, payment apps, and digital wallets. Extract amounts, account info, card details, wallet providers, merchant names, and balances.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on transaction_sms_parser