You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

筹款系统支付流程设计、数据库交互及账户模式技术咨询

Hey there, let's break this down clearly for you since you're deep into building a fundraising system—super exciting project!

1. How the Payment Module of a Database-Driven Fundraising System Works

I’ll walk you through the core workflow tied directly to your database design:

  • Initiate Donation Intent: When a visitor picks a campaign and enters a donation amount, your system first creates a record in donateTable. Set status to pending, fill in donatorId (use a temporary UUID if the visitor isn’t logged in yet, then link it to their user account later), paymentdate (set to the record creation time), paymentamount, and campainID. This step ensures you don’t lose donation data even if the payment flow gets interrupted.
  • Redirect to Third-Party Gateway: Generate a unique payment reference (like DON-{{donateTable.id}}) using the new record’s ID. Pass this reference, the donation amount, and campaign details to your Visa/Mastercard gateway, then send the visitor to the gateway’s payment page.
  • Handle Payment Callback: After the visitor completes or abandons payment, the gateway will send a callback to your system’s predefined endpoint:
    • If payment succeeds: Update the corresponding donateTable record’s status to completed, and update paymentdate to the actual payment finish time. Then locate the matching campaign in your campaign table (e.g., campaignTable) and add the donation amount x to its current_balance field.
    • If payment fails or is abandoned: Update the donateTable record’s status to failed or cancelled—this helps with later analytics and issue troubleshooting.
  • Reconciliation Checks: Run daily reconciliation by pulling transaction details from the payment gateway and cross-referencing them with completed records in donateTable. This ensures all payments are accounted for and matches up amounts to avoid discrepancies.
2. Full System Workflow & Account Model Recommendations

Overall System Workflow

Based on your scenario, here’s the end-to-end workflow you should implement:

  1. Visitor Starts Donation: The visitor browses a campaign, enters their donation amount, and provides basic info (or uses a temporary session ID if not logged in).
  2. Pre-Save Donation Record: Write the pending donation to donateTable (status=pending) and generate a unique donation order ID.
  3. Route Payment to Gateway: Package the order ID, amount, and campaign ID into a payment request, send it to the gateway, and redirect the visitor to complete payment.
  4. Update Status on Callback: Once the gateway sends a callback, update the donateTable status and sync the campaign’s balance.
  5. Send Notifications: Notify the donor of success/failure, generate a digital donation receipt (optional), and alert the campaign organizer about the new donation.

Account Model: Single Account + Reference Codes Is the Way to Go

For fundraising systems, using a single platform-wide receiving account paired with unique transaction reference codes is the most practical and efficient approach. Here’s why:

  • Simplified Account Management: You don’t need to open a separate bank account for every campaign—just maintain one platform account. This cuts down on administrative overhead for account setup and reconciliation.
  • Precise Transaction Tracking: The donateTable.id or custom payment reference you generate will be tied to every transaction in the gateway’s records. This lets you easily map each payment back to its specific donation and campaign.
  • Compliance & Tax Ease: A single account makes it easier to manage regulatory compliance, reporting, and tax filings. Later, you can use the donation records to distribute funds to campaign organizers as needed.

Quick Practical Tips

  • Idempotency for Callbacks: Payment gateways might send duplicate callbacks, so add logic to check if a donateTable record’s status is already updated before processing the callback. This prevents double-updating campaign balances.
  • Temporary Visitor Handling: Use a UUID for donatorId if the visitor isn’t logged in. When they create an account later, let them link their temporary donation records to their user profile.
  • Standardize Status Values: Use enum values for status (e.g., pending, completed, failed, cancelled) instead of free-text strings. This makes queries and analytics cleaner and less error-prone.

内容的提问来源于stack exchange,提问作者Tigray

火山引擎 最新活动