Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/apps/payments/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
class ServiceProductAdmin(admin.ModelAdmin):
"""Admin view for ServiceProduct model."""

list_display = ("name", "slug", "is_active", "contact_email", "created_at")
list_filter = ("is_active", "created_at")
list_display = ("name", "slug", "is_active", "is_test", "contact_email", "created_at")
list_filter = ("is_active", "is_test", "created_at")
search_fields = ("name", "slug", "contact_email")
readonly_fields = ("api_key", "api_secret", "created_at", "updated_at")
prepopulated_fields: ClassVar[dict] = {"slug": ("name",)}
Expand Down
18 changes: 18 additions & 0 deletions src/apps/payments/migrations/0004_serviceproduct_is_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.2.14 on 2026-05-19 08:32

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('payments', '0003_payment_exchange_rate_payment_settlement_amount_and_more'),
]

operations = [
migrations.AddField(
model_name='serviceproduct',
name='is_test',
field=models.BooleanField(default=False, help_text='Mark as test product to use Paystack test credentials.', verbose_name='test product'),
),
]
5 changes: 5 additions & 0 deletions src/apps/payments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ class ServiceProduct(models.Model):

# Settings
is_active = models.BooleanField("active", default=True)
is_test = models.BooleanField(
"test product",
default=False,
help_text="Mark as test product to use Paystack test credentials.",
)
allowed_currencies = models.JSONField(
"allowed currencies",
default=list,
Expand Down
8 changes: 8 additions & 0 deletions src/apps/payments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ def get_queryset(self):
qs = qs.filter(is_active=True)
elif status == "inactive":
qs = qs.filter(is_active=False)
mode = self.request.GET.get("mode")
if mode == "test":
qs = qs.filter(is_test=True)
elif mode == "live":
qs = qs.filter(is_test=False)
return qs.annotate(
payment_count=models.Count("payments"),
successful_payments=models.Count("payments", filter=models.Q(payments__status=Payment.Status.SUCCESS)),
Expand All @@ -256,8 +261,10 @@ def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["total_services"] = ServiceProduct.objects.count()
context["active_services"] = ServiceProduct.objects.filter(is_active=True).count()
context["test_services"] = ServiceProduct.objects.filter(is_test=True).count()
context["search_query"] = self.request.GET.get("q", "")
context["current_status"] = self.request.GET.get("status", "all")
context["current_mode"] = self.request.GET.get("mode", "all")
return context


Expand All @@ -270,6 +277,7 @@ class ServiceCreateView(AdminRequiredMixin, CreateView):
"name",
"slug",
"description",
"is_test",
"webhook_url",
"default_callback_url",
"contact_email",
Expand Down
7 changes: 7 additions & 0 deletions src/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -4246,6 +4246,10 @@ details.collapse summary::-webkit-details-marker {
border-radius: 9999px;
padding: 0px;
}
[type="checkbox"].checkbox-sm {
height: 1.25rem;
width: 1.25rem;
}
.drawer-open > .drawer-toggle {
display: none;
}
Expand Down Expand Up @@ -4804,6 +4808,9 @@ html:has(.drawer-toggle:checked) {
.ml-1 {
margin-left: 0.25rem;
}
.ml-2 {
margin-left: 0.5rem;
}
.ml-auto {
margin-left: auto;
}
Expand Down
8 changes: 8 additions & 0 deletions src/templates/dashboard/services/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ <h2 class="font-bold text-sm mb-4 flex items-center gap-2">
placeholder="Describe this product..."
class="textarea textarea-bordered w-full rounded-lg bg-base-100/50 text-sm">{{ form.description.value|default:'' }}</textarea>
</div>
<div class="form-control">
<label class="label py-1 cursor-pointer">
<input type="checkbox" name="is_test" id="id_is_test" {% if form.is_test.value %}checked{% endif %}
class="checkbox checkbox-sm rounded" />
<span class="label-text text-xs font-semibold ml-2">Test Product</span>
</label>
<label class="label py-0"><span class="label-text-alt text-base-content/30">Mark this product for using Paystack test credentials.</span></label>
</div>
</div>
</div>

Expand Down
18 changes: 13 additions & 5 deletions src/templates/dashboard/services/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,19 @@
<div class="w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="text-primary"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path></svg>
</div>
{% if service.is_active %}
<span class="w-2.5 h-2.5 rounded-full bg-success mt-1 shrink-0" title="Active"></span>
{% else %}
<span class="w-2.5 h-2.5 rounded-full bg-base-content/20 mt-1 shrink-0" title="Inactive"></span>
{% endif %}
<div class="flex items-center gap-2">
{% if service.is_test %}
<span class="badge badge-warning badge-sm gap-1">
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><circle cx="12" cy="12" r="1"></circle><circle cx="12" cy="5" r="1"></circle><circle cx="12" cy="19" r="1"></circle></svg>
Test
</span>
{% endif %}
{% if service.is_active %}
<span class="w-2.5 h-2.5 rounded-full bg-success mt-0.5 shrink-0" title="Active"></span>
{% else %}
<span class="w-2.5 h-2.5 rounded-full bg-base-content/20 mt-0.5 shrink-0" title="Inactive"></span>
{% endif %}
</div>
</div>
<h3 class="font-bold text-sm group-hover:text-accent transition-colors mb-1">{{ service.name }}</h3>
<p class="text-xs text-base-content/40 line-clamp-2 mb-4">{{ service.description|default:"No description" }}</p>
Expand Down
Loading