Authentication
This endpoint requires:
- Valid JWT token in Authorization header
- Any authenticated user (both pastors and members can donate)
Endpoint
PATCH /api/church/makedonation/:id
Path Parameters
The unique identifier of the user making the donation (typically the authenticated user’s profile ID).
Request Body
The unique identifier (ObjectId) of the donation campaign to contribute to.
The email address of the donor. Used by Stripe for the checkout session and receipts.
The amount to donate. Must meet or exceed the donation’s minAmount requirement.
Stripe Payment Flow
When a donation is initiated, the following process occurs:
- Validation: The system checks donation status, date range, and minimum amount
- Stripe Session Creation: A Stripe Checkout session is created with:
client_reference_id: User ID for tracking
customer_email: Donor’s email
line_items: Donation details (name, amount)
mode: “payment” (one-time payment)
success_url: Redirect after successful payment
cancel_url: Redirect if payment is cancelled
- Database Record: Donation entry is added to the
donators array with:
- User reference
- Donated amount
- Stripe transaction ID (session ID)
paymentVerified: false (pending verification)
- Redirect: User receives a Stripe Checkout URL to complete payment
Response
Indicates if the donation was initiated successfully.
A human-readable message with instructions for completing payment.
Stripe checkout session information.Stripe checkout session ID (used as transactionId).
Stripe Checkout URL where the user should complete payment.
Example Request
curl -X PATCH "https://api.example.com/api/church/makedonation/60d5ec49f1b2c72b8c8e4f1a" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"donationId": "60d5ec49f1b2c72b8c8e4f1c",
"useremail": "[email protected]",
"donated": 100
}'
Example Response
{
"success": true,
"message": "Your donation to Building Fund 2026 has been initiated. Kindly visit the url below to complete payment",
"data": {
"Id": "cs_test_a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6q7R8s9T0",
"url": "https://checkout.stripe.com/c/pay/cs_test_a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6q7R8s9T0"
}
}
Error Responses
404 - Below Minimum Amount
{
"success": false,
"message": "Unable to make donation",
"data": "Minimum donation amount is 10"
}
200 - Donation Completed
{
"success": false,
"message": "Unable to make donation",
"data": "The target for this donation has been achieved"
}
200 - Donation Not Open
{
"success": false,
"message": "Unable to make donation",
"data": "This donation is not open yet"
}
400 - Donation Ended
{
"success": false,
"message": "Unable to make donation",
"error": "This donation ended on 12/31/2025"
}
404 - Donation Not Found
{
"success": false,
"message": "Unable to make donation",
"data": "Donation with this Id does not exist"
}
500 - Server Error
{
"success": false,
"message": "Unable to make donation",
"data": "Error message details"
}
Donation Status Validation
The endpoint validates the following conditions before accepting a donation:
- Date Range: Current date must be before the donation’s
endDate
- Donation Status: Must be
"on" (active)
- If
"completed": Returns error that target has been achieved
- If
"off": Returns error that donation is not open
- Minimum Amount: Donated amount must meet
donationMetrics.minAmount
Payment Verification
After the user completes payment on Stripe:
- The donation record will have
paymentVerified: false initially
- A pastor must verify the payment using the
/verifydonation endpoint
- Upon verification,
totalGotten is updated and paymentVerified is set to true
Notes
- The amount is converted to cents for Stripe (
donated * 100)
- The Stripe session ID serves as the
transactionId in the database
- Payment verification is handled separately by pastors
- The
success_url includes the session ID for tracking: {CHECKOUT_SESSION_ID}
- Users can donate multiple times to the same campaign