diff --git a/backend/src/services/phonepe-transaction-sync-service.js b/backend/src/services/phonepe-transaction-sync-service.js index d822763..6538f44 100644 --- a/backend/src/services/phonepe-transaction-sync-service.js +++ b/backend/src/services/phonepe-transaction-sync-service.js @@ -32,6 +32,18 @@ class PhonePeTransactionSyncService { * Fetch transactions from PhonePe for a date range */ async fetchTransactions(startDate, endDate) { + // Check if PhonePe Gateway is configured + if (this.merchantId === 'YOUR_MERCHANT_ID' || !this.merchantId || this.merchantId.length < 5) { + console.log('ℹ️ [PhonePe Sync] PhonePe Gateway not configured - using Direct UPI instead'); + console.log('ℹ️ [PhonePe Sync] For Direct UPI payments, use the webhook-based reconciliation'); + return { + success: true, + transactions: [], + message: 'PhonePe Gateway not configured. Using Direct UPI payment system.', + usingDirectUPI: true, + }; + } + try { const payload = { merchantId: this.merchantId, @@ -212,6 +224,23 @@ class PhonePeTransactionSyncService { // Fetch transactions from PhonePe const result = await this.fetchTransactions(startDate, endDate); + // If using Direct UPI (no PhonePe Gateway configured) + if (result.usingDirectUPI) { + console.log('ℹ️ [PhonePe Sync] Using Direct UPI - No gateway sync needed'); + return { + success: true, + message: 'Direct UPI payment system active. Payments auto-detected via webhooks.', + results: { + total: 0, + matched: 0, + autoRecorded: 0, + needsReview: 0, + failed: 0, + usingDirectUPI: true, + }, + }; + } + if (!result.success) { return { success: false, @@ -309,6 +338,17 @@ class PhonePeTransactionSyncService { const result = await this.fetchTransactions(startDate, endDate); + // If using Direct UPI + if (result.usingDirectUPI) { + console.log('ℹ️ [PhonePe Sync] Direct UPI active - no review queue needed'); + return { + success: true, + reviewQueue: [], + count: 0, + message: 'Using Direct UPI - payments auto-detected via webhooks', + }; + } + if (!result.success) { return { success: false, message: result.message }; } diff --git a/luckychit/lib/interfaces/manager/transaction_sync_dialog.dart b/luckychit/lib/interfaces/manager/transaction_sync_dialog.dart index d7c5384..cbd6df6 100644 --- a/luckychit/lib/interfaces/manager/transaction_sync_dialog.dart +++ b/luckychit/lib/interfaces/manager/transaction_sync_dialog.dart @@ -720,13 +720,60 @@ class _TransactionSyncDialogState extends State { ), SizedBox(height: 8.h), Text( - 'No transactions need review.\nTap "Sync Transactions" to check for new payments.', + 'No transactions need review.', textAlign: TextAlign.center, style: TextStyle( fontSize: 14.sp, color: Colors.grey.shade600, ), ), + SizedBox(height: 16.h), + Container( + padding: EdgeInsets.all(16.w), + decoration: BoxDecoration( + color: Colors.blue.shade50, + borderRadius: BorderRadius.circular(12.r), + border: Border.all(color: Colors.blue.shade200), + ), + child: Column( + children: [ + Icon( + Icons.qr_code_2, + size: 32.w, + color: Colors.blue.shade600, + ), + SizedBox(height: 12.h), + Text( + 'Using Direct UPI Payments', + style: TextStyle( + fontSize: 14.sp, + fontWeight: FontWeight.w600, + color: Colors.blue.shade900, + ), + ), + SizedBox(height: 8.h), + Text( + 'Payments are automatically detected when members pay via UPI QR codes.', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12.sp, + color: Colors.blue.shade700, + height: 1.4, + ), + ), + SizedBox(height: 8.h), + Text( + '• 0% transaction fees\n• Instant auto-detection\n• Works with any UPI app', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 11.sp, + color: Colors.blue.shade600, + height: 1.5, + ), + ), + ], + ), + ), ], ), ),