Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions frontend/controllers/RefundController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function actionCreate($storeUuid, $orderUuid) {

$restaurant = Yii::$app->accountManager->getManagedAccount($storeUuid);

$order = Order::find()->where(['order_uuid' => $orderUuid])->exists();
$order = Order::find()->where(['order_uuid' => $orderUuid])->one();

if ($restaurant && $order)
{
Expand All @@ -105,7 +105,14 @@ public function actionCreate($storeUuid, $orderUuid) {

if (array_key_exists('errors', $response->data))
{
$model->addError('refund_amount', $response->data['errors'][0]['description']);
Yii::error([
'message' => 'Tap refund creation failed',
'order_uuid' => $order->order_uuid,
'refund_amount' => $model->refund_amount,
'errors' => $response->data['errors'],
], __METHOD__);

$model->addError('refund_amount', 'Unable to create the refund right now. Please try again later.');

return $this->render('create', [
'model' => $model,
Expand Down
20 changes: 20 additions & 0 deletions tests/check-frontend-refund-create-guard.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail

target="frontend/controllers/RefundController.php"

grep -Fq "Order::find()->where(['order_uuid' => \$orderUuid])->one()" "$target"
grep -Fq "'Tap refund creation failed'" "$target"
grep -Fq "'Unable to create the refund right now. Please try again later.'" "$target"

if grep -Fq "Order::find()->where(['order_uuid' => \$orderUuid])->exists()" "$target"; then
echo "refund create still stores order existence as a boolean before dereferencing payment" >&2
exit 1
fi

if grep -Fq "addError('refund_amount', \$response->data['errors'][0]['description'])" "$target"; then
echo "refund create still exposes raw Tap refund errors to the form" >&2
exit 1
fi

echo "Frontend refund create guard passed."