API-Only Donations
Build custom donation experiences with full control using Plexy's Donation API
API-Only Donations
For complete control over the donation experience, use Plexy's Donation API directly. This approach allows you to build fully custom donation forms, integrate with existing checkout flows, and implement advanced donation features.
When to Use API-Only
Choose the API-only approach when you need:
- Custom UI that matches your brand exactly
- Integration with existing checkout or CRM systems
- Complex donation workflows (multi-step, conditional logic)
- Server-side donation processing
- Advanced analytics and tracking
API-only integration requires handling card data, which increases your PCI DSS compliance scope (SAQ-A-EP or SAQ-D). Consider using Plexy.js tokenization to reduce your compliance burden.
API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/v2/donations | POST | Create a one-time donation |
/v2/donations/{id} | GET | Retrieve a donation |
/v2/donations | GET | List donations |
/v2/donations/{id}/refund | POST | Refund a donation |
/v2/donations/recurring | POST | Create a recurring donation |
/v2/donations/recurring/{id} | GET | Get recurring donation details |
/v2/donations/recurring/{id}/cancel | POST | Cancel recurring donation |
Create a One-Time Donation
curl -X POST https://api.plexypay.com/v2/donations \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: donation_unique_key_12345" \
-d '{
"amount": {
"value": 5000,
"currency": "KZT"
},
"donor": {
"email": "donor@example.com",
"first_name": "Jane",
"last_name": "Smith",
"address": {
"line1": "123 Main St",
"city": "Almaty",
"postal_code": "050000",
"country": "KZ"
}
},
"payment_method": {
"type": "card",
"card": {
"number": "4111111111111111",
"exp_month": 12,
"exp_year": 2028,
"cvc": "123"
}
},
"campaign_id": "camp_spring_fundraiser",
"dedication": {
"type": "in_memory_of",
"name": "Robert Smith",
"notify_email": "family@example.com",
"message": "In loving memory"
},
"anonymous": false,
"tax_receipt_requested": true,
"metadata": {
"source": "website",
"referrer": "email_campaign_march"
}
}'Response
{
"id": "don_abc123def456",
"object": "donation",
"status": "completed",
"amount": {
"value": 5000,
"currency": "KZT"
},
"net_amount": {
"value": 4850,
"currency": "KZT"
},
"fee": {
"value": 150,
"currency": "KZT"
},
"donor": {
"id": "dnr_xyz789",
"email": "donor@example.com",
"first_name": "Jane",
"last_name": "Smith"
},
"payment_method": {
"type": "card",
"card": {
"brand": "visa",
"last4": "1111",
"exp_month": 12,
"exp_year": 2028
}
},
"campaign_id": "camp_spring_fundraiser",
"dedication": {
"type": "in_memory_of",
"name": "Robert Smith"
},
"anonymous": false,
"tax_receipt_url": "https://receipts.plexy.money/don_abc123def456",
"created_at": "2026-03-25T10:30:00Z"
}Using Tokenized Payment Methods
For reduced PCI scope, tokenize card details first:
<script src="https://js.plexy.money/v2/plexy.js"></script>
<div id="card-element"></div>
<script>
const plexy = Plexy('pb_live_your_public_key');
const cardElement = plexy.elements.create('card');
cardElement.mount('#card-element');
// On form submit
const { token, error } = await plexy.createToken(cardElement);
if (token) {
// Send token.id to your server
await fetch('/api/donate', {
method: 'POST',
body: JSON.stringify({ token_id: token.id, amount: 5000 })
});
}
</script>curl -X POST https://api.plexypay.com/v2/donations \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": {
"value": 5000,
"currency": "KZT"
},
"donor": {
"email": "donor@example.com",
"first_name": "Jane",
"last_name": "Smith"
},
"payment_method": {
"type": "token",
"token_id": "tok_card_visa_4242"
},
"campaign_id": "camp_spring_fundraiser"
}'Create a Recurring Donation
curl -X POST https://api.plexypay.com/v2/donations/recurring \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": {
"value": 2500,
"currency": "KZT"
},
"interval": "monthly",
"donor": {
"email": "supporter@example.com",
"first_name": "Alex",
"last_name": "Johnson"
},
"payment_method": {
"type": "card",
"card": {
"number": "4111111111111111",
"exp_month": 12,
"exp_year": 2028,
"cvc": "123"
}
},
"campaign_id": "camp_monthly_giving",
"start_date": "2026-04-01",
"metadata": {
"signup_source": "website_footer"
}
}'Recurring Donation Response
{
"id": "rdon_abc123def456",
"object": "recurring_donation",
"status": "active",
"amount": {
"value": 2500,
"currency": "KZT"
},
"interval": "monthly",
"donor": {
"id": "dnr_xyz789",
"email": "supporter@example.com",
"first_name": "Alex",
"last_name": "Johnson"
},
"payment_method": {
"type": "card",
"card": {
"brand": "visa",
"last4": "1111"
}
},
"campaign_id": "camp_monthly_giving",
"start_date": "2026-04-01",
"next_payment_date": "2026-04-01",
"total_donated": {
"value": 0,
"currency": "KZT"
},
"donation_count": 0,
"created_at": "2026-03-25T10:30:00Z"
}List Donations
Retrieve donations with filtering and pagination:
curl -X GET "https://api.plexypay.com/v2/donations?campaign_id=camp_spring_fundraiser&created_after=2026-03-01&limit=50" \
-H "x-api-key: YOUR_API_KEY"Query Parameters
| Parameter | Type | Description |
|---|---|---|
campaign_id | string | Filter by campaign |
donor_id | string | Filter by donor |
status | string | completed, failed, refunded |
created_after | string | ISO 8601 date |
created_before | string | ISO 8601 date |
limit | integer | Results per page (max 100) |
starting_after | string | Cursor for pagination |
Refund a Donation
curl -X POST https://api.plexypay.com/v2/donations/don_abc123def456/refund \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": {
"value": 5000,
"currency": "KZT"
},
"reason": "donor_request",
"notify_donor": true
}'Cancel Recurring Donation
curl -X POST https://api.plexypay.com/v2/donations/recurring/rdon_abc123def456/cancel \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"reason": "donor_request",
"notify_donor": true
}'Request Parameters Reference
Donation Object
| Field | Type | Required | Description |
|---|---|---|---|
amount.value | integer | Yes | Amount in minor units |
amount.currency | string | Yes | ISO 4217 currency code |
donor.email | string | Yes | Donor's email address |
donor.first_name | string | Yes | Donor's first name |
donor.last_name | string | Yes | Donor's last name |
donor.address | object | No | Donor's mailing address |
payment_method | object | Yes | Payment method details |
campaign_id | string | No | Campaign identifier |
dedication.type | string | No | in_honor_of or in_memory_of |
dedication.name | string | No | Honoree/memorial name |
dedication.notify_email | string | No | Email to notify about dedication |
dedication.message | string | No | Personal message |
anonymous | boolean | No | Hide donor name publicly |
tax_receipt_requested | boolean | No | Generate tax receipt |
metadata | object | No | Custom key-value data |
Recurring Donation Object
Additional fields for recurring donations:
| Field | Type | Required | Description |
|---|---|---|---|
interval | string | Yes | weekly, monthly, quarterly, annually |
start_date | string | No | ISO 8601 date for first charge |
end_date | string | No | ISO 8601 date to stop recurring |
max_occurrences | integer | No | Maximum number of donations |
Error Handling
curl -X POST https://api.plexypay.com/v2/donations \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: donation_unique_key_12345" \
-d '{
"amount": { "value": 5000, "currency": "KZT" },
"donor": { "email": "donor@example.com", "first_name": "Jane", "last_name": "Smith" },
"payment_method": { "type": "token", "token_id": "tok_card_visa_4242" },
"campaign_id": "camp_spring_fundraiser"
}'When the API returns a non-2xx status, the response body contains an error object with a code field. Handle the following codes in your application logic:
| Code | Description |
|---|---|
card_declined | Suggest trying a different card |
invalid_amount | Amount below minimum or above maximum |
duplicate_donation | Idempotency key was reused |
campaign_inactive | Campaign has ended or is paused |
donor_blocked | Donor is on the blocklist |
Webhook Integration
Set up webhooks to receive real-time donation notifications. Plexy sends an inbound POST request to your configured endpoint whenever a donation event occurs:
curl -X POST https://your-app.example.com/webhooks/plexy \
-H "Plexy-Signature: t=1716640000,v1=ab12cd34ef5678..." \
-H "Content-Type: application/json" \
-d '{
"type": "donation.completed",
"data": {
"id": "don_abc123def456",
"status": "completed",
"amount": { "value": 5000, "currency": "KZT" },
"donor": { "id": "dnr_xyz789", "email": "donor@example.com" },
"campaign_id": "camp_spring_fundraiser",
"tax_receipt_url": "https://receipts.plexy.money/don_abc123def456"
}
}'Other event types sent to your endpoint: donation.failed, donation.recurring.payment, donation.recurring.failed.
Verify the signature
Compute HMAC-SHA256(<raw request body>, <your webhook secret>), hex-encode the result, and compare against the v1= value in the Plexy-Signature header using a constant-time comparison. Reject the request if they differ.
Next Steps
- Testing Donations - Test your API integration
- Donation Webhooks - Handle donation events
- Terms and Conditions - Compliance requirements