From faad25fc458c1459e8ad1c878133841fa4812d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Sun, 4 Feb 2024 19:14:18 +0100 Subject: [PATCH] wip --- src/StripeDriver.php | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/StripeDriver.php b/src/StripeDriver.php index 5f33de0..4cfd492 100644 --- a/src/StripeDriver.php +++ b/src/StripeDriver.php @@ -2,6 +2,7 @@ namespace Cone\Bazar\Stripe; +use Cone\Bazar\Exceptions\TransactionDriverMismatchException; use Cone\Bazar\Gateway\Driver; use Cone\Bazar\Gateway\Response; use Cone\Bazar\Interfaces\LineItem; @@ -151,4 +152,42 @@ public function handleNotification(Request $request): Response return parent::handleNotification($request); } + + /** + * Handle the manual transaction creation. + */ + public function handleManualTransaction(Transaction $transaction): void + { + match ($transaction->type) { + Transaction::PAYMENT => $this->handleManualPayment($transaction), + Transaction::REFUND => $this->handleManualRefund($transaction), + default => null, + }; + } + + /** + * Handle the manual payment creatiion. + */ + public function handleManualPayment(Transaction $transaction): void + { + // create payment link + } + + /** + * Handle the manual refund creatiion. + */ + public function handleManualRefund(Transaction $transaction): void + { + $payment = $transaction->order->transaction; + + if ($payment->driver !== $transaction->driver) { + throw new TransactionDriverMismatchException(sprintf( + "The refund driver [%s] does not match the base transaction's driver [%s].", + $transaction->driver, + $payment->driver + )); + } + + // create refund + } }