# give/4.18.0/src/PaymentGateways/Gateways/Stripe/Actions/AddExtraMetadataToPaymentIntent.php

GiveWP – Donation Plugin and Fundraising Platform, version 4.18.0. 38 lines.

- Page: https://pluginprobe.com/plugins/give/4.18.0/code/src/PaymentGateways/Gateways/Stripe/Actions/AddExtraMetadataToPaymentIntent.php
- Raw: https://pluginprobe.com/plugins/give/4.18.0/raw/src/PaymentGateways/Gateways/Stripe/Actions/AddExtraMetadataToPaymentIntent.php
- Modified: 2026-08-20T18:04: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.18.0/code/src/PaymentGateways/Gateways/Stripe/Actions/AddExtraMetadataToPaymentIntent.php#L10-L20`.

```php
<?php

namespace Give\PaymentGateways\Gateways\Stripe\Actions;

use Give\Donations\Models\Donation;

/**
 * Adds extra metadata to the transaction sent to Stripe.
 *
 * @since 4.16.7
 */
class AddExtraMetadataToPaymentIntent
{
    /**
     * Stripe rejects metadata values longer than 500 characters.
     */
    const MAX_LENGTH = 500;

    /**
     * @since 4.16.7
     */
    public function __invoke(array $metadata, int $donationId): array
    {
        $donation = Donation::find($donationId);
        $campaign = $donation ? $donation->campaign : null;

        if (!$campaign || empty($campaign->title)) {
            return $metadata;
        }

        $metadata['Campaign Name'] = mb_strlen($campaign->title) > self::MAX_LENGTH
            ? mb_substr($campaign->title, 0, self::MAX_LENGTH - 3) . '...'
            : $campaign->title;

        return $metadata;
    }
}

```
