Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Feb 9, 2024
1 parent 1a90ec9 commit 3fda624
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/Fields/Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public function fields(Request $request): array
MorphTo::make(__('Buyable Item'), 'buyable')
->required()
->types([
Product::class,
Variant::class,
Product::getProxiedClass(),
Variant::getProxiedClass(),
])
->display(static function (Model $relatable): ?string {
return (string) match ($relatable::class) {
Product::class => $relatable->name,
Variant::class => $relatable->alias,
Product::getProxiedClass() => $relatable->name,
Variant::getProxiedClass() => $relatable->alias,
default => $relatable->getKey(),
};
}),
Expand Down
16 changes: 10 additions & 6 deletions src/Gateway/CashDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,23 @@ class CashDriver extends Driver
*/
public function pay(Order $order, ?float $amount = null, array $attributes = []): Transaction
{
return parent::pay($order, $amount, array_merge($attributes, [
'completed_at' => time(),
]));
$transaction = parent::pay($order, $amount, $attributes);

$transaction->markAsCompleted();

return $transaction;
}

/**
* Process the refund.
*/
public function refund(Order $order, ?float $amount = null, array $attributes = []): Transaction
{
return parent::refund($order, $amount, array_merge($attributes, [
'completed_at' => time(),
]));
$transaction = parent::refund($order, $amount, $attributes);

$transaction->markAsCompleted();

return $transaction;
}

/**
Expand Down

0 comments on commit 3fda624

Please sign in to comment.