Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pricing & payments v2 for formbricks cloud #2648

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ShubhamPalriwala
Copy link
Member

@ShubhamPalriwala ShubhamPalriwala commented May 17, 2024

What does this PR do?

  • Implements new Pricing Strategy for Formbricks Cloud v2
  • Cleans up the current approach & simplifies everything Stripe

Closes https://github.com/formbricks/internal/issues/192

How should this be tested?

  • Run Stripe Webhook CLI locally
  • Try playing around with upgrages/downgrades/etc

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read How we Code at Formbricks
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand bits
  • Ran pnpm build
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues
  • First PR at Formbricks? Please sign the CLA! Without it we wont be able to merge it 🙏

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Formbricks Docs if changes were necessary

Copy link
Contributor

github-actions bot commented May 17, 2024

Thank you for following the naming conventions for pull request titles! 🙏

Copy link

vercel bot commented May 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
formbricks-cloud ⬜️ Ignored (Inspect) May 17, 2024 5:51pm
formbricks-docs ⬜️ Ignored (Inspect) May 17, 2024 5:51pm

Copy link
Contributor

@pandeymangg pandeymangg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! @ShubhamPalriwala thanks for the PR! looks good and works well, I just left a few comments, pls address them 🙏

also, there is no data migration right now so the older teams won't work with this, please write a data migration for backwards compatibility.

I also encountered this weird error that exists when I try to switch plans:

Screen.Recording.2024-05-23.at.4.20.51.PM.mov

you can see that only after reloading the page does the UI actually update (and I hard reloaded the page for it to work). Also, when I click on any Switch Plan button, all the other buttons also get a loading state, pls also fix these 🙏

<div className="mb-2 flex items-center gap-x-4"></div>
{
<div className="relative mx-8 mb-16 mt-4">
Responses
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please wrap this text inside a html tag like the p tag and give it some color as well 🙏 pls do the same for all the text elements

const product = await stripe.products.retrieve(
stripeSubscriptionObject.items.data[0].price.product as string
);
if (!product) throw new Error("Product not found");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be consistent here with the other services and throw a ResourceNotFoundError instead of just an Error for more context. Also pls do this for the other not found errors 🙏

if (!product) throw new Error("Product not found");

let updatedBilling = team.billing;
let responses = product.metadata.responses as unknown as number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't type cast these as numbers, they won't actually be converted to numbers, but the typescript compiler will still be treating them as numbers which could lead to runtime errors. Please use parseInt here to actually convert these to numbers 🙏


let updatedBilling = team.billing;
let responses = product.metadata.responses as unknown as number;
let miu = product.metadata.miu as unknown as number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here as above 😊

@@ -1,23 +1,25 @@
export enum ProductFeatureKeys {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this file contains constants, please use the upper case for all of them, you can take a look at the COLOR_DEFAULTS under packages/lib/styling/constants.ts for reference, its basically to be consistent around constants, like you've done with LIMITS 🙏

});
});
if (!priceObject) throw new Error("Price not found");
const responses = (priceObject.product as Stripe.Product).metadata.responses as unknown as number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as mentioned above, pls don't type cast it and actually convert it to an integer using parseInt

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

Successfully merging this pull request may close these issues.

None yet

2 participants