28 lines
726 B
PHP
28 lines
726 B
PHP
<?php
|
|
|
|
namespace App\Services\Paddle;
|
|
|
|
class PaddleCustomerPortalService
|
|
{
|
|
public function __construct(private readonly PaddleClient $client) {}
|
|
|
|
/**
|
|
* @param array{subscription_ids?: array<int, string>} $options
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function createSession(string $customerId, array $options = []): array
|
|
{
|
|
$payload = [
|
|
'customer_id' => $customerId,
|
|
];
|
|
|
|
if (! empty($options['subscription_ids'])) {
|
|
$payload['subscription_ids'] = array_values(
|
|
array_filter($options['subscription_ids'], 'is_string')
|
|
);
|
|
}
|
|
|
|
return $this->client->post('/customer-portal-sessions', $payload);
|
|
}
|
|
}
|