[#41] Allow users to download the user/planting guide for a payment - backend #92

Merged
mattn merged 2 commits from matt/41-backend into main 2023-03-09 14:58:47 +13:00
mattn commented 2023-03-06 18:23:42 +13:00 (Migrated from gitlab.catalyst.net.nz)

Hides the initial questionnaire behind a paywall

This MR is for the backend changes. The individual user flow is:

  1. User arrives at /apply and clicks 'Purchase Key'
  2. Links to /api/key/purchase which does the following
    1. Generates a 20 character key of characters in [A-Z0-9]
    2. Creates a Stripe session
    3. Stores the session ID and activation key as a key-value pair in Redis
    4. Redirects to the Stripe checkout page
  3. User fills form and purchases a key
  4. User is redirected to /api/key/activate which does the following
    1. Pulls the Stripe session and activation key from Redis
    2. Verifies the purchase and activates the key
    3. Invalidates the session and removes any persistence if the purchase was not followed through
    4. Redirects to /apply?key={KEY}
  5. User activates the key which performs a check against /api/key/validate

Additonally, the changes allow an admin to bulk create keys via ActivationKeySet, which takes a name and integer input and generates that many keys. The admin is then able to sort Questionnaires by their ActivationKeySet and bulk export depending on how they were generated. This is useful as Wilfred is wanting to sell N keys to a magazine and only export those related to that key set.

@satoshi just a quick sanity check as last time. I don't expect you to follow the code from start to finish. Cheers :)

Hides the initial questionnaire behind a paywall This MR is for the backend changes. The individual user flow is: 1. User arrives at `/apply` and clicks 'Purchase Key' 2. Links to `/api/key/purchase` which does the following 1. Generates a 20 character key of characters in `[A-Z0-9]` 2. Creates a [Stripe](https://stripe.com) session 3. Stores the session ID and activation key as a key-value pair in Redis 4. Redirects to the Stripe checkout page 3. User fills form and purchases a key 4. User is redirected to `/api/key/activate` which does the following 1. Pulls the Stripe session and activation key from Redis 2. Verifies the purchase and activates the key 3. Invalidates the session and removes any persistence if the purchase was not followed through 4. Redirects to `/apply?key={KEY}` 5. User activates the key which performs a check against `/api/key/validate` Additonally, the changes allow an admin to bulk create keys via `ActivationKeySet`, which takes a name and integer input and generates that many keys. The admin is then able to sort `Questionnaire`s by their `ActivationKeySet` and bulk export depending on how they were generated. This is useful as Wilfred is wanting to sell N keys to a magazine and only export those related to that key set. @satoshi just a quick sanity check as last time. I don't expect you to follow the code from start to finish. Cheers :)
mattn commented 2023-03-06 18:23:42 +13:00 (Migrated from gitlab.catalyst.net.nz)

assigned to @satoshi

assigned to @satoshi
mattn commented 2023-03-06 18:24:05 +13:00 (Migrated from gitlab.catalyst.net.nz)

changed the description

changed the description
satoshi commented 2023-03-08 16:57:53 +13:00 (Migrated from gitlab.catalyst.net.nz)

Looks fine for when user completes application in a single session.

Can a user restore session if user purchased a key, redirected to the /apply page but then closed the browser before completing the form?

Looks fine for when user completes application in a single session. Can a user restore session if user purchased a key, redirected to the /apply page but then closed the browser before completing the form?
mattn commented 2023-03-09 14:58:00 +13:00 (Migrated from gitlab.catalyst.net.nz)

Yes, the key purchased is included in the invoice sent to them. The key is inputted when redirected for convenience, but the user is able to copy+paste their key from their invoice when revisiting the page. The key is only consumed after the submit step.

Yes, the key purchased is included in the invoice sent to them. The key is inputted when redirected for convenience, but the user is able to copy+paste their key from their invoice when revisiting the page. The key is only consumed after the submit step.
satoshi commented 2023-03-09 14:58:40 +13:00 (Migrated from gitlab.catalyst.net.nz)

approved this merge request

approved this merge request
mattn (Migrated from gitlab.catalyst.net.nz) merged commit into main 2023-03-09 14:58:50 +13:00
satoshi (Migrated from gitlab.catalyst.net.nz) approved these changes 2024-12-18 08:20:26 +13:00
Sign in to join this conversation.
No description provided.