Skip to content

Membership Platform Setup

Jan Baykara edited this page May 3, 2022 · 7 revisions

For server, database and hosting setup, see this page.

Syncing Stripe and user data

Migrating user and membership data from the old website

  1. From the django admin app, use the "import" modeladmin action for the app.user model
  2. Shell into the server (fly ssh console && cd app)
  3. Run the following migration script, accessed through the virtualenv:
poetry run python manage.py sync_legacy_users_with_stripe
  1. Run the following SQL command to generate a profile of gifts given and received, and export as CSV
SELECT
    g.id as "gift_id",
    g.code as "gift_code",
    us.user_id as "giving_user_id",
    gifters.email as "giving_user_email",
    giftsub.stripe_id as "giving_sub",
    giftsub.stripe_status as "giving_stripe_status",
    g.email as "initial_recipient_email",
    recipients.id as "recipient_user_id_matching_gift_email",
    recipientsub.stripe_id as "follow_up_recipient_sub",
    recipientsub.stripe_status
FROM gifts g
LEFT JOIN user_subscription us ON us.id = g.user_subscription_id
LEFT JOIN users recipients ON recipients.email = g.email
LEFT JOIN users gifters ON gifters.id = us.user_id
LEFT JOIN subscriptions giftsub ON giftsub.user_id = us.user_id
LEFT JOIN subscriptions recipientsub ON recipientsub.user_id = recipients.id
ORDER BY giftsub.stripe_status, g.id;
  1. Import this CSV into the app.LegacyGifts model via the django admin panel
  2. Run the following to generate gift subscriptions and add metadata required for correct gift subscription functioning:
poetry run python manage.py  sync_legacy_gifts_with_stripe

Configuring Stripe data sync

  1. Enable webhooks on Stripe dashboard, pointed to /stripe/webhook/, to relay Stripe events, and update the STRIPE_WEBHOOK_SECRET environment variable accordingly
  2. Perform a full initial download of Stripe data to populate the dj-stripe tables
  poetry run python manage.py djstripe_sync_models Product Subscription Coupon

CMS setup

  1. In the CMS, configure Membership Plans and Subscription Fees pages. You can access them on the sidebar.

    Membership Plans (like "Solidarity Membership") can be offered to visitors to subscribe, with one or more underlying Stripe Product (e.g. classic or contemporary books) and one or more Subscription Fees (e.g. £4 per month, £40 per year). Currently, the cheapest, most frequent monthly and annual prices are displayed via the month/year picker buttons.

    Plans can be displayed to visitors in a group of options (for example a plan picker page) and also via a full page for each plan.

  2. Also in the CMS, configure Shipping Zones. See full documentation.

  3. Then configure the pre-created app.HomePage with website content.

    Use the layout section to add a MembershipPlanBlock to display a list of membership options, with buttons that will take them through the signup process.

    Then use other blocks to create and update site copy. Other pages can be created in the same way using the app.InformationPage.

    There is also a BlogIndexPage which can be used to create and display a blog roll, with a simpler full text layout.

  4. Finally, configure the Main Menu and Flat Menu (Footer) via settings > menus in the CMS.

Shopify setup

  1. Create book products and ensure they are:
    • Available to the Left Book Club Django App channel via the sidebar, and
    • Added to the "Member-Only Books" product collection. This collection's ID (numbers at end of url like 402936398057) is saved in the app environment as SHOPIFY_COLLECTION_ID.
  2. Pull product data from this shopify collection into the Books section of the website / CMS by running the following shell command:
poetry run python manage.py sync_shopify_products
  1. You can now set a Featured Content > Book of the Month via the CMS sidebar.

    Books will automatically display in the /books page, with their own web page for full details and purchasing via Shopify Checkout. All product data, imagery and copy is stored in Shopify.

    Books can also be displayed as a featured book or grid of books, on the home page and other pages.

NB: There is a Private App configured for the LBC on left-book-club-shop.myshopify.com/admin that is used for the integration. However, Private Apps are no longer creatable and will likely be deprecated, so new integrations with Shopify will require creating a Custom App and integrating via OAuth.

App transactional Emails

Configure Mailgun or another transactional ESP via the django-anymail package, which is configured in app.settings.production.

Membership marketing Emails

Configure Mailchimp integration via Stripe webhooks, using a tool like Zapier or N8N. More information and recommendations here.

Product analytics

Posthog.com has been installed to provide detailed product analytics and session recordings.

Running your membership