apiKey = $apiKey; } public function charge($amount, $token) { try { Charge::create([ 'amount' => $amount, 'source' => $token, 'currency' => 'usd', ], ['api_key' => $this->apiKey]); } catch (InvalidRequest $e) { throw new PaymentFailedException; } } }