Skip to content

Membership Platform Setup

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

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. The gifts will be immediately processed.

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.

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

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.

Clone this wiki locally