Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: update prices
Marc Seitz68afcaaf1f06
diff --git a/LICENSE b/LICENSEindex 0ad25db4..afe81f39 100644--- a/LICENSE+++ b/LICENSE@@ -1,178 +1,186 @@+Copyright (c) 2023-present Papermark, Inc.++Portions of this software are licensed as follows:++- All content that resides under https://github.com/mfts/papermark/tree/main/ee directory of this repository (Commercial License) is licensed under the license defined in "ee/LICENSE".+- All third party components incorporated into the Papermark Software are licensed under the original license provided by the owner of the applicable component.+- Content outside of the above mentioned directories or restrictions above is available under the "AGPLv3" license as defined below.+GNU AFFERO GENERAL PUBLIC LICENSEVersion 3, 19 November 2007- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>- Everyone is permitted to copy and distribute verbatim copies- of this license document, but changing it is not allowed.+Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>+Everyone is permitted to copy and distribute verbatim copies+of this license document, but changing it is not allowed.Preamble- The GNU Affero General Public License is a free, copyleft license for+The GNU Affero General Public License is a free, copyleft license forsoftware and other kinds of works, specifically designed to ensurecooperation with the community in the case of network server software.- The licenses for most software and other practical works are designed-to take away your freedom to share and change the works. By contrast,+The licenses for most software and other practical works are designed+to take away your freedom to share and change the works. By contrast,our General Public Licenses are intended to guarantee your freedom toshare and change all versions of a program--to make sure it remains freesoftware for all its users.- When we speak of free software, we are referring to freedom, not-price. Our General Public Licenses are designed to make sure that you+When we speak of free software, we are referring to freedom, not+price. Our General Public Licenses are designed to make sure that youhave the freedom to distribute copies of free software (and charge forthem if you wish), that you receive source code or can get it if youwant it, that you can change the software or use pieces of it in newfree programs, and that you know you can do these things.- Developers that use our General Public Licenses protect your rights+Developers that use our General Public Licenses protect your rightswith two steps: (1) assert copyright on the software, and (2) offeryou this License which gives you legal permission to copy, distributeand/or modify the software.- A secondary benefit of defending all users' freedom is that+A secondary benefit of defending all users' freedom is thatimprovements made in alternate versions of the program, if theyreceive widespread use, become available for other developers to-incorporate. Many developers of free software are heartened and-encouraged by the resulting cooperation. However, in the case of+incorporate. Many developers of free software are heartened and+encouraged by the resulting cooperation. However, in the case ofsoftware used on network servers, this result may fail to come about.The GNU General Public License permits making a modified version andletting the public access it on a server without ever releasing itssource code to the public.- The GNU Affero General Public License is designed specifically to+The GNU Affero General Public License is designed specifically toensure that, in such cases, the modified source code becomes available-to the community. It requires the operator of a network server to+to the community. It requires the operator of a network server toprovide the source code of the modified version running there to the-users of that server. Therefore, public use of a modified version, on+users of that server. Therefore, public use of a modified version, ona publicly accessible server, gives the public access to the sourcecode of the modified version.- An older license, called the Affero General Public License and-published by Affero, was designed to accomplish similar goals. This is+An older license, called the Affero General Public License and+published by Affero, was designed to accomplish similar goals. This isa different license, not a version of the Affero GPL, but Affero hasreleased a new version of the Affero GPL which permits relicensing underthis license.- The precise terms and conditions for copying, distribution and+The precise terms and conditions for copying, distribution andmodification follow.TERMS AND CONDITIONS- 0. Definitions.+1. Definitions.- "This License" refers to version 3 of the GNU Affero General Public License.+"This License" refers to version 3 of the GNU Affero General Public License.- "Copyright" also means copyright-like laws that apply to other kinds of+"Copyright" also means copyright-like laws that apply to other kinds ofworks, such as semiconductor masks.- "The Program" refers to any copyrightable work licensed under this-License. Each licensee is addressed as "you". "Licensees" and+"The Program" refers to any copyrightable work licensed under this+License. Each licensee is addressed as "you". "Licensees" and"recipients" may be individuals or organizations.- To "modify" a work means to copy from or adapt all or part of the work+To "modify" a work means to copy from or adapt all or part of the workin a fashion requiring copyright permission, other than the making of an-exact copy. The resulting work is called a "modified version" of the+exact copy. The resulting work is called a "modified version" of theearlier work or a work "based on" the earlier work.- A "covered work" means either the unmodified Program or a work based+A "covered work" means either the unmodified Program or a work basedon the Program.- To "propagate" a work means to do anything with it that, without+To "propagate" a work means to do anything with it that, withoutpermission, would make you directly or secondarily liable forinfringement under applicable copyright law, except executing it on a-computer or modifying a private copy. Propagation includes copying,+computer or modifying a private copy. Propagation includes copying,distribution (with or without modification), making available to thepublic, and in some countries other activities as well.- To "convey" a work means any kind of propagation that enables other-parties to make or receive copies. Mere interaction with a user through+To "convey" a work means any kind of propagation that enables other+parties to make or receive copies. Mere interaction with a user througha computer network, with no transfer of a copy, is not conveying.- An interactive user interface displays "Appropriate Legal Notices"+An interactive user interface displays "Appropriate Legal Notices"to the extent that it includes a convenient and prominently visiblefeature that (1) displays an appropriate copyright notice, and (2)tells the user that there is no warranty for the work (except to theextent that warranties are provided), that licensees may convey the-work under this License, and how to view a copy of this License. If+work under this License, and how to view a copy of this License. Ifthe interface presents a list of user commands or options, such as amenu, a prominent item in the list meets this criterion.- 1. Source Code.+1. Source Code.- The "source code" for a work means the preferred form of the work-for making modifications to it. "Object code" means any non-source+The "source code" for a work means the preferred form of the work+for making modifications to it. "Object code" means any non-sourceform of a work.- A "Standard Interface" means an interface that either is an official+A "Standard Interface" means an interface that either is an officialstandard defined by a recognized standards body, or, in the case ofinterfaces specified for a particular programming language, one thatis widely used among developers working in that language.- The "System Libraries" of an executable work include anything, other+The "System Libraries" of an executable work include anything, otherthan the work as a whole, that (a) is included in the normal form ofpackaging a Major Component, but which is not part of that MajorComponent, and (b) serves only to enable use of the work with thatMajor Component, or to implement a Standard Interface for which an-implementation is available to the public in source code form. A+implementation is available to the public in source code form. A"Major Component", in this context, means a major essential component(kernel, window system, and so on) of the specific operating system(if any) on which the executable work runs, or a compiler used toproduce the work, or an object code interpreter used to run it.- The "Corresponding Source" for a work in object code form means all+The "Corresponding Source" for a work in object code form means allthe source code needed to generate, install, and (for an executablework) run the object code and to modify the work, including scripts to-control those activities. However, it does not include the work's+control those activities. However, it does not include the work'sSystem Libraries, or general-purpose tools or generally available freeprograms which are used unmodified in performing those activities but-which are not part of the work. For example, Corresponding Source+which are not part of the work. For example, Corresponding Sourceincludes interface definition files associated with source files forthe work, and the source code for shared libraries and dynamicallylinked subprograms that the work is specifically designed to require,such as by intimate data communication or control flow between thosesubprograms and other parts of the work.- The Corresponding Source need not include anything that users+The Corresponding Source need not include anything that userscan regenerate automatically from other parts of the CorrespondingSource.- The Corresponding Source for a work in source code form is that+The Corresponding Source for a work in source code form is thatsame work.- 2. Basic Permissions.+2. Basic Permissions.- All rights granted under this License are granted for the term of+All rights granted under this License are granted for the term ofcopyright on the Program, and are irrevocable provided the stated-conditions are met. This License explicitly affirms your unlimited-permission to run the unmodified Program. The output from running a+conditions are met. This License explicitly affirms your unlimited+permission to run the unmodified Program. The output from running acovered work is covered by this License only if the output, given its-content, constitutes a covered work. This License acknowledges your+content, constitutes a covered work. This License acknowledges yourrights of fair use or other equivalent, as provided by copyright law.- You may make, run and propagate covered works that you do not+You may make, run and propagate covered works that you do notconvey, without conditions so long as your license otherwise remains-in force. You may convey covered works to others for the sole purpose+in force. You may convey covered works to others for the sole purposeof having them make modifications exclusively for you, or provide youwith facilities for running those works, provided that you comply withthe terms of this License in conveying all material for which you do-not control copyright. Those thus making or running the covered works+not control copyright. Those thus making or running the covered worksfor you must do so exclusively on your behalf, under your directionand control, on terms that prohibit them from making any copies ofyour copyrighted material outside their relationship with you.- Conveying under any other circumstances is permitted solely under-the conditions stated below. Sublicensing is not allowed; section 10+Conveying under any other circumstances is permitted solely under+the conditions stated below. Sublicensing is not allowed; section 10makes it unnecessary.- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.+3. Protecting Users' Legal Rights From Anti-Circumvention Law.- No covered work shall be deemed part of an effective technological+No covered work shall be deemed part of an effective technologicalmeasure under any applicable law fulfilling obligations under article11 of the WIPO copyright treaty adopted on 20 December 1996, orsimilar laws prohibiting or restricting circumvention of suchmeasures.- When you convey a covered work, you waive any legal power to forbid+When you convey a covered work, you waive any legal power to forbidcircumvention of technological measures to the extent such circumventionis effected by exercising rights under this License with respect tothe covered work, and you disclaim any intention to limit operation or@@ -180,9 +188,9 @@ modification of the work as a means of enforcing, against the work'susers, your or third parties' legal rights to forbid circumvention oftechnological measures.- 4. Conveying Verbatim Copies.+4. Conveying Verbatim Copies.- You may convey verbatim copies of the Program's source code as you+You may convey verbatim copies of the Program's source code as youreceive it, in any medium, provided that you conspicuously andappropriately publish on each copy an appropriate copyright notice;keep intact all notices stating that this License and any@@ -190,12 +198,12 @@ non-permissive terms added in accord with section 7 apply to the code;keep intact all notices of the absence of any warranty; and give allrecipients a copy of this License along with the Program.- You may charge any price or no price for each copy that you convey,+You may charge any price or no price for each copy that you convey,and you may offer support or warranty protection for a fee.- 5. Conveying Modified Source Versions.+5. Conveying Modified Source Versions.- You may convey a work based on the Program, or the modifications to+You may convey a work based on the Program, or the modifications toproduce it from the Program, in the form of source code under theterms of section 4, provided that you also meet all of these conditions:@@ -220,19 +228,19 @@ terms of section 4, provided that you also meet all of these conditions:interfaces that do not display Appropriate Legal Notices, yourwork need not make them do so.- A compilation of a covered work with other separate and independent+A compilation of a covered work with other separate and independentworks, which are not by their nature extensions of the covered work,and which are not combined with it such as to form a larger program,in or on a volume of a storage or distribution medium, is called an"aggregate" if the compilation and its resulting copyright are notused to limit the access or legal rights of the compilation's users-beyond what the individual works permit. Inclusion of a covered work+beyond what the individual works permit. Inclusion of a covered workin an aggregate does not cause this License to apply to the otherparts of the aggregate.- 6. Conveying Non-Source Forms.+6. Conveying Non-Source Forms.- You may convey a covered work in object code form under the terms+You may convey a covered work in object code form under the termsof sections 4 and 5, provided that you also convey themachine-readable Corresponding Source under the terms of this License,in one of these ways:@@ -278,75 +286,75 @@ in one of these ways:Source of the work are being offered to the general public at nocharge under subsection 6d.- A separable portion of the object code, whose source code is excluded+A separable portion of the object code, whose source code is excludedfrom the Corresponding Source as a System Library, need not beincluded in conveying the object code work.- A "User Product" is either (1) a "consumer product", which means any+A "User Product" is either (1) a "consumer product", which means anytangible personal property which is normally used for personal, family,or household purposes, or (2) anything designed or sold for incorporation-into a dwelling. In determining whether a product is a consumer product,-doubtful cases shall be resolved in favor of coverage. For a particular+into a dwelling. In determining whether a product is a consumer product,+doubtful cases shall be resolved in favor of coverage. For a particularproduct received by a particular user, "normally used" refers to atypical or common use of that class of product, regardless of the statusof the particular user or of the way in which the particular user-actually uses, or expects or is expected to use, the product. A product+actually uses, or expects or is expected to use, the product. A productis a consumer product regardless of whether the product has substantialcommercial, industrial or non-consumer uses, unless such uses representthe only significant mode of use of the product.- "Installation Information" for a User Product means any methods,+"Installation Information" for a User Product means any methods,procedures, authorization keys, or other information required to installand execute modified versions of a covered work in that User Product from-a modified version of its Corresponding Source. The information must+a modified version of its Corresponding Source. The information mustsuffice to ensure that the continued functioning of the modified objectcode is in no case prevented or interfered with solely becausemodification has been made.- If you convey an object code work under this section in, or with, or+If you convey an object code work under this section in, or with, orspecifically for use in, a User Product, and the conveying occurs aspart of a transaction in which the right of possession and use of theUser Product is transferred to the recipient in perpetuity or for afixed term (regardless of how the transaction is characterized), theCorresponding Source conveyed under this section must be accompanied-by the Installation Information. But this requirement does not apply+by the Installation Information. But this requirement does not applyif neither you nor any third party retains the ability to installmodified object code on the User Product (for example, the work hasbeen installed in ROM).- The requirement to provide Installation Information does not include a+The requirement to provide Installation Information does not include arequirement to continue to provide support service, warranty, or updatesfor a work that has been modified or installed by the recipient, or for-the User Product in which it has been modified or installed. Access to a+the User Product in which it has been modified or installed. Access to anetwork may be denied when the modification itself materially andadversely affects the operation of the network or violates the rules andprotocols for communication across the network.- Corresponding Source conveyed, and Installation Information provided,+Corresponding Source conveyed, and Installation Information provided,in accord with this section must be in a format that is publiclydocumented (and with an implementation available to the public insource code form), and must require no special password or key forunpacking, reading or copying.- 7. Additional Terms.+7. Additional Terms.- "Additional permissions" are terms that supplement the terms of this+"Additional permissions" are terms that supplement the terms of thisLicense by making exceptions from one or more of its conditions.Additional permissions that are applicable to the entire Program shallbe treated as though they were included in this License, to the extent-that they are valid under applicable law. If additional permissions+that they are valid under applicable law. If additional permissionsapply only to part of the Program, that part may be used separatelyunder those permissions, but the entire Program remains governed bythis License without regard to the additional permissions.- When you convey a copy of a covered work, you may at your option+When you convey a copy of a covered work, you may at your optionremove any additional permissions from that copy, or from any part of-it. (Additional permissions may be written to require their own-removal in certain cases when you modify the work.) You may place+it. (Additional permissions may be written to require their own+removal in certain cases when you modify the work.) You may placeadditional permissions on material, added by you to a covered work,for which you have or can give appropriate copyright permission.- Notwithstanding any other provision of this License, for material you+Notwithstanding any other provision of this License, for material youadd to a covered work, you may (if authorized by the copyright holders ofthat material) supplement the terms of this License with terms:@@ -373,74 +381,74 @@ that material) supplement the terms of this License with terms:any liability that these contractual assumptions directly impose onthose licensors and authors.- All other non-permissive additional terms are considered "further-restrictions" within the meaning of section 10. If the Program as you+All other non-permissive additional terms are considered "further+restrictions" within the meaning of section 10. If the Program as youreceived it, or any part of it, contains a notice stating that it isgoverned by this License along with a term that is a further-restriction, you may remove that term. If a license document contains+restriction, you may remove that term. If a license document containsa further restriction but permits relicensing or conveying under thisLicense, you may add to a covered work material governed by the termsof that license document, provided that the further restriction doesnot survive such relicensing or conveying.- If you add terms to a covered work in accord with this section, you+If you add terms to a covered work in accord with this section, youmust place, in the relevant source files, a statement of theadditional terms that apply to those files, or a notice indicatingwhere to find the applicable terms.- Additional terms, permissive or non-permissive, may be stated in the+Additional terms, permissive or non-permissive, may be stated in theform of a separately written license, or stated as exceptions;the above requirements apply either way.- 8. Termination.+8. Termination.- You may not propagate or modify a covered work except as expressly-provided under this License. Any attempt otherwise to propagate or+You may not propagate or modify a covered work except as expressly+provided under this License. Any attempt otherwise to propagate ormodify it is void, and will automatically terminate your rights underthis License (including any patent licenses granted under the thirdparagraph of section 11).- However, if you cease all violation of this License, then your+However, if you cease all violation of this License, then yourlicense from a particular copyright holder is reinstated (a)provisionally, unless and until the copyright holder explicitly andfinally terminates your license, and (b) permanently, if the copyrightholder fails to notify you of the violation by some reasonable meansprior to 60 days after the cessation.- Moreover, your license from a particular copyright holder is+Moreover, your license from a particular copyright holder isreinstated permanently if the copyright holder notifies you of theviolation by some reasonable means, this is the first time you havereceived notice of violation of this License (for any work) from thatcopyright holder, and you cure the violation prior to 30 days afteryour receipt of the notice.- Termination of your rights under this section does not terminate the+Termination of your rights under this section does not terminate thelicenses of parties who have received copies or rights from you under-this License. If your rights have been terminated and not permanently+this License. If your rights have been terminated and not permanentlyreinstated, you do not qualify to receive new licenses for the samematerial under section 10.- 9. Acceptance Not Required for Having Copies.+9. Acceptance Not Required for Having Copies.- You are not required to accept this License in order to receive or-run a copy of the Program. Ancillary propagation of a covered work+You are not required to accept this License in order to receive or+run a copy of the Program. Ancillary propagation of a covered workoccurring solely as a consequence of using peer-to-peer transmission-to receive a copy likewise does not require acceptance. However,+to receive a copy likewise does not require acceptance. However,nothing other than this License grants you permission to propagate or-modify any covered work. These actions infringe copyright if you do-not accept this License. Therefore, by modifying or propagating a+modify any covered work. These actions infringe copyright if you do+not accept this License. Therefore, by modifying or propagating acovered work, you indicate your acceptance of this License to do so.- 10. Automatic Licensing of Downstream Recipients.+10. Automatic Licensing of Downstream Recipients.- Each time you convey a covered work, the recipient automatically+Each time you convey a covered work, the recipient automaticallyreceives a license from the original licensors, to run, modify and-propagate that work, subject to this License. You are not responsible+propagate that work, subject to this License. You are not responsiblefor enforcing compliance by third parties with this License.- An "entity transaction" is a transaction transferring control of an+An "entity transaction" is a transaction transferring control of anorganization, or substantially all assets of one, or subdividing an-organization, or merging organizations. If propagation of a covered+organization, or merging organizations. If propagation of a coveredwork results from an entity transaction, each party to thattransaction who receives a copy of the work also receives whateverlicenses to the work the party's predecessor in interest had or could@@ -448,43 +456,43 @@ give under the previous paragraph, plus a right to possession of theCorresponding Source of the work from the predecessor in interest, ifthe predecessor has it or can get it with reasonable efforts.- You may not impose any further restrictions on the exercise of the-rights granted or affirmed under this License. For example, you may+You may not impose any further restrictions on the exercise of the+rights granted or affirmed under this License. For example, you maynot impose a license fee, royalty, or other charge for exercise ofrights granted under this License, and you may not initiate litigation(including a cross-claim or counterclaim in a lawsuit) alleging thatany patent claim is infringed by making, using, selling, offering forsale, or importing the Program or any portion of it.- 11. Patents.+11. Patents.- A "contributor" is a copyright holder who authorizes use under this-License of the Program or a work on which the Program is based. The+A "contributor" is a copyright holder who authorizes use under this+License of the Program or a work on which the Program is based. Thework thus licensed is called the contributor's "contributor version".- A contributor's "essential patent claims" are all patent claims+A contributor's "essential patent claims" are all patent claimsowned or controlled by the contributor, whether already acquired orhereafter acquired, that would be infringed by some manner, permittedby this License, of making, using, or selling its contributor version,but do not include claims that would be infringed only as a-consequence of further modification of the contributor version. For+consequence of further modification of the contributor version. Forpurposes of this definition, "control" includes the right to grantpatent sublicenses in a manner consistent with the requirements ofthis License.- Each contributor grants you a non-exclusive, worldwide, royalty-free+Each contributor grants you a non-exclusive, worldwide, royalty-freepatent license under the contributor's essential patent claims, tomake, use, sell, offer for sale, import and otherwise run, modify andpropagate the contents of its contributor version.- In the following three paragraphs, a "patent license" is any express+In the following three paragraphs, a "patent license" is any expressagreement or commitment, however denominated, not to enforce a patent(such as an express permission to practice a patent or covenant not to-sue for patent infringement). To "grant" such a patent license to a+sue for patent infringement). To "grant" such a patent license to aparty means to make such an agreement or commitment not to enforce apatent against the party.- If you convey a covered work, knowingly relying on a patent license,+If you convey a covered work, knowingly relying on a patent license,and the Corresponding Source of the work is not available for anyoneto copy, free of charge and under the terms of this License, through apublicly available network server or other readily accessible means,@@ -492,13 +500,13 @@ then you must either (1) cause the Corresponding Source to be soavailable, or (2) arrange to deprive yourself of the benefit of thepatent license for this particular work, or (3) arrange, in a mannerconsistent with the requirements of this License, to extend the patent-license to downstream recipients. "Knowingly relying" means you have+license to downstream recipients. "Knowingly relying" means you haveactual knowledge that, but for the patent license, your conveying thecovered work in a country, or your recipient's use of the covered workin a country, would infringe one or more identifiable patents in thatcountry that you have reason to believe are valid.- If, pursuant to or in connection with a single transaction or+If, pursuant to or in connection with a single transaction orarrangement, you convey, or propagate by procuring conveyance of, acovered work, and grant a patent license to some of the partiesreceiving the covered work authorizing them to use, propagate, modify@@ -506,10 +514,10 @@ or convey a specific copy of the covered work, then the patent licenseyou grant is automatically extended to all recipients of the coveredwork and works based on it.- A patent license is "discriminatory" if it does not include within+A patent license is "discriminatory" if it does not include withinthe scope of its coverage, prohibits the exercise of, or isconditioned on the non-exercise of one or more of the rights that are-specifically granted under this License. You may not convey a covered+specifically granted under this License. You may not convey a coveredwork if you are a party to an arrangement with a third party that isin the business of distributing software, under which you make paymentto the third party based on the extent of your activity of conveying@@ -521,83 +529,83 @@ for and in connection with specific products or compilations thatcontain the covered work, unless you entered into that arrangement,or that patent license was granted, prior to 28 March 2007.- Nothing in this License shall be construed as excluding or limiting+Nothing in this License shall be construed as excluding or limitingany implied license or other defenses to infringement that mayotherwise be available to you under applicable patent law.- 12. No Surrender of Others' Freedom.+12. No Surrender of Others' Freedom.- If conditions are imposed on you (whether by court order, agreement or+If conditions are imposed on you (whether by court order, agreement orotherwise) that contradict the conditions of this License, they do not-excuse you from the conditions of this License. If you cannot convey a+excuse you from the conditions of this License. If you cannot convey acovered work so as to satisfy simultaneously your obligations under thisLicense and any other pertinent obligations, then as a consequence you may-not convey it at all. For example, if you agree to terms that obligate you+not convey it at all. For example, if you agree to terms that obligate youto collect a royalty for further conveying from those to whom you conveythe Program, the only way you could satisfy both those terms and thisLicense would be to refrain entirely from conveying the Program.- 13. Remote Network Interaction; Use with the GNU General Public License.+13. Remote Network Interaction; Use with the GNU General Public License.- Notwithstanding any other provision of this License, if you modify the+Notwithstanding any other provision of this License, if you modify theProgram, your modified version must prominently offer all usersinteracting with it remotely through a computer network (if your versionsupports such interaction) an opportunity to receive the CorrespondingSource of your version by providing access to the Corresponding Sourcefrom a network server at no charge, through some standard or customary-means of facilitating copying of software. This Corresponding Source+means of facilitating copying of software. This Corresponding Sourceshall include the Corresponding Source for any work covered by version 3of the GNU General Public License that is incorporated pursuant to thefollowing paragraph.- Notwithstanding any other provision of this License, you have+Notwithstanding any other provision of this License, you havepermission to link or combine any covered work with a work licensedunder version 3 of the GNU General Public License into a single-combined work, and to convey the resulting work. The terms of this+combined work, and to convey the resulting work. The terms of thisLicense will continue to apply to the part which is the covered work,but the work with which it is combined will remain governed by version3 of the GNU General Public License.- 14. Revised Versions of this License.+14. Revised Versions of this License.- The Free Software Foundation may publish revised and/or new versions of-the GNU Affero General Public License from time to time. Such new versions+The Free Software Foundation may publish revised and/or new versions of+the GNU Affero General Public License from time to time. Such new versionswill be similar in spirit to the present version, but may differ in detail toaddress new problems or concerns.- Each version is given a distinguishing version number. If the+Each version is given a distinguishing version number. If theProgram specifies that a certain numbered version of the GNU Affero GeneralPublic License "or any later version" applies to it, you have theoption of following the terms and conditions either of that numberedversion or of any later version published by the Free Software-Foundation. If the Program does not specify a version number of the+Foundation. If the Program does not specify a version number of theGNU Affero General Public License, you may choose any version ever publishedby the Free Software Foundation.- If the Program specifies that a proxy can decide which future+If the Program specifies that a proxy can decide which futureversions of the GNU Affero General Public License can be used, that proxy'spublic statement of acceptance of a version permanently authorizes youto choose that version for the Program.- Later license versions may give you additional or different-permissions. However, no additional obligations are imposed on any+Later license versions may give you additional or different+permissions. However, no additional obligations are imposed on anyauthor or copyright holder as a result of your choosing to follow alater version.- 15. Disclaimer of Warranty.+15. Disclaimer of Warranty.- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT+THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHTHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTYOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OFALL NECESSARY SERVICING, REPAIR OR CORRECTION.- 16. Limitation of Liability.+16. Limitation of Liability.- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING+IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITINGWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYSTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANYGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE@@ -607,9 +615,9 @@ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OFSUCH DAMAGES.- 17. Interpretation of Sections 15 and 16.+17. Interpretation of Sections 15 and 16.- If the disclaimer of warranty and limitation of liability provided+If the disclaimer of warranty and limitation of liability providedabove cannot be given local legal effect according to their terms,reviewing courts shall apply local law that most closely approximatesan absolute waiver of all civil liability in connection with the@@ -620,11 +628,11 @@ copy of the Program in return for a fee.How to Apply These Terms to Your New Programs- If you develop a new program, and you want it to be of the greatest+If you develop a new program, and you want it to be of the greatestpossible use to the public, the best way to achieve this is to make itfree software which everyone can redistribute and change under these terms.- To do so, attach the following notices to the program. It is safest+To do so, attach the following notices to the program. It is safestto attach them to the start of each source file to most effectivelystate the exclusion of warranty; and each file should have at leastthe "copyright" line and a pointer to where the full notice is found.@@ -647,15 +655,15 @@ the "copyright" line and a pointer to where the full notice is found.Also add information on how to contact you by electronic and paper mail.- If your software can interact with users remotely through a computer+If your software can interact with users remotely through a computernetwork, you should also make sure that it provides a way for users to-get its source. For example, if your program is a web application, its+get its source. For example, if your program is a web application, itsinterface could display a "Source" link that leads users to an archive-of the code. There are many ways you could offer source, and different+of the code. There are many ways you could offer source, and differentsolutions will be better for different programs; see section 13 for thespecific requirements.- You should also get your employer (if you work as a programmer) or school,+You should also get your employer (if you work as a programmer) or school,if any, to sign a "copyright disclaimer" for the program, if necessary.For more information on this, and how to apply and follow the GNU AGPL, see<https://www.gnu.org/licenses/>.diff --git a/components/billing/pro-annual-banner.tsx b/components/billing/pro-annual-banner.tsxnew file mode 100644index 00000000..b583a0f5--- /dev/null+++ b/components/billing/pro-annual-banner.tsx@@ -0,0 +1,82 @@+import { useRouter } from "next/router";++import { Dispatch, SetStateAction, useState } from "react";++import { useTeam } from "@/context/team-context";+import Cookies from "js-cookie";+import { usePlausible } from "next-plausible";++import X from "@/components/shared/icons/x";+import { Button } from "@/components/ui/button";++import { usePlan } from "@/lib/swr/use-billing";++export default function ProAnnualBanner({+ setShowProAnnualBanner,+}: {+ setShowProAnnualBanner: Dispatch<SetStateAction<boolean | null>>;+}) {+ const plausible = usePlausible();+ const router = useRouter();+ const teamInfo = useTeam();+ const { plan: teamPlan, trial, isCustomer, isOldAccount } = usePlan();++ const [isLoading, setIsLoading] = useState(false);++ const handleHideBanner = () => {+ setShowProAnnualBanner(false);+ plausible("clickedHideProAnnualBanner");+ Cookies.set("hideProAnnualBanner", "pro-annual-banner", {+ expires: 7,+ });+ };++ return (+ <aside className="relative mb-2 flex w-full flex-col justify-center rounded-lg border border-gray-700 bg-background p-4 text-foreground">+ <button+ type="button"+ onClick={handleHideBanner}+ className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"+ >+ <X className="h-4 w-4" />+ <span className="sr-only">Close</span>+ </button>+ <div className="flex space-x-2">+ <span className="text-sm font-bold">Papermark Pro Annual</span>+ </div>+ <p className="my-4 text-sm">+ Upgrade to Papermark Pro Annual to get 2 months free.+ </p>+ <div className="flex">+ <Button+ type="button"+ className="grow"+ loading={isLoading}+ onClick={() => {+ if (isCustomer && teamPlan === "pro") {+ setIsLoading(true);+ fetch(+ `/api/teams/${teamInfo?.currentTeam?.id}/billing/manage?proAnnualBanner=true`,+ {+ method: "POST",+ },+ )+ .then(async (res) => {+ const url = await res.json();+ router.push(url);+ })+ .catch((err) => {+ alert(err);+ })+ .finally(() => {+ setIsLoading(false);+ });+ }+ }}+ >+ {isLoading ? "Upgrading..." : "Upgrade"}+ </Button>+ </div>+ </aside>+ );+}diff --git a/components/billing/upgrade-plan-container.tsx b/components/billing/upgrade-plan-container.tsxnew file mode 100644index 00000000..7b3faf25--- /dev/null+++ b/components/billing/upgrade-plan-container.tsx@@ -0,0 +1,98 @@+import Link from "next/link";+import { useRouter } from "next/router";++import { useState } from "react";++import { useTeam } from "@/context/team-context";++import { Button } from "@/components/ui/button";+import {+ Card,+ CardContent,+ CardDescription,+ CardFooter,+ CardHeader,+ CardTitle,+} from "@/components/ui/card";++import { usePlan } from "@/lib/swr/use-billing";++export default function UpgradePlanContainer() {+ const router = useRouter();+ const [loading, setLoading] = useState<boolean>(false);+ const teamInfo = useTeam();+ const { plan } = usePlan();++ const manageSubscription = async () => {+ if (!teamInfo?.currentTeam?.id) {+ return;+ }++ const teamId = teamInfo?.currentTeam?.id;++ setLoading(true);++ try {+ fetch(`/api/teams/${teamId}/billing/manage`, {+ method: "POST",+ })+ .then(async (res) => {+ const url = await res.json();+ router.push(url);+ })+ .catch((err) => {+ throw err;+ })+ .finally(() => {+ setLoading(false);+ });+ } catch (error) {+ console.error(error);+ } finally {+ setLoading(false);+ }+ };++ const ButtonList = () => {+ if (plan === "free") {+ return (+ <Link href="/settings/upgrade">+ <Button>Upgrade Plan</Button>+ </Link>+ );+ } else {+ return (+ <Button onClick={manageSubscription} loading={loading}>+ Manage Subscription+ </Button>+ );+ }+ };++ return (+ <div className="rounded-lg">+ <Card className="bg-transparent">+ <CardHeader>+ <CardTitle>Billing</CardTitle>+ <CardDescription>+ You are currently on the{" "}+ <span className="mx-0.5 rounded-full bg-background px-2.5 py-1 text-xs font-bold tracking-normal text-foreground ring-1 ring-gray-800 dark:ring-gray-400">+ {plan.charAt(0).toUpperCase() + plan.slice(1)}+ </span>{" "}+ plan.{" "}+ <Link+ href="/settings/upgrade"+ className="text-sm underline underline-offset-4 hover:text-foreground"+ >+ See all plans+ </Link>+ </CardDescription>+ </CardHeader>+ <CardContent></CardContent>+ <CardFooter className="flex items-center justify-end rounded-b-lg border-t px-6 py-3">+ <div className="shrink-0">{ButtonList()}</div>+ </CardFooter>+ </Card>+ </div>+ );+}diff --git a/components/billing/upgrade-plan-modal-old.tsx b/components/billing/upgrade-plan-modal-old.tsxindex 39fd75d6..46997bc9 100644--- a/components/billing/upgrade-plan-modal-old.tsx+++ b/components/billing/upgrade-plan-modal-old.tsx@@ -4,6 +4,8 @@ import { useEffect, useMemo, useState } from "react";import React from "react";import { useTeam } from "@/context/team-context";+import { getStripe } from "@/ee/stripe/client";+import { PLANS } from "@/ee/stripe/utils";import { CheckIcon } from "lucide-react";import { Button } from "@/components/ui/button";@@ -11,8 +13,6 @@ import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";import { useAnalytics } from "@/lib/analytics";-import { getStripe } from "@/lib/stripe/client";-import { PLANS } from "@/lib/stripe/utils";import { usePlan } from "@/lib/swr/use-billing";import { capitalize, cn } from "@/lib/utils";diff --git a/components/billing/upgrade-plan-modal.tsx b/components/billing/upgrade-plan-modal.tsxindex 9678cf45..66386b73 100644--- a/components/billing/upgrade-plan-modal.tsx+++ b/components/billing/upgrade-plan-modal.tsx@@ -5,6 +5,8 @@ import { useEffect, useMemo, useState } from "react";import React from "react";import { useTeam } from "@/context/team-context";+import { getStripe } from "@/ee/stripe/client";+import { PLANS } from "@/ee/stripe/utils";import { CheckIcon } from "lucide-react";import { Button } from "@/components/ui/button";@@ -12,8 +14,6 @@ import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";import { Switch } from "@/components/ui/switch";import { useAnalytics } from "@/lib/analytics";-import { getStripe } from "@/lib/stripe/client";-import { PLANS } from "@/lib/stripe/utils";import { usePlan } from "@/lib/swr/use-billing";import { capitalize } from "@/lib/utils";@@ -48,13 +48,13 @@ export function UpgradePlanModal({Pro: {featureIntro: "Everything in Free, plus:",features: [- "2 users included",- "100 documents",+ "1 user included",+ "300 documents","Unlimited links","Custom branding","Folder organization",- "Require email verification",- "More file types: pppt, docx, excel",+ // "Require email verification",+ "More file types: ppt, docx, excel","Papermark branding removed","1-year analytics retention",],diff --git a/components/document-upload.tsx b/components/document-upload.tsxindex 8d9fc300..335e137f 100644--- a/components/document-upload.tsx+++ b/components/document-upload.tsx@@ -16,20 +16,6 @@ import {} from "@/lib/utils/get-file-size-limits";import { getPagesCount } from "@/lib/utils/get-page-number-count";-// const fileSizeLimits: { [key: string]: number } = {-// "application/vnd.ms-excel": 40, // 40 MB-// "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": 40, // 40 MB-// "application/vnd.oasis.opendocument.spreadsheet": 40, // 40 MB-// "image/png": 100, // 100 MB-// "image/jpeg": 100, // 100 MB-// "image/jpg": 100, // 100 MB-// "video/mp4": 500, // 500 MB-// "video/quicktime": 500, // 500 MB-// "video/x-msvideo": 500, // 500 MB-// "video/webm": 500, // 500 MB-// "video/ogg": 500, // 500 MB-// };-export default function DocumentUpload({currentFile,setCurrentFile,diff --git a/components/sidebar/app-sidebar.tsx b/components/sidebar/app-sidebar.tsxindex a4645382..9d5853bb 100644--- a/components/sidebar/app-sidebar.tsx+++ b/components/sidebar/app-sidebar.tsx@@ -34,6 +34,7 @@ import { usePlan } from "@/lib/swr/use-billing";import useLimits from "@/lib/swr/use-limits";import { nFormatter } from "@/lib/utils";+import ProAnnualBanner from "../billing/pro-annual-banner";import ProBanner from "../billing/pro-banner";import { PlanEnum } from "../billing/upgrade-plan-modal";import { Progress } from "../ui/progress";@@ -41,9 +42,12 @@ import { Progress } from "../ui/progress";export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {const router = useRouter();const [showProBanner, setShowProBanner] = useState<boolean | null>(null);+ const [showProAnnualBanner, setShowProAnnualBanner] = useState<+ boolean | null+ >(null);const { currentTeam, teams, setCurrentTeam, isLoading }: TeamContextType =useTeam() || initialState;- const { plan: userPlan, trial: userTrial } = usePlan();+ const { plan: userPlan, trial: userTrial, isAnnualPlan } = usePlan();const isTrial = !!userTrial;const { limits } = useLimits();const linksLimit = limits?.links;@@ -55,8 +59,19 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {} else {setShowProBanner(false);}+ if (Cookies.get("hideProAnnualBanner") !== "pro-annual-banner") {+ setShowProAnnualBanner(true);+ } else {+ setShowProAnnualBanner(false);+ }}, []);+ console.log("userPlan", userPlan);+ console.log("userTrial", userTrial);++ console.log("linksLimit", linksLimit);+ console.log("documentsLimit", documentsLimit);+const data = {navMain: [// {@@ -186,6 +201,17 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {{userPlan === "free" && !userTrial && showProBanner ? (<ProBanner setShowProBanner={setShowProBanner} />) : null}+ {/*+ * if user is pro and showProAnnualBanner is true show pro annual banner+ */}+ {userPlan === "pro" &&+ !isAnnualPlan &&+ !userTrial &&+ showProAnnualBanner ? (+ <ProAnnualBanner+ setShowProAnnualBanner={setShowProAnnualBanner}+ />+ ) : null}<div className="mb-2">{linksLimit ? (diff --git a/ee/limits/constants.ts b/ee/limits/constants.tsindex 2bd2344b..fb6c4e49 100644--- a/ee/limits/constants.ts+++ b/ee/limits/constants.ts@@ -14,8 +14,8 @@ export type TPlanLimits = {export const FREE_PLAN_LIMITS = {users: 1,- links: 10,- documents: 10,+ links: 50,+ documents: 50,domains: 0,datarooms: 0,customDomainOnPro: false,@@ -24,10 +24,10 @@ export const FREE_PLAN_LIMITS = {};export const PRO_PLAN_LIMITS = {- users: 2,+ users: 1,links: null,- documents: 100,- domains: 2,+ documents: 300,+ domains: 0,datarooms: 0,customDomainOnPro: false,customDomainInDataroom: false,diff --git a/ee/limits/server.ts b/ee/limits/server.tsindex 5592b517..f63d33f4 100644--- a/ee/limits/server.ts+++ b/ee/limits/server.ts@@ -28,11 +28,11 @@ const configSchema = z.object({links: z.preprocess((v) => (v === null ? Infinity : Number(v)), z.number()).optional()- .default(10),+ .default(50),documents: z.preprocess((v) => (v === null ? Infinity : Number(v)), z.number()).optional()- .default(10),+ .default(50),users: z.number(),domains: z.number(),customDomainOnPro: z.boolean(),@@ -111,9 +111,8 @@ export async function getLimits({return {...parsedData,// if account is paid, but link and document limits are not set, then set them to Infinity- links: parsedData.links === 10 ? Infinity : parsedData.links,- documents:- parsedData.documents === 10 ? Infinity : parsedData.documents,+ links: parsedData.links > 50 ? Infinity : parsedData.links,+ documents: parsedData.documents > 300 ? Infinity : parsedData.documents,usage: { documents: documentCount, links: linkCount },};}diff --git a/lib/stripe/client.ts b/ee/stripe/client.tssimilarity index 100%rename from lib/stripe/client.tsrename to ee/stripe/client.tsdiff --git a/ee/stripe/functions/get-subscription-item.ts b/ee/stripe/functions/get-subscription-item.tsnew file mode 100644index 00000000..782a6b68--- /dev/null+++ b/ee/stripe/functions/get-subscription-item.ts@@ -0,0 +1,11 @@+import { stripeInstance } from "..";++export default async function getSubscriptionItem(+ subscriptionId: string,+ isOldAccount: boolean,+) {+ const stripe = stripeInstance(isOldAccount);+ const subscription = await stripe.subscriptions.retrieve(subscriptionId);+ const subscriptionItemId = subscription.items.data[0].id;+ return subscriptionItemId;+}diff --git a/lib/stripe/index.ts b/ee/stripe/index.tssimilarity index 100%rename from lib/stripe/index.tsrename to ee/stripe/index.tsdiff --git a/lib/stripe/utils.ts b/ee/stripe/utils.tssimilarity index 88%rename from lib/stripe/utils.tsrename to ee/stripe/utils.tsindex 05ec486b..e26a540f 100644--- a/lib/stripe/utils.ts+++ b/ee/stripe/utils.ts@@ -53,33 +53,37 @@ export const PLANS = [{name: "Pro",slug: "pro",- minQuantity: 2,+ minQuantity: 1,price: {monthly: {- amount: 39,+ amount: 29,unitPrice: 1950,priceIds: {test: {old: "price_1Q3bcHFJyGSZ96lhElXBA5C1",- new: "price_1Q8aUBBYvhH6u7U7LPIVxYpz",+ // new: "price_1Q8aUBBYvhH6u7U7LPIVxYpz",+ new: "price_1QvgdNBYvhH6u7U7drrXAXM3", // exp},production: {old: "price_1P3FK4FJyGSZ96lhD67yF3lj",- new: "price_1Q8egtBYvhH6u7U7gq1Pbp5Z",+ // new: "price_1Q8egtBYvhH6u7U7gq1Pbp5Z",+ new: "price_1Qvk3LBYvhH6u7U7JE4V6JY0", // exp},},},yearly: {- amount: 29,+ amount: 24,unitPrice: 1450,priceIds: {test: {old: "price_1Q3bV9FJyGSZ96lhCYWIcmg5",- new: "price_1Q8aTkBYvhH6u7U7kUiNTSLX",+ // new: "price_1Q8aTkBYvhH6u7U7kUiNTSLX",+ new: "price_1QviTtBYvhH6u7U79PQ2rzMI", // exp},production: {old: "price_1Q3gfNFJyGSZ96lh2jGhEadm",- new: "price_1Q8egtBYvhH6u7U7T4ehn7SM",+ // new: "price_1Q8egtBYvhH6u7U7T4ehn7SM",+ new: "price_1Qvk3LBYvhH6u7U7kppryTjV", // exp},},},diff --git a/lib/stripe/webhooks/checkout-session-completed.ts b/ee/stripe/webhooks/checkout-session-completed.tssimilarity index 98%rename from lib/stripe/webhooks/checkout-session-completed.tsrename to ee/stripe/webhooks/checkout-session-completed.tsindex 33bf5585..e54421af 100644--- a/lib/stripe/webhooks/checkout-session-completed.ts+++ b/ee/stripe/webhooks/checkout-session-completed.ts@@ -3,11 +3,11 @@ import {DATAROOMS_PLAN_LIMITS,PRO_PLAN_LIMITS,} from "@/ee/limits/constants";+import { stripeInstance } from "@/ee/stripe";import Stripe from "stripe";import { sendUpgradePlanEmail } from "@/lib/emails/send-upgrade-plan";import prisma from "@/lib/prisma";-import { stripeInstance } from "@/lib/stripe";import { log } from "@/lib/utils";import { getPlanFromPriceId } from "../utils";diff --git a/lib/stripe/webhooks/customer-subscription-deleted.ts b/ee/stripe/webhooks/customer-subscription-deleted.tssimilarity index 100%rename from lib/stripe/webhooks/customer-subscription-deleted.tsrename to ee/stripe/webhooks/customer-subscription-deleted.tsdiff --git a/lib/stripe/webhooks/customer-subscription-updated.ts b/ee/stripe/webhooks/customer-subscription-updated.tssimilarity index 95%rename from lib/stripe/webhooks/customer-subscription-updated.tsrename to ee/stripe/webhooks/customer-subscription-updated.tsindex 85d3e448..a2587776 100644--- a/lib/stripe/webhooks/customer-subscription-updated.ts+++ b/ee/stripe/webhooks/customer-subscription-updated.ts@@ -112,4 +112,13 @@ export async function customerSubsciptionUpdated(},});}++ // Update the subscription start and end dates+ await prisma.team.update({+ where: { stripeId },+ data: {+ startsAt,+ endsAt,+ },+ });}diff --git a/lib/swr/use-billing.ts b/lib/swr/use-billing.tsindex f3f22791..6146a4b7 100644--- a/lib/swr/use-billing.ts+++ b/lib/swr/use-billing.ts@@ -44,6 +44,7 @@ type PlanWithOld = `${BasePlan}+old` | `${BasePlan}+drtrial+old`;type PlanResponse = {plan: BasePlan | PlanWithTrial | PlanWithOld;isCustomer: boolean;+ subscriptionCycle: "monthly" | "yearly";};interface PlanDetails {@@ -79,10 +80,11 @@ export function usePlan() {: { plan: null, trial: null, old: false };return {- plan: parsedPlan.plan,+ plan: parsedPlan.plan ?? "free",trial: parsedPlan.trial,isOldAccount: parsedPlan.old,isCustomer: plan?.isCustomer,+ isAnnualPlan: plan?.subscriptionCycle === "yearly",loading: !plan && !error,error,};diff --git a/lib/types.ts b/lib/types.tsindex ed30c93c..dc77590d 100644--- a/lib/types.ts+++ b/lib/types.ts@@ -264,6 +264,7 @@ export type AnalyticsEvents =| {event: "Stripe Billing Portal Clicked";teamId: string;+ action?: string;};export interface Team {diff --git a/pages/api/stripe/webhook-old.ts b/pages/api/stripe/webhook-old.tsindex b043c3f4..47c4bd9d 100644--- a/pages/api/stripe/webhook-old.ts+++ b/pages/api/stripe/webhook-old.ts@@ -1,12 +1,12 @@import { NextApiRequest, NextApiResponse } from "next";+import { stripeInstance } from "@/ee/stripe";+import { checkoutSessionCompleted } from "@/ee/stripe/webhooks/checkout-session-completed";+import { customerSubscriptionDeleted } from "@/ee/stripe/webhooks/customer-subscription-deleted";+import { customerSubsciptionUpdated } from "@/ee/stripe/webhooks/customer-subscription-updated";import { Readable } from "node:stream";import type Stripe from "stripe";-import { stripeInstance } from "@/lib/stripe";-import { checkoutSessionCompleted } from "@/lib/stripe/webhooks/checkout-session-completed";-import { customerSubscriptionDeleted } from "@/lib/stripe/webhooks/customer-subscription-deleted";-import { customerSubsciptionUpdated } from "@/lib/stripe/webhooks/customer-subscription-updated";import { log } from "@/lib/utils";// Stripe requires the raw body to construct the event.diff --git a/pages/api/stripe/webhook.ts b/pages/api/stripe/webhook.tsindex d013c78c..d8eca84f 100644--- a/pages/api/stripe/webhook.ts+++ b/pages/api/stripe/webhook.ts@@ -1,12 +1,12 @@import { NextApiRequest, NextApiResponse } from "next";+import { stripeInstance } from "@/ee/stripe";+import { checkoutSessionCompleted } from "@/ee/stripe/webhooks/checkout-session-completed";+import { customerSubscriptionDeleted } from "@/ee/stripe/webhooks/customer-subscription-deleted";+import { customerSubsciptionUpdated } from "@/ee/stripe/webhooks/customer-subscription-updated";import { Readable } from "node:stream";import type Stripe from "stripe";-import { stripeInstance } from "@/lib/stripe";-import { checkoutSessionCompleted } from "@/lib/stripe/webhooks/checkout-session-completed";-import { customerSubscriptionDeleted } from "@/lib/stripe/webhooks/customer-subscription-deleted";-import { customerSubsciptionUpdated } from "@/lib/stripe/webhooks/customer-subscription-updated";import { log } from "@/lib/utils";// Stripe requires the raw body to construct the event.diff --git a/pages/api/teams/[teamId]/billing/manage.ts b/pages/api/teams/[teamId]/billing/manage.tsindex 9d0efa9c..60ee008d 100644--- a/pages/api/teams/[teamId]/billing/manage.ts+++ b/pages/api/teams/[teamId]/billing/manage.ts@@ -1,13 +1,14 @@import { NextApiRequest, NextApiResponse } from "next";+import { stripeInstance } from "@/ee/stripe";+import getSubscriptionItem from "@/ee/stripe/functions/get-subscription-item";+import { PLANS, isOldAccount } from "@/ee/stripe/utils";import { waitUntil } from "@vercel/functions";import { getServerSession } from "next-auth/next";import { identifyUser, trackAnalytics } from "@/lib/analytics";import { errorhandler } from "@/lib/errorHandler";import prisma from "@/lib/prisma";-import { stripeInstance } from "@/lib/stripe";-import { isOldAccount } from "@/lib/stripe/utils";import { CustomUser } from "@/lib/types";import { authOptions } from "../../../auth/[...nextauth]";@@ -29,7 +30,10 @@ export default async function handle(return;}- const { teamId } = req.query as { teamId: string };+ const { teamId, proAnnualBanner } = req.query as {+ teamId: string;+ proAnnualBanner?: string;+ };const userId = (session.user as CustomUser).id;const userEmail = (session.user as CustomUser).email;try {@@ -44,6 +48,7 @@ export default async function handle(},select: {stripeId: true,+ subscriptionId: true,plan: true,},});@@ -55,10 +60,51 @@ export default async function handle(return res.status(400).json({ error: "No Stripe customer ID" });}+ if (!team.subscriptionId) {+ return res.status(400).json({ error: "No subscription ID" });+ }++ let priceId: string | undefined;+ let subscriptionItemId: string | undefined;+ if (!!proAnnualBanner) {+ priceId = PLANS.find((p) => p.name === "Pro")?.price.yearly.priceIds[+ process.env.NEXT_PUBLIC_VERCEL_ENV === "production"+ ? "production"+ : "test"+ ][isOldAccount(team.plan) ? "old" : "new"];++ subscriptionItemId = await getSubscriptionItem(+ team.subscriptionId,+ isOldAccount(team.plan),+ );+ }+const stripe = stripeInstance(isOldAccount(team.plan));const { url } = await stripe.billingPortal.sessions.create({customer: team.stripeId,- return_url: `${process.env.NEXTAUTH_URL}/settings/billing`,+ return_url: `${process.env.NEXTAUTH_URL}/settings/billing?cancel=true`,+ ...(!!proAnnualBanner &&+ subscriptionItemId && {+ flow_data: {+ type: "subscription_update_confirm",+ subscription_update_confirm: {+ subscription: team.subscriptionId,+ items: [+ {+ id: subscriptionItemId,+ quantity: 1,+ price: priceId,+ },+ ],+ },+ after_completion: {+ type: "redirect",+ redirect: {+ return_url: `${process.env.NEXTAUTH_URL}/settings/billing?success=true`,+ },+ },+ },+ }),});waitUntil(identifyUser(userEmail ?? userId));@@ -66,6 +112,7 @@ export default async function handle(trackAnalytics({event: "Stripe Billing Portal Clicked",teamId,+ action: !!proAnnualBanner ? "pro-annual-banner" : undefined,}),);diff --git a/pages/api/teams/[teamId]/billing/plan.ts b/pages/api/teams/[teamId]/billing/plan.tsindex dc12cde7..d3c9a195 100644--- a/pages/api/teams/[teamId]/billing/plan.ts+++ b/pages/api/teams/[teamId]/billing/plan.ts@@ -35,12 +35,29 @@ export default async function handle(select: {plan: true,stripeId: true,+ startsAt: true,+ endsAt: true,},});const isCustomer = !!team?.stripeId;- return res.status(200).json({ plan: team?.plan, isCustomer });+ // calculate the plan cycle either yearly or monthly based on the startsAt and endsAt dates+ let subscriptionCycle = "monthly";+ if (team?.startsAt && team?.endsAt) {+ const durationInDays = Math.round(+ (team.endsAt.getTime() - team.startsAt.getTime()) /+ (1000 * 60 * 60 * 24),+ );+ // If duration is more than 31 days, consider it yearly+ subscriptionCycle = durationInDays > 31 ? "yearly" : "monthly";+ }++ return res.status(200).json({+ plan: team?.plan,+ isCustomer,+ subscriptionCycle,+ });} catch (error) {errorhandler(error, res);}diff --git a/pages/api/teams/[teamId]/billing/upgrade.ts b/pages/api/teams/[teamId]/billing/upgrade.tsindex 5d60ca2a..4e1b5d42 100644--- a/pages/api/teams/[teamId]/billing/upgrade.ts+++ b/pages/api/teams/[teamId]/billing/upgrade.ts@@ -1,12 +1,12 @@import { NextApiRequest, NextApiResponse } from "next";+import { stripeInstance } from "@/ee/stripe";+import { getPlanFromPriceId, isOldAccount } from "@/ee/stripe/utils";import { waitUntil } from "@vercel/functions";import { getServerSession } from "next-auth/next";import { identifyUser, trackAnalytics } from "@/lib/analytics";import prisma from "@/lib/prisma";-import { stripeInstance } from "@/lib/stripe";-import { getPlanFromPriceId, isOldAccount } from "@/lib/stripe/utils";import { CustomUser } from "@/lib/types";import { authOptions } from "../../../auth/[...nextauth]";@@ -61,13 +61,14 @@ export default async function handle(const lineItem = {price: priceId,quantity: oldAccount ? 1 : minimumQuantity,- ...(!oldAccount && {- adjustable_quantity: {- enabled: true,- minimum: minimumQuantity,- maximum: 99,- },- }),+ ...(!oldAccount &&+ minimumQuantity > 1 && {+ adjustable_quantity: {+ enabled: true,+ minimum: minimumQuantity,+ maximum: 99,+ },+ }),};const stripe = stripeInstance(oldAccount);diff --git a/pages/api/teams/[teamId]/index.ts b/pages/api/teams/[teamId]/index.tsindex a5fdb32b..195d3979 100644--- a/pages/api/teams/[teamId]/index.ts+++ b/pages/api/teams/[teamId]/index.ts@@ -1,5 +1,7 @@import { NextApiRequest, NextApiResponse } from "next";+import { cancelSubscription } from "@/ee/stripe";+import { isOldAccount } from "@/ee/stripe/utils";import { DocumentStorageType } from "@prisma/client";import { getServerSession } from "next-auth";@@ -7,8 +9,6 @@ import { removeDomainFromVercelProject } from "@/lib/domains";import { errorhandler } from "@/lib/errorHandler";import { deleteFiles } from "@/lib/files/delete-team-files-server";import prisma from "@/lib/prisma";-import { cancelSubscription } from "@/lib/stripe";-import { isOldAccount } from "@/lib/stripe/utils";import { CustomUser } from "@/lib/types";import { unsubscribe } from "@/lib/unsend";diff --git a/pages/settings/billing.tsx b/pages/settings/billing.tsxindex 326cb231..45e42089 100644--- a/pages/settings/billing.tsx+++ b/pages/settings/billing.tsx@@ -7,6 +7,7 @@ import { useTeam } from "@/context/team-context";import { CheckIcon } from "lucide-react";import { toast } from "sonner";+import UpgradePlanContainer from "@/components/billing/upgrade-plan-container";import {PlanEnum,UpgradePlanModal,@@ -109,8 +110,8 @@ export default function Billing() {featureIntro: "What's included:",features: ["1 user",- "10 links",- "10 documents",+ "50 links",+ "50 documents","Unlimited visitors","Page-by-page analytics","Document sharing controls",@@ -133,13 +134,13 @@ export default function Billing() {description: "The branded experience for your documents.",featureIntro: "Everything in Free, plus:",features: [- "2 users included",+ "1 user included","Unlimited links",- "100 documents",+ "300 documents","Custom branding","Folder organization",- "Require email verification",- "More file types: pppt, docx, excel",+ // "Require email verification",+ "More file types: ppt, docx, excel","Papermark branding removed","1-year analytics retention",],@@ -226,211 +227,7 @@ export default function Billing() {<main className="relative mx-2 mb-10 mt-4 space-y-8 overflow-hidden px-1 sm:mx-3 md:mx-5 md:mt-5 lg:mx-7 lg:mt-8 xl:mx-10"><SettingsHeader />- <div>- <div className="mb-4 flex items-center justify-between md:mb-8 lg:mb-12">- <div className="space-y-1">- <h3 className="text-2xl font-semibold tracking-tight text-foreground">- Billing- </h3>- <div className="flex items-center space-x-2">- <p className="text-sm text-muted-foreground">- Manage your subscription and billing information.- </p>- <Link- href="/settings/upgrade"- className="text-sm text-foreground underline-offset-4 hover:underline"- >- See all plans- </Link>- </div>- </div>- </div>-- <div className="bg-white dark:bg-gray-900">- <div className="mx-auto space-y-8">- <div className="isolate grid grid-cols-1 overflow-hidden rounded-xl border border-black dark:border-muted-foreground md:grid-cols-4">- {tiers.map((tier) => (- <div- key={tier.id}- className="flex flex-col justify-between border-r-0 border-black dark:border-muted-foreground md:border-r md:last:!border-r-0"- >- <div>- <div className="border-b border-black bg-gray-100 p-6 dark:border-muted-foreground dark:bg-gray-500">- <h3- id={tier.id}- className="flex items-center gap-x-2 text-balance text-xl leading-8 text-foreground"- >- <span>{tier.name}</span>- {tier.currentPlan ? (- <Badge className="rounded-md">Current Plan</Badge>- ) : null}- </h3>- </div>- <div className="p-6">- <div className="mt-2">- {tier.id === "tier-enterprise" ? (- <div className="min-h-12">- <div className="flex flex-col text-sm">- <div className="h-6"></div>- <h4>Get in touch</h4>- </div>- </div>- ) : null}- </div>-- {/* <p className="mt-4 text-balance text-sm leading-6 text-gray-600 dark:text-muted-foreground">- {tier.description}- </p> */}- <ul- role="list"- className="mt-8 space-y-3 text-sm leading-6 text-gray-600 dark:text-muted-foreground"- >- <li>{tier.featureIntro}</li>- {tier.features.map((feature) => (- <li key={feature} className="flex gap-x-3">- <CheckIcon- className="h-6 w-5 flex-none text-[#fb7a00]"- aria-hidden="true"- />- <span>{feature}</span>- </li>- ))}- </ul>- </div>- </div>- <div className="p-6">- {tier.id !==- "tier-free" /** hide button on free tier */ ? (- tier.currentPlan && isCustomer ? (- <Button- className="rounded-3xl"- loading={clicked}- onClick={() => {- setClicked(true);- fetch(- `/api/teams/${teamInfo?.currentTeam?.id}/billing/manage`,- {- method: "POST",- },- )- .then(async (res) => {- const url = await res.json();- router.push(url);- })- .catch((err) => {- alert(err);- setClicked(false);- });- }}- >- {clicked- ? "Redirecting to Customer Portal..."- : "Manage Subscription"}- </Button>- ) : plan !== "free" && isCustomer ? (- <Button- className="rounded-3xl"- variant={- tier.id === "tier-business" ? "orange" : "default"- }- loading={clicked}- onClick={() => {- setClicked(true);- fetch(- `/api/teams/${teamInfo?.currentTeam?.id}/billing/manage`,- {- method: "POST",- },- )- .then(async (res) => {- const url = await res.json();- router.push(url);- })- .catch((err) => {- alert(err);- setClicked(false);- });- }}- >- {clicked- ? "Redirecting to Customer Portal..."- : tier.buttonText}- </Button>- ) : (- <UpgradePlanModal- clickedPlan={tier.name as PlanEnum}- trigger={"billing_page"}- >- <Button- className="rounded-3xl"- variant={- tier.id === "tier-business"- ? "orange"- : "default"- }- >- {tier.buttonText}- </Button>- </UpgradePlanModal>- )- ) : null}- </div>- </div>- ))}- </div>- <div className="isolate grid grid-cols-1 overflow-hidden rounded-xl border border-black dark:border-muted-foreground">- <div- key="tier-enterprise"- className="flex flex-col justify-between border-r-0 border-black dark:border-muted-foreground md:border-r md:last:!border-r-0"- >- <div>- <div className="border-b border-black bg-gray-100 p-6 dark:border-muted-foreground dark:bg-gray-800">- <h3- id="tier-enterprise"- className="flex items-center gap-x-2 text-balance text-xl leading-8 text-foreground"- >- <span>Enterprise</span>- </h3>- </div>- <div className="p-6">- <p className="mt-4 text-balance text-sm leading-6 text-gray-600 dark:text-muted-foreground">- Self-hosted and advanced document infrastructure for- your company.- </p>- <p className="mt-6 flex items-baseline gap-x-1">- <span className="text-balance text-4xl font-medium text-foreground">- Custom- </span>- </p>- <ul- role="list"- className="mt-8 grid grid-cols-1 gap-y-3 text-sm leading-6 text-gray-600 dark:text-muted-foreground sm:grid-cols-2 md:grid-cols-3"- >- {enterpriseFeatures.map((feature) => (- <li key={feature} className="flex gap-x-3">- <CheckIcon- className="h-6 w-5 flex-none text-[#fb7a00]"- aria-hidden="true"- />- <span>{feature}</span>- </li>- ))}- </ul>- </div>- </div>- <div className="p-6">- <Link- href="https://cal.com/marcseitz/papermark"- target="_blank"- >- <Button className="rounded-3xl">Talk to us</Button>- </Link>- </div>- </div>- </div>- </div>- </div>- </div>+ <UpgradePlanContainer /></main></AppLayout>);diff --git a/pages/settings/upgrade.tsx b/pages/settings/upgrade.tsxindex 6356f916..c6cf98ca 100644--- a/pages/settings/upgrade.tsx+++ b/pages/settings/upgrade.tsx@@ -4,14 +4,14 @@ import { useMemo, useState } from "react";import React from "react";import { useTeam } from "@/context/team-context";+import { getStripe } from "@/ee/stripe/client";+import { PLANS } from "@/ee/stripe/utils";import { CheckIcon } from "lucide-react";import { Button } from "@/components/ui/button";import { Switch } from "@/components/ui/switch";import { useAnalytics } from "@/lib/analytics";-import { getStripe } from "@/lib/stripe/client";-import { PLANS } from "@/lib/stripe/utils";import { usePlan } from "@/lib/swr/use-billing";import { capitalize } from "@/lib/utils";@@ -28,13 +28,13 @@ export default function UpgradePage() {Pro: {featureIntro: "Everything in Free, plus:",features: [- "2 users included",- "100 documents",+ "1 user included",+ "300 documents","Unlimited links","Custom branding","Folder organization",- "Require email verification",- "More file types: pppt, docx, excel",+ // "Require email verification",+ "More file types: ppt, docx, excel","Papermark branding removed","1-year analytics retention",],