Skip to content

Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.

865 B
Raw Blame
<?php

declare(strict_types=1);

namespace App\Support\Billing;

use Carbon\CarbonImmutable;
use Illuminate\Support\Str;

/**
 * Reads the raw values of a Stripe payload, null when a value is missing or
 * not of the type Stripe sends.
 */
final class StripeValue
{
    /**
     * Stripe sends amounts in cents; TryPost charges in BRL, USD and EUR only,
     * all with two decimals.
     */
    public static function amount(mixed $cents): ?float
    {
        return is_int($cents) ? $cents / 100 : null;
    }

    public static function currency(mixed $currency): ?string
    {
        return is_string($currency) && filled($currency) ? Str::upper($currency) : null;
    }

    public static function timestamp(mixed $seconds): ?CarbonImmutable
    {
        return is_numeric($seconds) ? CarbonImmutable::createFromTimestampUTC((int) $seconds) : null;
    }
}