Skip to main content
PATCH
/
api
/
church
/
makedonation
/
:id
Make Donation
curl --request PATCH \
  --url https://api.example.com/api/church/makedonation/:id \
  --header 'Content-Type: application/json' \
  --data '
{
  "donationId": "<string>",
  "useremail": "<string>",
  "donated": 123
}
'
{
  "success": true,
  "message": "<string>",
  "data": {
    "data.Id": "<string>",
    "data.url": "<string>"
  }
}

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

id
string
required
The unique identifier of the user making the donation (typically the authenticated user’s profile ID).

Request Body

donationId
string
required
The unique identifier (ObjectId) of the donation campaign to contribute to.
useremail
string
required
The email address of the donor. Used by Stripe for the checkout session and receipts.
donated
number
required
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:
  1. Validation: The system checks donation status, date range, and minimum amount
  2. 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
  3. Database Record: Donation entry is added to the donators array with:
    • User reference
    • Donated amount
    • Stripe transaction ID (session ID)
    • paymentVerified: false (pending verification)
  4. Redirect: User receives a Stripe Checkout URL to complete payment

Response

success
boolean
Indicates if the donation was initiated successfully.
message
string
A human-readable message with instructions for completing payment.
data
object
Stripe checkout session information.
data.Id
string
Stripe checkout session ID (used as transactionId).
data.url
string
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:
  1. Date Range: Current date must be before the donation’s endDate
  2. Donation Status: Must be "on" (active)
    • If "completed": Returns error that target has been achieved
    • If "off": Returns error that donation is not open
  3. Minimum Amount: Donated amount must meet donationMetrics.minAmount

Payment Verification

After the user completes payment on Stripe:
  1. The donation record will have paymentVerified: false initially
  2. A pastor must verify the payment using the /verifydonation endpoint
  3. 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

Build docs developers (and LLMs) love