PlexySDK DOCS
Donations

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

EndpointMethodDescription
/v2/donationsPOSTCreate a one-time donation
/v2/donations/{id}GETRetrieve a donation
/v2/donationsGETList donations
/v2/donations/{id}/refundPOSTRefund a donation
/v2/donations/recurringPOSTCreate a recurring donation
/v2/donations/recurring/{id}GETGet recurring donation details
/v2/donations/recurring/{id}/cancelPOSTCancel 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

ParameterTypeDescription
campaign_idstringFilter by campaign
donor_idstringFilter by donor
statusstringcompleted, failed, refunded
created_afterstringISO 8601 date
created_beforestringISO 8601 date
limitintegerResults per page (max 100)
starting_afterstringCursor 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

FieldTypeRequiredDescription
amount.valueintegerYesAmount in minor units
amount.currencystringYesISO 4217 currency code
donor.emailstringYesDonor's email address
donor.first_namestringYesDonor's first name
donor.last_namestringYesDonor's last name
donor.addressobjectNoDonor's mailing address
payment_methodobjectYesPayment method details
campaign_idstringNoCampaign identifier
dedication.typestringNoin_honor_of or in_memory_of
dedication.namestringNoHonoree/memorial name
dedication.notify_emailstringNoEmail to notify about dedication
dedication.messagestringNoPersonal message
anonymousbooleanNoHide donor name publicly
tax_receipt_requestedbooleanNoGenerate tax receipt
metadataobjectNoCustom key-value data

Recurring Donation Object

Additional fields for recurring donations:

FieldTypeRequiredDescription
intervalstringYesweekly, monthly, quarterly, annually
start_datestringNoISO 8601 date for first charge
end_datestringNoISO 8601 date to stop recurring
max_occurrencesintegerNoMaximum 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:

CodeDescription
card_declinedSuggest trying a different card
invalid_amountAmount below minimum or above maximum
duplicate_donationIdempotency key was reused
campaign_inactiveCampaign has ended or is paused
donor_blockedDonor 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

On this page