Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Feb 4, 2024
1 parent 94a6211 commit faad25f
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/StripeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
}
}

0 comments on commit faad25f

Please sign in to comment.