PlexySDK DOCS
Donations

Testing Donations

Test your donation integration in test mode with test cards, webhooks, and simulation scenarios

Testing Donations

Before going live with your donation integration, thoroughly test all scenarios in Plexy's test environment. This guide covers test credentials, test cards, and how to simulate various donation scenarios.

Test Environment

All testing should be done in test mode using test API keys.

Test API keys start with pr_ (secret) and pb_test_ (public). Never use production keys (pr_, pb_live_) for testing.

Test Base URL

All test API requests should use:

https://api.plexypay.com/v2

The API automatically routes to the test environment based on your test API key.

Test Cards

Use these test card numbers to simulate various scenarios:

Successful Donations

Card NumberBrandScenario
4111 1111 1111 1111VisaSuccessful donation
5500 0000 0000 0004MastercardSuccessful donation
3400 000000 00009American ExpressSuccessful donation
4000 0000 0000 0077VisaSuccessful with 3D Secure

Declined Cards

Card NumberBrandDecline Reason
4000 0000 0000 0002VisaGeneric decline
4000 0000 0000 9995VisaInsufficient funds
4000 0000 0000 9987VisaLost card
4000 0000 0000 9979VisaStolen card
4000 0000 0000 0069VisaExpired card
4000 0000 0000 0127VisaInvalid CVC

Special Scenarios

Card NumberScenario
4000 0000 0000 32203D Secure 2 authentication required
4000 0000 0000 30633D Secure authentication fails
4000 0000 0000 0259Delayed success (webhook arrives later)
4000 0000 0000 0341Attach card fails during tokenization

Test Card Details

For all test cards, use:

  • Expiration date: Any future date (e.g., 12/28)
  • CVC: Any 3 digits (e.g., 123) or 4 digits for Amex
  • Cardholder name: Any name
  • Address: Any valid address format

Testing Scenarios

One-Time Donation

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": "test@example.com",
      "first_name": "Test",
      "last_name": "Donor"
    },
    "payment_method": {
      "type": "card",
      "card": {
        "number": "4111111111111111",
        "exp_month": 12,
        "exp_year": 2028,
        "cvc": "123"
      }
    },
    "campaign_id": "camp_test_campaign"
  }'
{
  "id": "don_test_abc123",
  "status": "completed",
  "amount": {
    "value": 5000,
    "currency": "KZT"
  }
}

Verify that your webhook endpoint received the donation.completed event.

Declined Donation

Test your error handling with a decline scenario:

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": "test@example.com",
      "first_name": "Test",
      "last_name": "Donor"
    },
    "payment_method": {
      "type": "card",
      "card": {
        "number": "4000000000000002",
        "exp_month": 12,
        "exp_year": 2028,
        "cvc": "123"
      }
    }
  }'

Expected response:

{
  "error": {
    "type": "card_error",
    "code": "card_declined",
    "message": "Your card was declined.",
    "decline_code": "generic_decline"
  }
}

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": "recurring@example.com",
      "first_name": "Monthly",
      "last_name": "Donor"
    },
    "payment_method": {
      "type": "card",
      "card": {
        "number": "4111111111111111",
        "exp_month": 12,
        "exp_year": 2028,
        "cvc": "123"
      }
    }
  }'

In test mode, you can manually trigger the next recurring payment:

curl -X POST https://api.plexypay.com/v2/donations/recurring/rdon_test_abc123/trigger \
  -H "x-api-key: YOUR_API_KEY"

Check for donation.recurring.payment webhook event.

Donation with 3D Secure

Test 3D Secure authentication flow:

curl -X POST https://api.plexypay.com/v2/donations \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": {
      "value": 10000,
      "currency": "KZT"
    },
    "donor": {
      "email": "3ds@example.com",
      "first_name": "Secure",
      "last_name": "Donor"
    },
    "payment_method": {
      "type": "card",
      "card": {
        "number": "4000000000003220",
        "exp_month": 12,
        "exp_year": 2028,
        "cvc": "123"
      }
    },
    "return_url": "https://yoursite.com/donation/complete"
  }'

Response requiring authentication:

{
  "id": "don_test_3ds_abc123",
  "status": "requires_action",
  "next_action": {
    "type": "redirect_to_url",
    "redirect_to_url": {
      "url": "https://checkout.plexy.money/3ds/authenticate/...",
      "return_url": "https://yoursite.com/donation/complete"
    }
  }
}

In test mode, the 3D Secure page auto-completes. In production, the donor must authenticate with their bank.

Refund a Donation

# First, create a donation
DONATION_ID=$(curl -s -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": "refund@example.com", "first_name": "Refund", "last_name": "Test"},
    "payment_method": {"type": "card", "card": {"number": "4111111111111111", "exp_month": 12, "exp_year": 2028, "cvc": "123"}}
  }' | jq -r '.id')

# Then refund it
curl -X POST "https://api.plexypay.com/v2/donations/$DONATION_ID/refund" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": {"value": 5000, "currency": "KZT"},
    "reason": "donor_request"
  }'

Testing Webhooks

Using Plexy CLI

The Plexy CLI can forward webhooks to your local development server:

# Install Plexy CLI
npm install -g @plexy/cli

# Login to your account
plexy login

# Forward webhooks to localhost
plexy webhooks forward --to http://localhost:3000/webhooks/plexy

Webhook Test Events

Trigger test webhook events from the Dashboard or API:

curl -X POST https://api.plexypay.com/v2/webhooks/test \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "endpoint_id": "we_abc123",
    "event_type": "donation.completed"
  }'

Webhook Event Examples

donation.completed

{
  "id": "evt_test_123",
  "type": "donation.completed",
  "created_at": "2026-03-25T10:30:00Z",
  "data": {
    "id": "don_test_abc123",
    "object": "donation",
    "status": "completed",
    "amount": {
      "value": 5000,
      "currency": "KZT"
    },
    "donor": {
      "id": "dnr_test_xyz789",
      "email": "test@example.com",
      "first_name": "Test",
      "last_name": "Donor"
    },
    "campaign_id": "camp_test_campaign",
    "tax_receipt_url": "https://receipts.plexy.money/don_test_abc123"
  }
}

donation.failed

{
  "id": "evt_test_456",
  "type": "donation.failed",
  "created_at": "2026-03-25T10:30:00Z",
  "data": {
    "id": "don_test_failed123",
    "object": "donation",
    "status": "failed",
    "amount": {
      "value": 5000,
      "currency": "KZT"
    },
    "failure_code": "card_declined",
    "failure_message": "Your card was declined."
  }
}

donation.recurring.payment

{
  "id": "evt_test_789",
  "type": "donation.recurring.payment",
  "created_at": "2026-04-01T00:00:00Z",
  "data": {
    "recurring_donation_id": "rdon_test_abc123",
    "donation_id": "don_test_recurring_456",
    "amount": {
      "value": 2500,
      "currency": "KZT"
    },
    "occurrence_number": 2,
    "next_payment_date": "2026-05-01"
  }
}

Testing Checklist

Use this checklist to ensure comprehensive test coverage:

Basic Functionality

  • One-time donation with valid card succeeds
  • Donation amount is correctly recorded
  • Donor information is captured
  • Tax receipt URL is generated
  • Webhook donation.completed is received

Error Handling

  • Declined card shows appropriate error
  • Expired card is rejected
  • Invalid CVC is caught
  • Insufficient funds error is handled
  • Network errors are handled gracefully

Recurring Donations

  • Recurring donation is created successfully
  • Subsequent payments are processed
  • Failed recurring payment triggers webhook
  • Cancellation works correctly
  • Donor can update payment method

3D Secure

  • 3DS challenge is displayed when required
  • Successful authentication completes donation
  • Failed authentication is handled
  • Frictionless 3DS works correctly

Refunds

  • Full refund processes correctly
  • Partial refund is supported
  • Refund webhook is received
  • Donor receives refund notification

Edge Cases

  • Minimum donation amount is enforced
  • Maximum donation amount is enforced
  • Duplicate donation prevention works
  • Campaign-specific restrictions apply
  • Anonymous donation hides donor info

Test Data Cleanup

Test data is automatically cleaned up after 30 days. To manually clean up test data:

curl -X DELETE https://api.plexypay.com/v2/test/donations \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "created_before": "2026-03-01"
  }'

This endpoint is only available in test mode and will delete all test donations matching the criteria.

Moving to Production

Once testing is complete:

Replace test API keys with production keys: - pr_... → pr_... - pb_test_... → pb_live_...

Configure production webhook URLs in the Dashboard.

Next Steps

On this page