Simple Connect with your website or app. Easily integrated with Node.js, .NET Core, PHP, and Java – Complete documentation provided.
The Donation Box is a flexible, easy-to-integrate solution designed to simplify the process of accepting donations online. Built with modern technologies like jQuery, .NET Core, and MS SQL, it ensures seamless functionality and a user-friendly experience.
With support for customizable donation packages, secure payment processing through PayPal and credit cards, and effortless integration into any website platform, Donation Box provides everything you need to maximize contributions and support your cause.
See DonorBox Plug and Play in action! Watch the demo video below to explore the user-friendly interface and seamless workflow that make donation management effortless.
The Donation Box offers a rich set of features designed to make the donation process seamless, user-friendly, and highly efficient. Whether you're a developer or an organization, this solution is customizable to meet your specific needs while ensuring a hassle-free experience for your donors.
The Donation system uses the following table:
CREATE TABLE Donation ( DonationId INT PRIMARY KEY IDENTITY(1,1), Email NVARCHAR(255), Phone NVARCHAR(50), DonationAmount DECIMAL(18,2), ChargesAmount DECIMAL(18,2) NULL, SelectionDate DATETIME NOT NULL, PaymentDate DATETIME NULL, PaymentMode NVARCHAR(50) NULL, IsPaid BIT NULL, PaymentReferenceID NVARCHAR(255) NULL, Remarks NVARCHAR(MAX) NULL );
The Donation system uses the following table:
CREATE TABLE Donation ( DonationId INT PRIMARY KEY AUTO_INCREMENT, Email VARCHAR(255), Phone VARCHAR(50), DonationAmount DECIMAL(18,2), ChargesAmount DECIMAL(18,2) NULL, SelectionDate DATETIME NOT NULL, PaymentDate DATETIME NULL, PaymentMode VARCHAR(50) NULL, IsPaid TINYINT(1) NULL, PaymentReferenceID VARCHAR(255) NULL, Remarks TEXT NULL );
The Donation system uses the following table:
CREATE TABLE Donation ( DonationId SERIAL PRIMARY KEY, Email VARCHAR(255), Phone VARCHAR(50), DonationAmount NUMERIC(18,2), ChargesAmount NUMERIC(18,2) NULL, SelectionDate TIMESTAMP NOT NULL, PaymentDate TIMESTAMP NULL, PaymentMode VARCHAR(50) NULL, IsPaid BOOLEAN NULL, PaymentReferenceID VARCHAR(255) NULL, Remarks TEXT NULL );
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<included>
<included>
To integrate the chat system with your application:
To generate a PayPal API key:
To generate Stripe API keys:
// POST: Create payment intent [HttpPost] public IActionResult CreatePaymentIntent(string email, string phone, decimal amount) { // Set your secret key StripeConfiguration.ApiKey = "yourstripekey"; // Replace with your Stripe Secret Key try { // Convert amount to cents long amountInCents = (long)(amount * 100); var options = new PaymentIntentCreateOptions { Amount = amountInCents, Currency = "usd", PaymentMethodTypes = new List{ "card", }, }; var service = new PaymentIntentService(); PaymentIntent intent = service.Create(options); // Store the initial record in the database var donation = new Donation { Email = email, Phone = phone, DonationAmount = amount, SelectionDate = DateTime.Now, PaymentDate = null, // Will update on successful payment PaymentMode = "Stripe", Ispaid = false, PaymentReferneceID = intent.Id, // Store the PaymentIntent ID for reference Remarks = "Pending Payment" }; _dbContext.Donations.Add(donation); _dbContext.SaveChanges(); return Json(new { clientSecret = intent.ClientSecret, success = true }); } catch (Exception ex) { return Json(new { success = false, message = ex.Message }); } } [HttpPost] public IActionResult UpdatePaymentStatus(string paymentReferenceID) { try { var donation = _dbContext.Donations.FirstOrDefault(d => d.PaymentReferneceID == paymentReferenceID); if (donation == null) return Json(new { success = false, message = "Donation record not found." }); donation.Ispaid = true; donation.PaymentDate = DateTime.Now; donation.Remarks = "Payment Successful"; _dbContext.SaveChanges(); return Json(new { success = true }); } catch (Exception ex) { return Json(new { success = false, message = ex.Message }); } } [HttpPost] public IActionResult PayPalPayment(string email, string phone, decimal amount, string payerId, string paymentId) { try { // Record the successful donation in the database var donation = new Donation { Email = email, Phone = phone, DonationAmount = amount, SelectionDate = DateTime.Now, PaymentDate = DateTime.Now, // Set the payment date to the current time PaymentMode = "PayPal", Ispaid = true, // Mark as paid PaymentReferneceID = paymentId, // Store the PayPal Payment ID for reference Remarks = "Payment Completed" }; // Save the donation record in the database _dbContext.Donations.Add(donation); _dbContext.SaveChanges(); return Json(new { success = true, message = "Donation recorded successfully." }); } catch (Exception ex) { return Json(new { success = false, message = ex.Message }); } }
// POST: Create payment intent $amountInCents, 'currency' => 'usd', 'payment_method_types' => ['card'], ]); // Store the initial record in the database (Use your DB connection here) $donation = [ 'Email' => $email, 'Phone' => $phone, 'DonationAmount' => $amount, 'SelectionDate' => date('Y-m-d H:i:s'), 'PaymentDate' => null, // Will update on successful payment 'PaymentMode' => 'Stripe', 'Ispaid' => false, 'PaymentReferneceID' => $paymentIntent->id, // Store the PaymentIntent ID for reference 'Remarks' => 'Pending Payment' ]; // Insert into the database (replace with your DB logic) // Example: $db->insert('donations', $donation); // Return the client secret to the frontend echo json_encode(['clientSecret' => $paymentIntent->client_secret, 'success' => true]); } catch (Exception $e) { echo json_encode(['success' => false, 'message' => $e->getMessage()]); } } ?> // POST: Update payment status query("SELECT * FROM donations WHERE PaymentReferneceID = '$paymentReferenceID'"); if (!$donation) { echo json_encode(['success' => false, 'message' => 'Donation record not found.']); exit; } // Update donation status $donation['Ispaid'] = true; $donation['PaymentDate'] = date('Y-m-d H:i:s'); $donation['Remarks'] = 'Payment Successful'; // Save the updated donation record in the database (replace with your DB logic) // Example: $db->update('donations', $donation); echo json_encode(['success' => true]); } catch (Exception $e) { echo json_encode(['success' => false, 'message' => $e->getMessage()]); } } ?> // POST: PayPal payment $email, 'Phone' => $phone, 'DonationAmount' => $amount, 'SelectionDate' => date('Y-m-d H:i:s'), 'PaymentDate' => date('Y-m-d H:i:s'), // Set the payment date to the current time 'PaymentMode' => 'PayPal', 'Ispaid' => true, // Mark as paid 'PaymentReferneceID' => $paymentId, // Store the PayPal Payment ID for reference 'Remarks' => 'Payment Completed' ]; // Save the donation record in the database (replace with your DB logic) // Example: $db->insert('donations', $donation); echo json_encode(['success' => true, 'message' => 'Donation recorded successfully.']); } catch (Exception $e) { echo json_encode(['success' => false, 'message' => $e->getMessage()]); } } ?>
const express = require('express'); const stripe = require('stripe')('sk_test_51QV8zsC7t26NzuTMmWF310gRzMMfhhclYcfLuwKrYhNNwcBHdimsE74tu0gj94QONq3fmpZsnFfDAHbMTYVR7i3r00NvztIBoB'); // Replace with your Stripe Secret Key const bodyParser = require('body-parser'); const app = express(); app.use(bodyParser.json()); // POST: Create payment intent app.post('/create-payment-intent', async (req, res) => { const { email, phone, amount } = req.body; try { // Convert amount to cents const amountInCents = Math.round(amount * 100); // Create a PaymentIntent const paymentIntent = await stripe.paymentIntents.create({ amount: amountInCents, currency: 'usd', payment_method_types: ['card'], }); // Store the initial record in the database (use your DB logic here) const donation = { email, phone, donationAmount: amount, selectionDate: new Date(), paymentDate: null, // Will update on successful payment paymentMode: 'Stripe', isPaid: false, paymentReferenceID: paymentIntent.id, // Store the PaymentIntent ID for reference remarks: 'Pending Payment' }; // Save donation record in your database here // Return client secret to the frontend res.json({ clientSecret: paymentIntent.client_secret, success: true }); } catch (error) { res.json({ success: false, message: error.message }); } }); // POST: Update payment status app.post('/update-payment-status', async (req, res) => { const { paymentReferenceID } = req.body; try { // Fetch the donation record by PaymentReferenceID (use your DB logic here) const donation = await db.getDonationByPaymentReferenceID(paymentReferenceID); // Replace with actual DB logic if (!donation) { return res.json({ success: false, message: 'Donation record not found.' }); } // Update donation status donation.isPaid = true; donation.paymentDate = new Date(); donation.remarks = 'Payment Successful'; // Save the updated donation record in the database (replace with your DB logic) await db.updateDonation(donation); // Replace with actual DB logic res.json({ success: true }); } catch (error) { res.json({ success: false, message: error.message }); } }); app.listen(3000, () => { console.log('Server is running on port 3000'); }); const express = require('express'); const paypal = require('paypal/checkout-server-sdk'); const bodyParser = require('body-parser'); const app = express(); app.use(bodyParser.json()); // PayPal SDK environment setup const clientId = 'YOUR_PAYPAL_CLIENT_ID'; const clientSecret = 'YOUR_PAYPAL_CLIENT_SECRET'; const environment = new paypal.core.SandboxEnvironment(clientId, clientSecret); const client = new paypal.core.PayPalHttpClient(environment); // POST: PayPal payment app.post('/paypal-payment', async (req, res) => { const { email, phone, amount, payerId, paymentId } = req.body; try { // Record the successful donation in the database const donation = { email, phone, donationAmount: amount, selectionDate: new Date(), paymentDate: new Date(), // Set the payment date to the current time paymentMode: 'PayPal', isPaid: true, // Mark as paid paymentReferenceID: paymentId, // Store the PayPal Payment ID for reference remarks: 'Payment Completed' }; // Save the donation record in the database (replace with your DB logic) await db.saveDonation(donation); // Replace with actual DB logic res.json({ success: true, message: 'Donation recorded successfully.' }); } catch (error) { res.json({ success: false, message: error.message }); } }); app.listen(3000, () => { console.log('Server is running on port 3000'); });
import com.stripe.Stripe; import com.stripe.model.PaymentIntent; import com.stripe.exception.StripeException; import com.stripe.param.PaymentIntentCreateParams; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.util.List; Service public class StripeService { Value("${stripe.api.key}") private String stripeApiKey; public PaymentIntent createPaymentIntent(Long amount) throws StripeException { Stripe.apiKey = stripeApiKey; PaymentIntentCreateParams params = PaymentIntentCreateParams.builder() .setAmount(amount * 100) // Convert to cents .setCurrency("usd") .addPaymentMethodType("card") .build(); return PaymentIntent.create(params); } } Entity public class Donation { Id GeneratedValue private Long id; private String email; private String phone; private Double donationAmount; private Date selectionDate; private Date paymentDate; private String paymentMode; private Boolean isPaid; private String paymentReferenceID; private String remarks; // Getters and setters } import org.springframework.data.jpa.repository.JpaRepository; public interface DonationRepository extends JpaRepository{ Donation findByPaymentReferenceID(String paymentReferenceID); } import com.stripe.exception.StripeException; import com.stripe.model.PaymentIntent; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Date; RestController RequestMapping("/payment") public class PaymentController { Autowired private StripeService stripeService; Autowired private DonationRepository donationRepository; // Create Stripe Payment Intent PostMapping("/create-payment-intent") public String createPaymentIntent(RequestParam String email, RequestParam String phone, RequestParam Double amount) { try { PaymentIntent paymentIntent = stripeService.createPaymentIntent(amount); Donation donation = new Donation(); donation.setEmail(email); donation.setPhone(phone); donation.setDonationAmount(amount); donation.setSelectionDate(new Date()); donation.setPaymentMode("Stripe"); donation.setIsPaid(false); donation.setPaymentReferenceID(paymentIntent.getId()); donation.setRemarks("Pending Payment"); donationRepository.save(donation); return "{\"clientSecret\": \"" + paymentIntent.getClientSecret() + "\", \"success\": true}"; } catch (StripeException e) { return "{\"success\": false, \"message\": \"" + e.getMessage() + "\"}"; } } // Update payment status PostMapping("/update-payment-status") public String updatePaymentStatus(RequestParam String paymentReferenceID) { try { Donation donation = donationRepository.findByPaymentReferenceID(paymentReferenceID); if (donation == null) { return "{\"success\": false, \"message\": \"Donation record not found.\"}"; } donation.setIsPaid(true); donation.setPaymentDate(new Date()); donation.setRemarks("Payment Successful"); donationRepository.save(donation); return "{\"success\": true}"; } catch (Exception e) { return "{\"success\": false, \"message\": \"" + e.getMessage() + "\"}"; } } } import com.paypal.api.payments.*; import com.paypal.base.rest.APIContext; import com.paypal.base.rest.PayPalRESTException; import com.paypal.base.rest.OAuthTokenCredential; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; Service public class PayPalService { Value("${paypal.client.id}") private String clientId; Value("${paypal.client.secret}") private String clientSecret; Value("${paypal.mode}") private String mode; public Payment createPayment(Double amount, String returnUrl, String cancelUrl) throws PayPalRESTException { OAuthTokenCredential authTokenCredential = new OAuthTokenCredential(clientId, clientSecret); APIContext apiContext = new APIContext(authTokenCredential.getAccessToken()); apiContext.setConfigurationMap(PayPalConfig.getPayPalConfigMap(mode)); Amount totalAmount = new Amount(); totalAmount.setCurrency("USD"); totalAmount.setTotal(String.valueOf(amount)); Transaction transaction = new Transaction(); transaction.setAmount(totalAmount); transaction.setDescription("Donation Payment"); Payment payment = new Payment(); payment.setIntent("sale"); payment.setPayer(new Payer("paypal")); payment.setTransactions(Arrays.asList(transaction)); RedirectUrls redirectUrls = new RedirectUrls(); redirectUrls.setReturnUrl(returnUrl); redirectUrls.setCancelUrl(cancelUrl); payment.setRedirectUrls(redirectUrls); return payment.create(apiContext); } } import com.paypal.api.payments.Payment; import com.paypal.base.rest.PayPalRESTException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Date; RestController RequestMapping("/payment") public class PayPalController { Autowired private PayPalService payPalService; Autowired private DonationRepository donationRepository; // PayPal Payment PostMapping("/paypal-payment") public String paypalPayment(RequestParam String email, RequestParam String phone, RequestParam Double amount) { try { Payment payment = payPalService.createPayment(amount, "https://yourdomain.com/return", "https://yourdomain.com/cancel"); Donation donation = new Donation(); donation.setEmail(email); donation.setPhone(phone); donation.setDonationAmount(amount); donation.setSelectionDate(new Date()); donation.setPaymentDate(new Date()); donation.setPaymentMode("PayPal"); donation.setIsPaid(true); donation.setPaymentReferenceID(payment.getId()); donation.setRemarks("Payment Completed"); donationRepository.save(donation); return "{\"success\": true, \"message\": \"Donation recorded successfully.\"}"; } catch (PayPalRESTException e) { return "{\"success\": false, \"message\": \"" + e.getMessage() + "\"}"; } } }
Initial release of the Donation Box feature for collecting charitable contributions.
Future versions will continue to enhance the donation box system with additional features such as:
Your website is a tireless employee, working around the clock, 24 hours a day, 7 days a week, without rest or break. It is the face of your business, representing you to the world, and it needs to be the best it can be. That's why you can trust the expert team at AM-Technology to create the ultimate employee for your business - a website that works for you, day and night.
Contact us