The GiveHub donation workflow system is a comprehensive payment processing infrastructure that enables both traditional payment methods and blockchain-based cryptocurrency donations. The system integrates with Stellar blockchain, along with other cryptocurrency networks, and provides robust mechanisms for transaction tracking, verification, and reporting.
This documentation provides a detailed overview of the donation workflow, including the components involved, the relationships between them, and the flow of donation processing from end to end.
The donation workflow consists of the following key components:
Donate Class (lib/Donate.php): The
entry point for donation processing that handles both Square payments
and crypto donations.
DonationProcessor Class
(lib/DonationProcessor.php): Handles the core
donation business logic, database management, and
notifications.
TransactionProcessor Class
(lib/TransactionProcessor.php): Handles
blockchain-specific transaction processing, particularly for the Stellar
network.
BlockchainTransactionController Class
(lib/BlockchainTransactionController.php): Manages
blockchain transaction records and provides status
verification.
Transaction Class
(lib/Transaction.php): The API controller for
transaction operations that provides HTTP endpoints.
The relationship between components follows this structure:
┌─────────────────────┐ ┌──────────────────────────┐
│ │ │ │
│ Transaction Class │ │ DonationProcessor │
│ (API Controller) │──────────▶ (Core Donation │
│ │ │ Business Logic) │
└─────────────────────┘ │ │
└───────────────┬──────────┘
┌─────────────────────┐ │
│ │ │
│ Donate Class │ ┌───────────────▼──────────┐
│ (Payment Processor) │──────────▶ TransactionProcessor │
│ │ │ (Blockchain Processing) │
└────────────┬────────┘ │ │
│ └───────────────┬──────────┘
│ │
┌────────────▼────────┐ ┌───────────────▼──────────┐
│ │ │ │
│ BlockchainTransaction◄─────────▶ Database Collections │
│ Controller │ │ │
│ │ └──────────────────────────┘
└─────────────────────┘
The donation process begins when a user selects a payment method on the frontend:
For credit card payments through Square:
/api.php/Donate/processSquarePayment
with payment detailsDonate class validates the data and connects to
Square APIDonate class forwards the payment data to
DonationProcessorFor cryptocurrency donations:
/api.php/Donate/processCryptoDonation with donation
detailsDonate class validates the crypto type and
generates payment instructionsblockchain_transactions collectionAll transactions, regardless of payment method, are recorded in the system:
For cryptocurrency transactions, verification happens in two ways:
The BlockchainTransactionController handles the
verification by:
The system supports two advanced donation features:
processRecurringDonations method)
processes due donations┌───────────────────────┐ ┌──────────────────────────┐
│ Donate Class │ │ DonationProcessor Class │
├───────────────────────┤ ├──────────────────────────┤
│ processSquarePayment()│──────▶│ processDonation() │
│ processCryptoDonation()│─────▶│ validateDonationData() │
│ getSupportedCryptos() │ │ structureDonationData() │
│ verifyBlockchain │ │ initiateTransaction() │
│ Transaction() │ │ updateCampaignFunding() │
└───────────────────────┘ │ sendConfirmationEmail() │
│ updateDonationStatus() │
│ processRecurringDonations│
└──────────────────────────┘
┌───────────────────────────┐ ┌──────────────────────────┐
│ TransactionProcessor Class│ │ BlockchainTransaction │
├───────────────────────────┤ │ Controller Class │
│ processDonation() │ ├──────────────────────────┤
│ updateCampaignFunding() │ │ createTransaction() │
│ releaseMilestoneFunding() │ │ updateTransactionStatus()│
│ createMilestoneEscrow() │ │ checkTransactionStatus() │
│ getStellarAccountTrans │ │ getTransaction() │
│ actions() │ │ getTransactionById() │
│ checkStellarAccount │ │ getTransactionsByStatus()│
│ Balance() │ │ getUserTransactions() │
└───────────────────────────┘ │ getCampaignTransactions()│
│ getPendingTransactions() │
└──────────────────────────┘
The donation workflow utilizes several MongoDB collections:
Transactions go through several states during their lifecycle:
| State | Description |
|---|---|
| pending | Transaction is created but not yet confirmed on the blockchain |
| submitted | Transaction has been submitted to the blockchain network |
| confirming | Transaction is being processed by blockchain validators |
| confirmed | Transaction is confirmed and finalized on the blockchain |
| failed | Transaction failed to process or was rejected |
| expired | Pending transaction that timed out (after 1 hour) |
The system primarily uses the Stellar blockchain with these key features:
The system also supports:
For credit card payments, the system:
For crypto payments, the system:
The donation workflow implements several error handling mechanisms:
The donation system implements these security measures:
The donation workflow provides comprehensive reporting through:
The donation workflow exposes these main API endpoints:
| Endpoint | Description |
|---|---|
/api.php/Donate/processSquarePayment |
Process a Square credit card payment |
/api.php/Donate/processCryptoDonation |
Generate crypto payment instructions |
/api.php/Transaction/processDonation |
Process a blockchain-based donation |
/api.php/Transaction/getTransactionHistory |
Get history of transactions |
/api.php/Transaction/getTransaction |
Get details of a specific transaction |
/api.php/Transaction/createMilestoneEscrow |
Create a milestone-based escrow account |
/api.php/Transaction/releaseMilestoneFunding |
Release funds from an escrow account |
// Frontend JavaScript example
async function makeCryptoDonation() {
const donationData = {
cryptoType: "XLM",
amount: 50,
campaignId: "60a3e5b2f91a123456789012",
donorInfo: {
name: "John Doe",
email: "john@example.com"
},
message: "Supporting this great cause!",
isAnonymous: false
};
const response = await fetch('/api.php/Donate/processCryptoDonation', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(donationData)
});
const result = await response.json();
if (result.success) {
// Show QR code and payment instructions to user
displayQRCode(result.qrCode);
displayWalletAddress(result.walletAddress);
displayInstructions(result.instructions);
// Store transaction reference for later verification
saveTransactionReference(result.reference);
} else {
// Handle error
displayError(result.error);
}
}The GiveHub donation workflow system provides a robust, secure, and flexible way to accept and manage donations through both traditional payment methods and cryptocurrencies. The system’s modular design allows for easy extension to support additional payment methods or blockchain networks in the future.