src/includes/classes/Core/Utils/Stripe.php
protected function parseArgs(string $func, array $args): array
    {
        $default_api_key = $this->App->Config->©stripe['©secret_key'];
        $api_key         = (string) ($args['api_key'] ?? '');
        $api_key         = $api_key ?: $default_api_key;
        unset($args['api_key']); // Ditch this now.

        // NOTE: The number `500` in clipping below comes
        // from a limit imposed by the Stripe API for metadata.

        foreach ($args as $_key => &$_value) {
            if ($_key === 'amount') {
                $_value    = (float) $_value;
                $_currency = (string) ($args['currency'] ?? '');
                $_currency = mb_substr(mb_strtoupper($_currency), 0, 3);
                $_value    = $this->unitAmount($_value, $_currency);
                //
            } elseif ($_key === 'currency') {
                $_value = mb_substr(mb_strtoupper((string) $_value), 0, 3);
                //
            } elseif ($_key === 'metadata') {
                if (is_object($_value)) {
                    $_value = (array) $_value;
                } elseif (!is_array($_value)) {
                    $_value = [];
                } // Forces an array value.

                foreach ($_value as $__key => &$__value) {
                    $__value = $this->c::clip((string) $__value, 500);
                } // Must unset value in sub-loop by reference.
                unset($__key, $__value); // Housekeeping.
                //
            } elseif (in_array($_key, ['update_existing', 'is_default_source'], true)) {
                $_value = (bool) $_value; // Booleans.
                //
            } elseif (in_array($_key, ['trial_period_days', 'interval_count'], true)) {
                $_value = (int) $_value; // Integers.
                //
            } else {  // Everything else becomes a string.
                $_value = (string) $_value; // Force string value.
                if (!in_array($_key, ['customer', 'charge', 'subscription', 'plan', 'source', 'interval', 'currency'], true)) {
                    $_value = $this->c::clip($_value, 500); // Max of 500 chars.
                }
            }
        } // Must unset value by reference.
        unset($_key, $_value, $_currency); // Housekeeping.

        return $data = [
            'args' => $args,
            'opts' => [
                'api_key'        => $api_key,
                'stripe_version' => $this::API_VERSION,
            ],
        ];
    }
protected function parseArgs(string $func, array $args): array
    {
        $default_api_key = $this->App->Config->©stripe['©secret_key'];
        $api_key         = (string) ($args['api_key'] ?? '');
        $api_key         = $api_key ?: $default_api_key;
        unset($args['api_key']); // Ditch this now.

        // NOTE: The number `500` in clipping below comes
        // from a limit imposed by the Stripe API for metadata.

        foreach ($args as $_key => &$_value) {
            if ($_key === 'amount') {
                $_value    = (float) $_value;
                $_currency = (string) ($args['currency'] ?? '');
                $_currency = mb_substr(mb_strtoupper($_currency), 0, 3);
                $_value    = $this->unitAmount($_value, $_currency);
                //
            } elseif ($_key === 'currency') {
                $_value = mb_substr(mb_strtoupper((string) $_value), 0, 3);
                //
            } elseif ($_key === 'metadata') {
                if (is_object($_value)) {
                    $_value = (array) $_value;
                } elseif (!is_array($_value)) {
                    $_value = [];
                } // Forces an array value.

                foreach ($_value as $__key => &$__value) {
                    $__value = $this->c::clip((string) $__value, 500);
                } // Must unset value in sub-loop by reference.
                unset($__key, $__value); // Housekeeping.
                //
            } elseif (in_array($_key, ['update_existing', 'is_default_source'], true)) {
                $_value = (bool) $_value; // Booleans.
                //
            } elseif (in_array($_key, ['trial_period_days', 'interval_count'], true)) {
                $_value = (int) $_value; // Integers.
                //
            } else {  // Everything else becomes a string.
                $_value = (string) $_value; // Force string value.
                if (!in_array($_key, ['customer', 'charge', 'subscription', 'plan', 'source', 'interval', 'currency'], true)) {
                    $_value = $this->c::clip($_value, 500); // Max of 500 chars.
                }
            }
        } // Must unset value by reference.
        unset($_key, $_value, $_currency); // Housekeeping.

        return $data = [
            'args' => $args,
            'opts' => [
                'api_key'        => $api_key,
                'stripe_version' => $this::API_VERSION,
            ],
        ];
    }
Argument parser.

@since 170329.13807 Stripe utils.

@param string $func Function.
@param array  $args Request args.

@return array ['args' => [], 'opts' => []]