Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Feb 20, 2024
1 parent 1d2ad9b commit 7a9ab4a
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/StripeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function handleManualRefund(Transaction $transaction): void
],
]);

$transaction->setAttribute('key', $refund->id)->markAsCompleted();
$transaction->setAttribute('key', $refund->id)->save();
}

/**
Expand Down Expand Up @@ -246,15 +246,20 @@ public function handleIrn(Event $event): void
$order = $this->resolveOrderForNotification($event);

foreach ($event->data['object']['refunds']['data'] as $refund) {
if (is_null($order->transactions->firstWhere('key', $refund['id']))) {
$transaction = $this->refund(
$order,
$refund['amount'] / 100,
['key' => $refund['id']]
);

$transaction->markAsCompleted();
}
$transaction = $order->refunds->first(
static function (Transaction $transaction) use ($refund): bool {
return $transaction->key === $refund['id'];
},
function () use ($order, $refund): Transaction {
return $this->refund(
$order,
$refund['amount'] / 100,
['key' => $refund['id']]
);
}
);

$transaction->markAsCompleted();
}
}
}

0 comments on commit 7a9ab4a

Please sign in to comment.