Skip to content

Commit 0b67757

Browse files
committed
Clear order's gateway data when Mollie payment expires
1 parent 6117a07 commit 0b67757

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

src/Data/HasData.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ public function merge($data): self
4646
return $this;
4747
}
4848

49+
public function remove(string $key): self
50+
{
51+
unset($this->data[$key]);
52+
53+
return $this;
54+
}
55+
4956
public function toArray(): array
5057
{
5158
return $this->data()->toArray();

src/Gateways/Builtin/MollieGateway.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,19 @@ public function webhook(Request $request)
124124

125125
event(new OrderPaymentFailed($order));
126126
}
127+
128+
if ($payment->status === MolliePaymentStatus::STATUS_EXPIRED) {
129+
$order = $this->getOrderFromWebhookRequest($request);
130+
131+
if (! $order) {
132+
throw new OrderNotFound("Order related to Mollie transaction [{$mollieId}] could not be found.");
133+
}
134+
135+
$order
136+
->remove('mollie')
137+
->clearGatewayData()
138+
->save();
139+
}
127140
}
128141

129142
public function fieldtypeDisplay($value): array

src/Orders/Order.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,13 @@ public function gatewayData(?string $gateway = null, ?array $data = null, ?array
227227
return new GatewayData($this->gateway);
228228
}
229229

230+
public function clearGatewayData(): self
231+
{
232+
$this->gateway = null;
233+
234+
return $this;
235+
}
236+
230237
public function resource($resource = null)
231238
{
232239
return $this

0 commit comments

Comments
 (0)