Skip to content

Commit

Permalink
Merge pull request #268 from membermatters/fix/membershipplan-fixes
Browse files Browse the repository at this point in the history
Fix/membershipplan fixes
  • Loading branch information
jabelone authored Jul 2, 2024
2 parents d77a46a + 830a425 commit 60cb2d4
Show file tree
Hide file tree
Showing 30 changed files with 763 additions and 424 deletions.
22 changes: 22 additions & 0 deletions memberportal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,28 @@ Starting development server at http://127.0.0.1:8000/

Now that the backend API is running, you can head over to the [frontend](/frontend) folder and follow those instructions to get the frontend UI running.

## Stripe Webhooks
If you want to test Stripe webhooks you can use the stripe CLI to forward webhooks to your local dev server.
To do so, you will need to install the stripe CLI and login to your stripe account.
Click [here](https://dashboard.stripe.com/test/webhooks/create?endpoint_location=local) for detailed instructions from
Stripe.

Once you're set up, run the following command to forward webhooks to your local dev server:

```bash
stripe listen --skip-verify --events invoice.paid,invoice.payment_failed,customer.subscription.deleted --forward-to localhost:8080/api/billing/stripe-webhook/
```

Finally, check that you're running the frontend proxy on port 8080 and configure the signing secret in the Constance
settings.
You can find the local signing secret in the command line output after running `stripe listen` above.
It will start like this `whsec_...`

You can also trigger common events like `invoice.paid` using the CLI like this:
```bash
stripe trigger invoice.paid
```

## Linter

As explained below, this projects uses a linter (called "Black") to fix common errors, and to enforce consistent code style/standards.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.2.25 on 2024-06-16 14:16

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("api_admin_tools", "0010_auto_20230729_2031"),
]

operations = [
migrations.AlterField(
model_name="paymentplan",
name="interval",
field=models.CharField(
choices=[("Month", "month"), ("Week", "week"), ("Day", "day")],
max_length=10,
),
),
]
6 changes: 3 additions & 3 deletions memberportal/api_admin_tools/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MemberTier(ExportModelOperationsMixin("kiosk"), models.Model):
featured = models.BooleanField("Is this plan featured?", default=False)

def __str__(self):
return self.name
return f"{self.name}{' (hidden)' if not self.visible else ''}{' (featured)' if self.featured else ''} - Stripe ID: {self.stripe_id}"

def get_object(self):
plans = []
Expand All @@ -35,7 +35,7 @@ def get_object(self):
class PaymentPlan(ExportModelOperationsMixin("payment-plan"), models.Model):
"""A Membership Plan that specifies how a member is billed for a member tier."""

BILLING_PERIODS = [("Months", "month"), ("Weeks", "week"), ("Days", "days")]
BILLING_PERIODS = [("Month", "month"), ("Week", "week"), ("Day", "day")]

id = models.AutoField(primary_key=True)
name = models.CharField("Name", max_length=50)
Expand All @@ -54,7 +54,7 @@ class PaymentPlan(ExportModelOperationsMixin("payment-plan"), models.Model):
interval = models.CharField(choices=BILLING_PERIODS, max_length=10)

def __str__(self):
return self.name
return f"{self.name} {self.member_tier.name}{' (hidden)' if not self.visible else ''} - Stripe ID: {self.stripe_id}"

def get_object(self):
return {
Expand Down
32 changes: 23 additions & 9 deletions memberportal/api_admin_tools/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,39 @@
views.MemberbucksDevices.as_view(),
name="MemberbucksDevices",
),
path("api/admin/tiers/", views.MemberTiers.as_view(), name="ManageMemberTiers"),
path(
"api/admin/tiers/",
views.ManageMembershipTier.as_view(),
name="ManageMembershipTier",
),
path(
"api/admin/tiers/<int:tier_id>/",
views.ManageMemberTier.as_view(),
name="ManageMemberTier",
views.ManageMembershipTier.as_view(),
name="ManageMembershipTier",
),
path(
"api/admin/tiers/<int:tier_id>/plans/",
views.ManageMemberTierPlans.as_view(),
name="GetPlans",
views.ManageMembershipTierPlan.as_view(),
name="ManageMembershipTierPlan",
),
path(
"api/admin/plans/",
views.ManageMemberTierPlans.as_view(),
name="ManagePlans",
views.ManageMembershipTierPlan.as_view(),
name="ManageMembershipTierPlan",
),
path(
"api/admin/plans/<int:plan_id>/",
views.ManageMemberTierPlans.as_view(),
name="ManagePlan",
views.ManageMembershipTierPlan.as_view(),
name="ManageMembershipTierPlan",
),
path(
"api/admin/settings/",
views.ManageSettings.as_view(),
name="ManageSettings",
),
path(
"api/admin/settings/<str:setting_key>/",
views.ManageSettings.as_view(),
name="ManageSettings",
),
]
Loading

0 comments on commit 60cb2d4

Please sign in to comment.