Skip to content

[$500] Create new "Pay & Downgrade" RHP #58603

Closed

Description

@blimpich

Problem

When a user has a a Pay-per-use (PPU) plan and has at least 3 purchases (example: 1 billing cycle === 1 purchase), they are unable to delete their workspace. We support this flow in OldDot, but not in NewDot. It leaves the user trapped, unable to delete their workspace and forced to go to OldDot to finish the flow, which hurts our ability to retain customers.

Solution

Implement new RHP UI to support deleting a workspace when user is on PPU plan and has at least 3 purchases.

Flow

User goes to new.expensify.com/settings/workspaces where they have a workspace and clicks "delete workspace"

Image

When the use clicks "delete workspace" we should call a new command called CalculateBillNewDot. This command takes no params other than authToken. This command will return an onyx update for a new onyx key called shouldBillWhenDowngrading. If this key is false then we proceed as normal and we show the confirmation modal that we currently show when deleting a workspace

Image

If shouldBillWhenDowngrading is true then instead of showing the confirmation modal we will open the Pay & Downgrade RHP:

Image

This new UI will be populated by a table displaying the number of current users the workspace has, the discounts available to this user, and their total amount they need to pay before deleting their account. This data will be stored in a new onyx key called billingReceiptDetails. This an example of how that payload will be formed:

{
  "subtotal": 0,
  "receiptsWithoutDiscount": [
    {
      "description": "1 Collect user @ $20.00/user",
      "amount": 2000,
      "formattedAmount": "$20.00",
      "type": "",
      "percentage": 0
    }
  ],
  "discounts": [
    {
      "description": "0% Annual Subscription Discount (<a href=\"https://www.expensify.com.dev/admin_policies?param={%22section%22:%22group%22}\" style=\"color: #00a5d5;\">Make it 50%</a>)",
      "amount": 0,
      "formattedAmount": "-$0.00",
      "type": "annual",
      "percentage": 0
    },
    {
      "description": "0% Expensify Card Discount (<a href=\"https://www.expensify.com.dev/inbox?taskID=AddWithdrawalAccount\" style=\"color: #00a5d5;\">Make it 25%</a>)",
      "amount": 0,
      "formattedAmount": "-$0.00",
      "type": "expensifyCard",
      "percentage": 0
    }
  ],
  "salesTax": [],
  "billingMonth": "March 2025",
  "formattedSubtotal": "$20.00",
  "averageYearlyUserPrice": 0,
  "monthlyCorpBasePrice": 3600,
  "monthlyTeamBasePrice": 2000
}

When the user clicks "Pay & downgrade" we should call a new command called PayAndDowngrade. This command also takes no params other than authToken. This command will charge the user and delete their workspace. It can error out in 6 distinct ways. Below is a table outlining the 6 different errors that we know the command can throw and the error messages that will be provided when the command throws.

Title Message
Insufficient funds Your card has insufficient funds
Purchase type not supported Your card doesn't support this type of purchase
Incorrect Card Number The card number you entered is incorrect
Cannot delete workspace One of the workspaces you own is set as the Preferred Workspace for a domain group. Please disable the Preferred Workspace setting on the Group Permissions page or transfer the workspace to someone else.
Card Declined Your card was declined
Error making payment There was an error making the payment

How to test

This issue is is slightly tricky to test because in order for shouldBillWhenDowngrading to be true the user needs to have at least three purchases, but it's not possible to add purchases in staging/production for contributors to test this. So whoever works on this and whoever reviews this will need to use my (@blimpich) ngrok to access my local backend, where they can access a test account that has three purchases on it. Note: my ngrok will only work when I'm online. I generally work Monday-Friday from 9am to 6pm PST. Your work hours will have to at least somewhat overlap mine.

If you're okay with the ngrok and hours overlap situation, update your .env file to look like this

NEW_EXPENSIFY_URL=https:/
NEW_EXPENSIFY_URL=https://new.expensify.com/
SECURE_EXPENSIFY_URL=https://secure.expensify.com.dev/
EXPENSIFY_URL=https://www.expensify.com.dev/
EXPENSIFY_PARTNER_NAME=chat-expensify-com
EXPENSIFY_PARTNER_PASSWORD=e21965746fd75f82bb66
PUSHER_APP_KEY=ac6d22b891daae55283a
SECURE_NGROK_URL=https://secure-expensify-blimpich.ngrok.io/
NGROK_URL=https://expensify-blimpich.ngrok.io/
USE_NGROK=true
USE_WEB_PROXY=false
USE_WDYR=false
CAPTURE_METRICS=false
ONYX_METRICS=false

PUSHER_DEV_SUFFIX=-def525f225124b848df43bee41aa4e7c

Once you have ngrok setup you can access ppu@test.com which should have three valid test purchases, so that you can properly test this. The OTP for logging in will be 000000

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021904213388095519395
  • Upwork Job ID: 1904213388095519395
  • Last Price Increase: 2025-03-24
Issue OwnerCurrent Issue Owner: @sakluger

Activity

  1. self-assigned this
    on Mar 17, 2025
  2. blimpich commented on Mar 18, 2025

    @blimpich
    ContributorAuthor

    Going to hold this until the backend is ready

  3. changed the title [-]Create new "Pay & Downgrade" RHP[/-] [+][HOLD] Create new "Pay & Downgrade" RHP[/+] on Mar 18, 2025
  4. added
    NewFeatureSomething to build that is a new item.
    and removed on Mar 21, 2025
  5. melvin-bot commented on Mar 21, 2025

    @melvin-bot

    Triggered auto assignment to @sakluger (NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details. Please add this Feature request to a GH project, as outlined in the SO.

  6. 62 remaining items

  7. jayeshmangwani commented on Apr 28, 2025

    @jayeshmangwani
    Contributor

    The follow-up issue seems to have been solved from the BE side. One PR was raised by @blimpich . Since I don't have access to that BE PR, could you please link it here?

  8. blimpich commented on Apr 28, 2025

    @blimpich
    ContributorAuthor

    Yeah we ended deciding to fix the follow up work with a backend change 👍

  9. sakluger commented on Apr 29, 2025

    @sakluger
    Contributor

    Okay, so that does that mean this is fixed and ready to pay out?

  10. blimpich commented on Apr 29, 2025

    @blimpich
    ContributorAuthor

    Yes!

  11. sakluger commented on Apr 30, 2025

    @sakluger
    Contributor

    Summarizing payment on this issue:

    Contributor: @jayeshmangwani $500, please request on Newdot
    Contributor+: @dukenv0307 $500, due via NewDot

  12. jayeshmangwani commented on Apr 30, 2025

    @jayeshmangwani
    Contributor

    @sakluger, could you please update the summary? I’ll be paid via ND.

  13. garrettmknight commented on May 2, 2025

    @garrettmknight
    Contributor

    $500 approved for @jayeshmangwani

  14. dukenv0307 commented on May 6, 2025

    @dukenv0307
    Contributor

    Contributor+: @dukenv0307 $500, paid via Upwork

    I also get paid via NewDot, it seems the summary was updated from "please request on Newdot" to "paid via Upwork" by mistake. As @sakluger is OOO, @JmillsExpensify could you help to correct the payment summary when you approve my ND request, thanks 🙏

  15. mallenexpensify commented on May 8, 2025

    @mallenexpensify
    Contributor

    Updated comment above

    Contributor+: @dukenv0307 $500, due via NewDot

    Reopening til @dukenv0307's confirmed they've been paid (or... they requested and are confidently expecting to be paid soon)

    Also confirmed they weren't paid via Upwork

    Image
  16. dukenv0307 commented on May 8, 2025

    @dukenv0307
    Contributor

    Updated comment above

    @mallenexpensify Thank you!

    they requested and are confidently expecting to be paid soon

    @mallenexpensify I've requested so we can close this out now.

  17. JmillsExpensify commented on May 13, 2025

    @JmillsExpensify
    Contributor

    $500 approved for @dukenv0307

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionDailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributorNewFeatureSomething to build that is a new item.

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions