Skip to main content
PATCH
/
api
/
church
/
editdonationstatus
Edit Donation Status
curl --request PATCH \
  --url https://api.example.com/api/church/editdonationstatus \
  --header 'Content-Type: application/json' \
  --data '
{
  "donationId": "<string>",
  "churchId": "<string>",
  "status": {}
}
'
{
  "success": true,
  "message": "<string>",
  "data": {
    "data._id": "<string>",
    "data.church": "<string>",
    "data.donationName": "<string>",
    "data.donationStatus": {},
    "data.startDate": "<string>",
    "data.endDate": "<string>",
    "data.donationDescription": "<string>",
    "data.bankDetails": {},
    "data.donationSupportContact": {},
    "data.donationMetrics": {},
    "data.createdAt": "<string>",
    "data.updatedAt": "<string>"
  }
}

Authentication

This endpoint requires:
  • Valid JWT token in Authorization header
  • User role must be pastor

Endpoint

PATCH /api/church/editdonationstatus

Request Body

donationId
string
required
The unique identifier (ObjectId) of the donation campaign to update.
churchId
string
required
The unique identifier (ObjectId) of the church that owns the donation. Used for validation.
status
enum
required
The new status for the donation. Must be one of:
  • "on" - Activate the donation (allows new contributions)
  • "off" - Deactivate the donation (temporarily pause contributions)
  • "completed" - Mark the donation as completed (prevents new contributions)

Donation Status Details

”on” - Active

  • Donation is open and accepting contributions
  • Users can initiate payments through the /makedonation endpoint
  • Typically used when the campaign is running and needs funds

”off” - Inactive/Paused

  • Donation is temporarily closed
  • Users cannot make contributions
  • Useful for pausing campaigns without deleting them
  • Can be reactivated by setting status back to “on"

"completed” - Completed

  • Donation has reached its target or ended
  • Users cannot make contributions
  • Indicates the campaign is finished
  • Typically a final status (though can be changed if needed)

Response

success
boolean
Indicates if the status was updated successfully.
message
string
A human-readable message describing the result.
data
object
The updated donation object (without donators array).
data._id
string
Unique identifier for the donation.
data.church
string
Reference to the church ObjectId.
data.donationName
string
Name of the donation campaign.
data.donationStatus
enum
Updated status: “on”, “off”, or “completed”.
data.startDate
date
Campaign start date.
data.endDate
date
Campaign end date.
data.donationDescription
string
Description of the donation purpose.
data.bankDetails
object
Bank account information.
data.donationSupportContact
object
Contact information for support.
data.donationMetrics
object
Financial metrics for the campaign.
data.createdAt
date
Timestamp when the donation was created.
data.updatedAt
date
Timestamp of last update (reflects status change).

Example Request

curl -X PATCH "https://api.example.com/api/church/editdonationstatus" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "donationId": "60d5ec49f1b2c72b8c8e4f1c",
    "churchId": "60d5ec49f1b2c72b8c8e4f1b",
    "status": "completed"
  }'

Example Response

{
  "success": true,
  "message": "Donation status changed",
  "data": {
    "_id": "60d5ec49f1b2c72b8c8e4f1c",
    "church": "60d5ec49f1b2c72b8c8e4f1b",
    "donationName": "Building Fund 2026",
    "donationStatus": "completed",
    "startDate": "2026-04-01T00:00:00.000Z",
    "endDate": "2026-12-31T23:59:59.000Z",
    "donationDescription": "Fundraising for new church building construction",
    "bankDetails": {
      "accountName": "First Baptist Church",
      "accountNumber": "1234567890",
      "bankName": "Community Bank"
    },
    "donationSupportContact": {
      "phone": "+1-555-0123",
      "email": "[email protected]"
    },
    "donationMetrics": {
      "targetAmount": 500000,
      "minAmount": 10,
      "totalGotten": 500000
    },
    "createdAt": "2026-03-07T10:30:00.000Z",
    "updatedAt": "2026-03-07T15:45:00.000Z"
  }
}

Error Responses

400 - Invalid Status

{
  "success": false,
  "message": "Unable to edit donation status",
  "data": "Donation status must be on, off or completed"
}

400 - Donation Not Found

{
  "success": false,
  "message": "Unable to edit donation status",
  "data": "Donation not found"
}

500 - Server Error

{
  "success": false,
  "message": "Unable to edit donation status",
  "data": "Error message details"
}

Use Cases

Activate a Donation

{
  "donationId": "60d5ec49f1b2c72b8c8e4f1c",
  "churchId": "60d5ec49f1b2c72b8c8e4f1b",
  "status": "on"
}
Use when starting a new campaign or resuming a paused one.

Pause a Donation

{
  "donationId": "60d5ec49f1b2c72b8c8e4f1c",
  "churchId": "60d5ec49f1b2c72b8c8e4f1b",
  "status": "off"
}
Use when temporarily stopping donations (e.g., during review or between campaign phases).

Complete a Donation

{
  "donationId": "60d5ec49f1b2c72b8c8e4f1c",
  "churchId": "60d5ec49f1b2c72b8c8e4f1b",
  "status": "completed"
}
Use when the fundraising goal is achieved or the campaign has ended.

Validation

The endpoint validates:
  1. Status Value: Must be exactly “on”, “off”, or “completed” (case-sensitive)
  2. Donation Exists: The donation must exist in the database
  3. Church Match: The donation must belong to the specified church
  4. Authorization: User must have pastor role (enforced by middleware)

Notes

  • Only pastors can edit donation status (role-based authorization)
  • The churchId parameter ensures pastors can only modify donations for their churches
  • Status changes are immediate and affect the /makedonation endpoint behavior
  • The donators array is excluded from the response for performance
  • The updatedAt timestamp is automatically updated when status changes
  • Status can be changed multiple times (e.g., from “completed” back to “on” if needed)
  • No email notifications are sent when status changes (implement separately if needed)

Build docs developers (and LLMs) love