# ivyforms/1.5/backend/src/ValueObjects/Form/PaymentSettings.php

The Innovative Form Builder – IvyForms, version 1.5. 55 lines.

- Page: https://pluginprobe.com/plugins/ivyforms/1.5/code/backend/src/ValueObjects/Form/PaymentSettings.php
- Raw: https://pluginprobe.com/plugins/ivyforms/1.5/raw/backend/src/ValueObjects/Form/PaymentSettings.php
- Modified: 2026-06-22T13:19:22+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/ivyforms/1.5/code/backend/src/ValueObjects/Form/PaymentSettings.php#L10-L20`.

```php
<?php

namespace IvyForms\ValueObjects\Form;

use IvyForms\Common\Constants\SupportedCurrencyCodes;
use IvyForms\Services\Template\TemplateDefaults;

/**
 * Form-level payment display settings (currency for product fields, totals, etc.).
 */
final class PaymentSettings
{
    private string $currency;

    /**
     * @param array<string, mixed>|null $settings Raw settings (typically already sanitized).
     */
    public function __construct($settings = null)
    {
        if (!is_array($settings) || empty($settings)) {
            $settings = TemplateDefaults::getDefaultPaymentSettings();
        }

        $code = isset($settings['currency'])
            ? strtoupper(trim((string) $settings['currency']))
            : SupportedCurrencyCodes::DEFAULT_CODE;
        $this->currency = SupportedCurrencyCodes::isAllowed($code) ? $code : SupportedCurrencyCodes::DEFAULT_CODE;
    }

    public function getCurrency(): string
    {
        return $this->currency;
    }

    public function setCurrency(string $code): void
    {
        $normalized = strtoupper(trim($code));
        $this->currency = SupportedCurrencyCodes::isAllowed($normalized)
            ? $normalized
            : SupportedCurrencyCodes::DEFAULT_CODE;
    }

    /**
     * @return mixed[]
     */
    public function toArray(): array
    {
        return [
            'paymentSettings' => [
                'currency' => $this->currency,
            ],
        ];
    }
}

```
