Skip to content

Commit

Permalink
Added zone support to payment methods
Browse files Browse the repository at this point in the history
  • Loading branch information
fulopattila122 committed Apr 10, 2024
1 parent 095a7fe commit 036f0c3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- Added the listing of order item adjustments
- Added the `domain` field to the channel form
- Added billing and shipping zones to the channel form
- Added zone support to payment methods

## 3.7.1
##### 2023-12-17
Expand Down
3 changes: 3 additions & 0 deletions src/Http/Controllers/PaymentMethodController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace Vanilo\Admin\Http\Controllers;

use Konekt\Address\Query\Zones;
use Konekt\AppShell\Http\Controllers\BaseController;
use Vanilo\Admin\Contracts\Requests\CreatePaymentMethod;
use Vanilo\Admin\Contracts\Requests\UpdatePaymentMethod;
Expand Down Expand Up @@ -43,6 +44,7 @@ public function create()
return view('vanilo::payment-method.create', [
'paymentMethod' => app(PaymentMethod::class),
'gateways' => PaymentGateways::choices(),
'zones' => Zones::withBillingScope()->get(),
'multiChannelEnabled' => Features::isMultiChannelEnabled(),
'channels' => $this->channelsForUi(),
]);
Expand Down Expand Up @@ -79,6 +81,7 @@ public function edit(PaymentMethod $paymentMethod)
return view('vanilo::payment-method.edit', [
'paymentMethod' => $paymentMethod,
'gateways' => PaymentGateways::choices(),
'zones' => Zones::withBillingScope()->get(),
'multiChannelEnabled' => Features::isMultiChannelEnabled(),
'channels' => $this->channelsForUi(),
]);
Expand Down
1 change: 1 addition & 0 deletions src/Http/Requests/CreatePaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function rules()
'name' => 'required|min:2|max:255',
'gateway' => ['required', Rule::in(PaymentGateways::ids())],
'configuration' => 'sometimes|json',
'zone_id' => 'sometimes|nullable|exists:zones,id',
'is_enabled' => 'sometimes|boolean',
'description' => 'sometimes|nullable|string',
'channels' => 'sometimes|array',
Expand Down
1 change: 1 addition & 0 deletions src/Http/Requests/UpdatePaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function rules()
'gateway' => ['required', Rule::in(PaymentGateways::ids())],
'configuration' => 'sometimes|json',
'is_enabled' => 'sometimes|boolean',
'zone_id' => 'sometimes|nullable|exists:zones,id',
'description' => 'sometimes|nullable|string',
];
}
Expand Down
16 changes: 16 additions & 0 deletions src/resources/views/payment-method/_form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@

<hr>

<div class="mb-3 row">
<label class="col-form-label col-form-label-sm col-md-2">{{ __('Restricted to Zone') }}</label>
<div class="col-md-10">
{{ Form::select('zone_id', $zones->pluck('name', 'id'), null, [
'class' => 'form-select form-select-sm' . ($errors->has('zone_id') ? ' is-invalid': ''),
'placeholder' => '<' . __('Unrestricted') . '>',
])
}}
@if ($errors->has('zone_id'))
<div class="invalid-feedback">{{ $errors->first('zone_id') }}</div>
@endif
</div>
</div>

<hr>

<div class="mb-3 row">
<label class="col-form-label col-form-label-sm col-md-2">{{ __('Configuration') }}</label>
<div class="col-md-10">
Expand Down
10 changes: 10 additions & 0 deletions src/resources/widgets/payment-method/table.widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@
],
'title' => __('Name'),
],
'zone' => [
'title' => __('Zone'),
'valign' => 'middle',
'widget' => [
'type' => 'badge',
'color' => ['bool' => ['info', 'secondary']],
'text' => '$model.zone.name',
'modifier' => sprintf('text_if_empty:%s', __('Unrestricted'))
]
],
'transaction_count' => [
'title' => __('No. of Transactions'),
'valign' => 'middle',
Expand Down

0 comments on commit 036f0c3

Please sign in to comment.