From 3365e93da07fb24a2d1956bb4f0f55533006ced8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 18 Dec 2023 15:37:03 +1100 Subject: [PATCH] Clean up --- app/PaymentDrivers/Stripe/ACSS.php | 12 +++++------- app/PaymentDrivers/Stripe/Charge.php | 7 ++----- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/PaymentDrivers/Stripe/ACSS.php b/app/PaymentDrivers/Stripe/ACSS.php index e246ee5b18..07b88f3e02 100644 --- a/app/PaymentDrivers/Stripe/ACSS.php +++ b/app/PaymentDrivers/Stripe/ACSS.php @@ -137,7 +137,7 @@ class ACSS * Generates a token Payment Intent * * @param ClientGatewayToken $token - * @return void + * @return PaymentIntent */ private function tokenIntent(ClientGatewayToken $token): PaymentIntent { @@ -223,7 +223,6 @@ class ACSS * Continues the payment flow after a Mandate has been successfully generated * * @param array $data - * @return void */ private function continuePayment(array $data) { @@ -260,7 +259,7 @@ class ACSS /** * PaymentResponseRequest * - * @param mixed $request + * @param PaymentResponseRequest $request */ public function paymentResponse(PaymentResponseRequest $request) { @@ -269,7 +268,7 @@ class ACSS $cgt = ClientGatewayToken::find($this->decodePrimaryKey($request->token)); - /** @var Stripe\PaymentIntent $intent */ + /** @var \Stripe\PaymentIntent $intent */ $intent = $this->tokenIntent($cgt); $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $request->all()); @@ -298,7 +297,7 @@ class ACSS $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $stripe_amount]); $this->stripe->payment_hash->save(); - /** @var Stripe\PaymentIntent $intent */ + /** @var \Stripe\PaymentIntent $intent */ $intent = $this->tokenIntent($cgt); if ($intent->status && $intent->status == 'processing') { @@ -316,9 +315,8 @@ class ACSS * Creates a payment for the transaction * * @param string $payment_intent - * @return Illuminate\Http\RedirectResponse */ - public function processSuccessfulPayment(string $payment_intent): \Illuminate\Http\RedirectResponse + public function processSuccessfulPayment(string $payment_intent) { $data = [ 'payment_method' => $payment_intent, diff --git a/app/PaymentDrivers/Stripe/Charge.php b/app/PaymentDrivers/Stripe/Charge.php index bc42fd96e8..513a23adfd 100644 --- a/app/PaymentDrivers/Stripe/Charge.php +++ b/app/PaymentDrivers/Stripe/Charge.php @@ -102,12 +102,9 @@ class Charge ]; switch ($e) { + /** @var \Stripe\Exception\CardException $e */ case $e instanceof CardException: - $data['status'] = $e->getHttpStatus(); - $data['error_type'] = $e->getError()->type; - $data['error_code'] = $e->getError()->code; - $data['param'] = $e->getError()->param; - $data['message'] = $e->getError()->message; + $data['message'] = $e->getError()->message ?? $e->getMessage(); break; case $e instanceof RateLimitException: $data['message'] = 'Too many requests made to the API too quickly';