*/ public array $statuses = []; /** @var list */ public array $created = []; /** @var list */ public array $links = []; /** @var list */ public array $fpxRequested = []; public int $statusCalls = 0; public bool $down = false; public function create(Store $store, string $email): string { $this->failIfDown(); $id = 'acct_fake_'.$store->id; $this->created[] = $id; $this->statuses[$id] ??= new MerchantAccountStatus(false, false, false); return $id; } public function setupLink(string $accountId, string $returnUrl, string $refreshUrl): string { $this->failIfDown(); $this->links[] = ['account' => $accountId, 'return' => $returnUrl, 'refresh' => $refreshUrl]; return 'https://connect.stripe.test/setup/'.$accountId; } public function status(string $accountId): MerchantAccountStatus { $this->failIfDown(); $this->statusCalls++; return $this->statuses[$accountId] ?? throw new PaymentException('Unknown account.'); } public function requestFpx(string $accountId): void { $this->failIfDown(); $this->fpxRequested[] = $accountId; } /** * Pretend the merchant finished Stripe's form and Stripe approved the account. */ public function approve(string $accountId, bool $payouts = true): void { $this->statuses[$accountId] = new MerchantAccountStatus(true, $payouts, true); } private function failIfDown(): void { if ($this->down) { throw new PaymentException('Stripe is down.'); } } }