<?php

namespace App\Services\Payments;

use App\Contracts\PaymentGatewayInterface;

class PayoutService
{
    protected PaymentGatewayInterface $gateway;

    public function __construct(PaymentGatewayInterface $gateway)
    {
        $this->gateway = $gateway;
    }

    /**
     * Transfer funds to a connected account.
     *
     * Example $data structure:
     * [
     *     'amount' => 5000, // in cents
     *     'currency' => 'usd',
     *     'destination_account_id' => 'acct_1ABCXYZ...',
     *     'description' => 'Loaner Invoice Payment',
     *     'metadata' => [
     *          'type' => 'Loaner Invoice',
     *          'payment_type' => Full-Payment,
     *          'billing_request_id' => 1,
     *          'billing_invoice' => 'IVN-2025-07-11-07-33-41-vy8dOlbAxX',
     *          'company_id' => 1,
     *     ]
     * ]
     *
     * @param array $data
     * @return array Stripe Transfer object as array
     *
     * @throws \Exception|\Stripe\Exception\ApiErrorException
     */
    public function transferToConnectedAccount(array $data): array
    {
        return $this->gateway->transferToConnectedAccount($data);
    }
}
