# give/4.17.0/src/Donations/Factories/DonationFactory.php

GiveWP – Donation Plugin and Fundraising Platform, version 4.17.0. 47 lines.

- Page: https://pluginprobe.com/plugins/give/4.17.0/code/src/Donations/Factories/DonationFactory.php
- Raw: https://pluginprobe.com/plugins/give/4.17.0/raw/src/Donations/Factories/DonationFactory.php
- Modified: 2025-03-31T19:17:16+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/give/4.17.0/code/src/Donations/Factories/DonationFactory.php#L10-L20`.

```php
<?php

namespace Give\Donations\Factories;

use Exception;
use Give\Campaigns\Models\Campaign;
use Give\Donations\ValueObjects\DonationMode;
use Give\Donations\ValueObjects\DonationStatus;
use Give\Donations\ValueObjects\DonationType;
use Give\Donors\Models\Donor;
use Give\Framework\Models\Factories\ModelFactory;
use Give\Framework\Support\ValueObjects\Money;
use Give\PaymentGateways\Gateways\TestGateway\TestGateway;

class DonationFactory extends ModelFactory
{

    /**
     * @since 4.0.0 added campaignId
     * @since 2.22.0 add optional support for anonymous and company properties
     * @since 2.20.0 update default donorId to create factory
     * @since 2.19.6
     *
     * @throws Exception
     */
    public function definition(): array
    {
        return [
            'status' => DonationStatus::PENDING(),
            'gatewayId' => TestGateway::id(),
            'mode' => DonationMode::TEST(),
            'type' => DonationType::SINGLE(),
            'amount' => new Money($this->faker->numberBetween(50, 50000), 'USD'),
            'donorId' => Donor::factory()->create()->id,
            'firstName' => $this->faker->firstName,
            'lastName' => $this->faker->lastName,
            'email' => $this->faker->email,
            'campaignId' => 1,
            'formId' => 1,
            'formTitle' => 'Form Title',
            'anonymous' => $this->faker->optional(0.5, false)->boolean(true),
            'company' => $this->faker->optional()->company,
            'comment' => $this->faker->optional()->text,
        ];
    }
}

```
