Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| CreateSetupIntentAction | |
100.00% |
7 / 7 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __invoke | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Action\Investor; |
| 6 | |
| 7 | use App\Domain\Stripe\Service\InvestorStripeService; |
| 8 | use App\Renderer\JsonRenderer; |
| 9 | use App\Support\Row; |
| 10 | use Psr\Http\Message\ResponseInterface; |
| 11 | use Psr\Http\Message\ServerRequestInterface; |
| 12 | |
| 13 | /** |
| 14 | * POST /api/investor/payment-methods/setup-intent |
| 15 | * |
| 16 | * Returns a Stripe SetupIntent client_secret. The frontend uses it with |
| 17 | * Stripe.js to securely capture card details — FlowState never sees the |
| 18 | * card number, just the resulting PaymentMethod ID retrievable later via |
| 19 | * the list endpoint. |
| 20 | */ |
| 21 | final readonly class CreateSetupIntentAction |
| 22 | { |
| 23 | public function __construct( |
| 24 | private InvestorStripeService $service, |
| 25 | private JsonRenderer $renderer, |
| 26 | ) {} |
| 27 | |
| 28 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface |
| 29 | { |
| 30 | $investorId = Row::int($request->getAttributes(), 'investorId'); |
| 31 | |
| 32 | $clientSecret = $this->service->createSetupIntentClientSecret($investorId); |
| 33 | |
| 34 | return $this->renderer->json($response, [ |
| 35 | 'success' => true, |
| 36 | 'data' => ['clientSecret' => $clientSecret], |
| 37 | ]); |
| 38 | } |
| 39 | } |