Commit Graph

642 Commits

Author SHA1 Message Date
Fabien O'Carroll
41bdd38237 Wired up member-analytics-service
refs https://github.com/TryGhost/Team/issues/1054

We need to instantiate the MemberAnalyticsService so that we can start
listening to events and storing them, this is the minium glue code
required to get us going.
2021-09-21 13:40:23 +02:00
Fabien O'Carroll
bdd030cce5 Published new versions
- @tryghost/domain-events@0.1.0
 - @tryghost/member-events@0.1.0
 - @tryghost/members-api@1.35.0
2021-09-17 15:25:14 +02:00
Fabien 'egg' O'Carroll
528fd23874 Added ability to fetch member by identity token (#329)
refs https://github.com/TryGhost/Team/issues/1057

This method will validate a token, and then return the member associated
with it. Rather than exposing token validation and coupling consumers to
the structure of the token response data.
2021-09-17 11:25:57 +02:00
Fabien O'Carroll
d99e0acf1a Published new versions
- @tryghost/members-api@1.34.0
2021-09-14 13:22:21 +02:00
Fabien 'egg' O'Carroll
1f2750e5c0 Added browse, edit & add methods to MemberBREADService (#326)
refs https://github.com/TryGhost/Team/issues/873

This ensures that all requests to the API will include the mock
subscriptions for comped members. Allowing the Admin to correctly show
the subscription information after adding and editing members. As well
as having the correct information when navigating from the list of
members to an individual member.
2021-09-14 13:18:34 +02:00
Fabien O'Carroll
81f19f4991 Published new versions
- @tryghost/members-api@1.33.0
2021-09-13 14:47:49 +02:00
Fabien O'Carroll
7a401e5253 Used @tryghost/stripe-service in @tryghost/members-api
no-issue

This finalises the extraction of the StripeAPIService to a separate
package!
2021-09-13 14:38:40 +02:00
Fabien O'Carroll
eed346e4ec Published new versions
- @tryghost/members-api@1.32.1
2021-09-08 12:39:51 +02:00
Fabien O'Carroll
00e0c9d205 Fixed webhook handler check for if Stripe configured
no-issue

Previously we would not create an instance of the StripeAPIService if
Stripe was not configured, but that is not the case any more, instead we
have a configured flag on the service. The webhook route handler was not
updated to use this flag and so would attempt to handle webhooks without
having any of the required data. This would result in an uncaught error.
2021-09-08 12:27:09 +02:00
Fabien O'Carroll
a072d19385 Published new versions
- @tryghost/members-api@1.32.0
2021-09-07 18:26:36 +02:00
Fabien O'Carroll
67d2104190 Deleted webhooks when disconnecting from Stripe
refs https://github.com/TryGhost/Team/issues/1006

When disconnecting from Stripe, we currently do not remove the webhooks,
this will result in the webhooks from Stripe failing, and tending toward
a 100% error rate, which will ultimately result in emails from Stripe
about the failing webhook.

In order to stop all of that from happening, we should make sure that we
actively remove the webhook from Stripe when disconnecting.
2021-09-07 18:02:35 +02:00
Fabien O'Carroll
2d394b3a2e Published new versions
- @tryghost/members-api@1.31.0
2021-09-07 16:51:25 +02:00
Fabien O'Carroll
8476e7cbd7 Added disconnectStripe method to handle cleaning up
refs https://github.com/TryGhost/Team/issues/1006

As part of the work to handle cleaning up webhooks when we disconnect
from Stripe, I'm moving the logic to clear out the Stripe related data
from the database into a disconnectStripe method. This then allows us to
start handling the cleanup of webhooks via the Stripe API.
2021-09-07 16:34:08 +02:00
Fabien O'Carroll
ae1f905766 Published new versions
- @tryghost/members-api@1.29.3
2021-09-06 13:10:42 +02:00
Fabien O'Carroll
b6e4eae272 Fixed comped members having a status of 'paid'
refs https://github.com/TryGhost/Team/issues/995

Since we reintroduced the comped status, we did not update the
subscription handling to correctly set members to a status of comped
when they were on a 'Complimentary' plan.
2021-09-06 13:06:30 +02:00
Fabien O'Carroll
dbae9f3233 Published new versions
- @tryghost/members-api@1.29.2
2021-09-06 12:50:25 +02:00
Fabien O'Carroll
66143dbb7c Updated options parameter to be optional
no-issue

Since updating the product repository to force transactions, the options
parameter was used in every call, meaning it wasn't optional any more,
which broke usage. This updates the parameter to have a default so that
existing usage still works.
2021-09-06 12:47:19 +02:00
Fabien O'Carroll
537c9cb02d Published new versions
- @tryghost/magic-link@1.0.11
 - @tryghost/members-api@1.29.1
 - @tryghost/members-csv@1.1.6
 - @tryghost/members-importer@0.3.2
 - @tryghost/members-ssr@1.0.12
2021-09-01 19:12:44 +02:00
Fabien O'Carroll
3b94ba7dce Fixed update method not using transaction for reads
no-issue

Since we run our product repository methods in transactions now we must
ensure that all database interations in the method use the transaction.
This adds the missing options to the reading of existing prices so that
they happen inside of the transaction.
2021-09-01 19:10:12 +02:00
Renovate Bot
b0133b3c2e Update dependency mocha to v9.1.1 2021-08-31 07:43:26 +00:00
Fabien O'Carroll
c782b3d2c9 Published new versions
- @tryghost/members-api@1.29.0
2021-08-26 20:07:08 +02:00
Fabien O'Carroll
82506e1599 Passed transaction to all model methods
refs https://github.com/TryGhost/Team/issues/982

These calls to the edit method were missing the transaction option from
the parent which meant that they ran outside of the transaction and
would cause the method to timeout.
2021-08-26 20:04:06 +02:00
Fabien O'Carroll
dd4d6aeae5 Wrapped product repo methods in transactions
refs https://github.com/TryGhost/Team/issues/982

This ensures that we will not commit any rows to the database if
something is to go wrong with a Stripe API request.
2021-08-26 20:03:16 +02:00
Fabien O'Carroll
dc79f04989 Published new versions
- @tryghost/members-api@1.28.0
2021-08-26 16:16:00 +02:00
Fabien O'Carroll
ec8dbf2890 Added products as default relation when fetching members
no-issue

As subscriptions are a default relation, and we now require products to
populate subscriptions for comped members, we need to include products
by default when reading members.
2021-08-26 16:10:13 +02:00
Fabien O'Carroll
0f4e97eae7 Updated getMemberIdentityData to use BREAD Service
refs https://github.com/TryGhost/Team/issues/986

The getMemberIdentityData is a relic of time past. Originally it was
used before we had anything like the member repository or bread
controller as a way for things inside of the Members ecosystem to get
access to member data.

This updates it to use the same interface as everything else for
fetching members so that we can rely on the shape of the data that we
consider a member.

This update will ensure that themes have access to the dummy
subscriptions created by the `read` method of the MemberBREADService.
2021-08-26 16:07:06 +02:00
Fabien O'Carroll
fa73786c92 Published new versions
- @tryghost/members-api@1.27.3
2021-08-26 15:54:13 +02:00
Fabien O'Carroll
d3b1283241 Removed old product when subscription is updated
refs https://github.com/TryGhost/Team/issues/979

This correctly handles updates to subscriptions so that if the product a
subscription is for has changed, we will remove the previous product, if
and only if there is not another subscription which gives access to it.
2021-08-26 15:53:38 +02:00
Fabien O'Carroll
16d67203cf Published new versions
- @tryghost/members-api@1.27.2
2021-08-26 13:03:41 +02:00
Fabien O'Carroll
83d4b5f834 Handled missing data in read method bread service
refs https://github.com/TryGhost/Team/issues/873

The `get` method of the member repository will return null when no
member is found - we must ensure that we don't attempt to call toJSON!

It is also possible for a member to not have any products, in which case
we should not attempt to iterate over them, and we can return early.
2021-08-26 12:58:39 +02:00
Fabien O'Carroll
58c06bce2e Published new versions
- @tryghost/members-api@1.27.1
2021-08-26 11:54:51 +02:00
Fabien O'Carroll
3a91687b08 Used current time for created_at for missing events
refs https://github.com/TryGhost/Team/issues/873

This is an unexpected state, but possible if the alpha version of tier
has been enabled previous to the events being added.
2021-08-26 11:52:53 +02:00
Fabien O'Carroll
40699893ba Published new versions
- @tryghost/members-api@1.27.0
2021-08-25 23:27:47 +02:00
Fabien O'Carroll
86f5879432 Added dummy subscriptions for comped members
refs https://github.com/TryGhost/Team/issues/873

This adds a dummy subscription for each product that a member has
without an associated stripe subscription. It allows clients to deal
with things like a created date for comped members.
2021-08-25 21:26:04 +02:00
Fabien O'Carroll
c17442cf4b Added memberService to members-api
no-issue

The idea of this service is to sit infront of the repository and handle
application logic which does not belong at the data layer. The exact
naming and structure is TBC but this gives us a place to start pulling
logic out of the controllers, without having to mash it all into the
repository.

Also important to note is that is does not return instances of bookshelf
models, but a JSON representation of the model, this allows us to not
leak internal implementation to consumers.
2021-08-25 21:25:19 +02:00
Fabien O'Carroll
a2120fc2d6 Published new versions
- @tryghost/members-api@1.26.0
2021-08-24 15:12:48 +02:00
Fabien O'Carroll
d55e828b34 Wired up MemberProductEvents to MemberRepository
refs https://github.com/TryGhost/Team/issues/873

This handles the creation of product events when a members access to
products is changed. This can happen on creation, update, and any
changes to stripe subscriptions.

We manually workout the difference between the current products and the
new products, and add the events accordingly.
2021-08-24 14:57:04 +02:00
Fabien O'Carroll
df753df87a Published new versions
- @tryghost/magic-link@1.0.10
 - @tryghost/members-api@1.25.2
 - @tryghost/members-csv@1.1.5
 - @tryghost/members-importer@0.3.1
 - @tryghost/members-ssr@1.0.11
2021-08-23 14:49:21 +02:00
Fabien O'Carroll
4b219626eb Fixed usage of bson-objectid
no-issue

Calling ObjectId doesn't return a string a but an ObjectId object.
Whilst this object is cast to a string via the toJSON and toString
methods, this is not enough for MySQL. Instead we should explicitly cast
this to a string ourselves and the application level.
2021-08-23 14:46:53 +02:00
Renovate Bot
2b15530e82 Update dependency mocha to v9.1.0 2021-08-23 02:56:38 +00:00
Naz
fe25f02d86 Published new versions
- @tryghost/magic-link@1.0.9
 - @tryghost/members-api@1.25.1
 - @tryghost/members-csv@1.1.4
 - @tryghost/members-importer@0.3.0
 - @tryghost/members-ssr@1.0.10
2021-08-20 17:31:40 +04:00
Daniel Lockyer
6e4437c7e4 Added c8 test coverage
refs https://github.com/TryGhost/Team/issues/870

- using `c8` allows us to see test coverage for all packages in the repo
- this commit adds `c8` as a dev dependency and prepends the `mocha`
  command with `c8` so it runs on all tests
2021-08-20 10:28:07 +02:00
Fabien O'Carroll
df8136804d Published new versions
- @tryghost/members-api@1.25.0
2021-08-16 20:06:49 +02:00
Fabien 'egg' O'Carroll
4a8ec62317 Added bulkEdit method to MemberRepository
refs https://github.com/TryGhost/Team/issues/946

This adds the bulk edit method which handles bulk edit operations to members
to be used by the filtering feature. They have been combined into a single method
as that is how they are exposed to the API. This is definitely a candidate for a
refactor in the form of a service in front of the repository.
2021-08-16 19:05:48 +01:00
Fabien O'Carroll
be55c4e184 Published new versions
- @tryghost/members-api@1.24.1
2021-08-13 13:26:47 +02:00
Fabien O'Carroll
6540fd0cd0 Updated bulkDestroy method to handle model updates
refs https://github.com/TryGhost/Ghost/commit/1dd52075

- Fixes bulkDestroy being passed the context
- Fixes passing options.search to the model layer
- Updates return value since the changes in referenced commit
2021-08-13 13:23:01 +02:00
Fabien O'Carroll
7ee0df2ce6 Published new versions
- @tryghost/members-api@1.24.0
2021-08-12 13:58:53 +02:00
Fabien O'Carroll
6bb3407725 Added bulkDestroy method to Member Repository
no-issue

The logic for bulk destroy is currently incorrectly inside of the
members api controller in Ghost core. Moving it out to here allows us to
simplify the controller to rely on the service, rather than implement
the logic.
2021-08-12 13:57:45 +02:00
Fabien O'Carroll
daa3bb405d Published new versions
- @tryghost/members-api@1.23.3
2021-08-11 13:00:39 +02:00
Fabien O'Carroll
f4b7dfd08c Fixed status when subscriptions are canceled
refs https://github.com/TryGhost/Team/issues/959

Because we were using the pre-existing products to determine a members
status, instead of the products _after_ we have handled the updates to
subscriptions, members with a paid subscription which was later canceled
were changed to 'comped' rather than 'free'. This adds a final check to
set a member to 'free' if their new set of products is empty.
2021-08-11 11:59:32 +01:00
Naz
8fbd24626d Published new versions
- @tryghost/magic-link@1.0.8
 - @tryghost/members-api@1.23.2
 - @tryghost/members-csv@1.1.3
 - @tryghost/members-importer@0.1.2
 - @tryghost/members-ssr@1.0.9
2021-07-28 19:14:58 +04:00
Renovate Bot
e4109e38f3 Update dependency sinon to v11.1.2 2021-07-28 13:54:56 +00:00
Renovate Bot
102568a72a Update dependency mocha to v9.0.3 2021-07-27 04:36:33 +00:00
Rishabh
f90e36b816 Published new versions
- @tryghost/members-api@1.23.1
2021-07-22 12:53:03 +05:30
Rishabh
e28a19178d Added labels/products data to members identity
refs https://github.com/TryGhost/Team/issues/909
refs 3e13a6c562

`labels` and `products` data on member is needed for content gating post access for new segmented access
2021-07-22 12:52:02 +05:30
Rishabh
45ba046ad5 Published new versions
- @tryghost/members-api@1.23.0
2021-07-22 12:33:07 +05:30
Rishabh
3e13a6c562 Removed unused data from members identity data
refs https://github.com/TryGhost/Team/issues/909

The member identity data currently attaches several extra data points to member information which is not used/needed, and causes multiple DB queries on each page load when Portal requests for member via `/members/api/member` endpoint. This change removes all the unused data points on member - `labels`, `stripe_customer`, products`, `stripe_product` cutting DB queries in half.
2021-07-22 12:28:39 +05:30
Fabien O'Carroll
d0f587a6cc Published new versions
- @tryghost/members-api@1.22.1
2021-07-20 12:37:36 +01:00
Fabien O'Carroll
6693d470d0 Removed superfluous benefits relation fetch
refs https://github.com/TryGhost/Team/issues/919

As we pass the `benefits` to the Product model on creation, we do not
need to manually fetch them again. In fact doing so causes a strange SQL
error, where we attempt to run `SELECT undefined.*`.
2021-07-20 12:36:41 +01:00
Fabien O'Carroll
5fc0646d5e Published new versions
- @tryghost/members-api@1.22.0
2021-07-19 13:58:43 +01:00
Fabien O'Carroll
caf059cd7e Added WellKnownController and exposed jwks.json
refs https://github.com/TryGhost/Team/issues/664

The well known controller is designed to handle any requests to the
/.well-known endpoint where the members app is mounted. The first and
only requirement so far is that we expose a JSON Web Key Set so that
external services are able to validate Members JWT's
2021-07-19 13:51:58 +01:00
Rishabh
97be7ca3db Published new versions
- @tryghost/members-api@1.21.0
2021-07-19 17:23:50 +05:30
Rishabh
069accdbe8 Fixed stripe migration to avoid complimentary prices as monthly/yearly price
closes https://github.com/TryGhost/Team/issues/778

- cleans up the stripe migration to add default monthly/yearly prices for sites, which had a possibility of using complimentary (0 amount prices) in edge cases
- adds missing return in the same migration for an unlikely failure to parse stripe plans
2021-07-19 16:20:12 +05:30
Fabien O'Carroll
ceec3efe6a Published new versions
- @tryghost/magic-link@1.0.7
 - @tryghost/members-api@1.20.3
 - @tryghost/members-ssr@1.0.7
2021-07-15 18:19:11 +01:00
Fabien O'Carroll
128ce5db9a Published new versions
- @tryghost/members-api@1.20.2
2021-07-15 18:08:17 +01:00
Fabien O'Carroll
15915a6040 Fixed index.js require
no-issue
2021-07-15 18:06:45 +01:00
Fabien O'Carroll
fe668113b1 Published new versions
- @tryghost/members-api@1.20.1
2021-07-15 18:03:59 +01:00
Fabien O'Carroll
02766afedd Moved MembersAPI.js into lib
no-issue

The previous published version was broken as we only include index.js
and the lib directory in the npm package
2021-07-15 18:01:53 +01:00
Fabien O'Carroll
d59051c104 Published new versions
- @tryghost/magic-link@1.0.6
 - @tryghost/members-api@1.20.0
 - @tryghost/members-csv@1.1.2
 - @tryghost/members-ssr@1.0.6
2021-07-15 16:34:02 +01:00
Fabien O'Carroll
d427e72b1c Fixed created_at dates for member event objects
refs https://github.com/TryGhost/Team/issues/542

Importing members with a created_at date will incorrectly create events
for the member for the date of the import. This updates our event
handling to use either the passed created_at date, or in the case of
subscriptions the start_date of the subscription. We're using start_date
for subscriptions rather than created, as this is more accurate because
start_date works correctly for backdated subscriptions in Stripe.
2021-07-15 15:20:16 +01:00
Rishabh
aad662267c Added migration to remove invalid subscriptions
closes https://github.com/TryGhost/Team/issues/660

All subscriptions in Ghost are expected to have a corresponding price details in `stripe_price` table, which is used to determine the Stripe price a subscription is on. In some edge cases, specially before we started deleted old Stripe data during Stripe disconnect, it's possible that a subscription exists in DB without having a corresponding Stripe price in the DB. These subscriptions are not active for the connected Stripe account, and are save to remove. Going forward, all existing subscriptions with connected account will be removed when disconnecting stripe so we shouldn't have invalid subscriptions in DB in future.

The goal of this migration is to clean all such subscriptions from the DB to avoid any issues around missing price with invalid subscriptions.
2021-07-14 20:12:39 +05:30
Rishabh
aa19008651 Fixed incorrect import path
no refs
2021-07-14 20:01:29 +05:30
Fabien O'Carroll
3e1084905e Removed usage of raw Error class
refs https://github.com/TryGhost/Team/issues/879
2021-07-14 14:17:38 +01:00
Fabien O'Carroll
d51fdc3f4a Moved code out of index.js in directories
refs https://github.com/TryGhost/Team/issues/879
2021-07-14 14:17:38 +01:00
Fabien O'Carroll
13943e9746 Moved MembersAPI out of index.js
refs https://github.com/TryGhost/Team/issues/879
2021-07-14 14:17:38 +01:00
Renovate Bot
223ee56647 Update Test & linting packages 2021-07-14 14:12:12 +01:00
Fabien O'Carroll
e39016423e Removed calls to console.log
refs https://github.com/TryGhost/Team/issues/879
2021-07-14 12:05:07 +01:00
Fabien O'Carroll
6083e4825f Removed trailing commas from .eslintrc.js
refs https://github.com/TryGhost/Team/issues/879
2021-07-14 12:04:46 +01:00
Fabien O'Carroll
8af799bdc9 Published new versions
- @tryghost/members-api@1.19.0
2021-07-06 13:47:38 +01:00
Fabien O'Carroll
dd8376dd90 Restricted Stripe Checkout to members without products
refs https://github.com/TryGhost/Team/issues/858

Replacing the check for subscriptions with products ensures that Stripe
Checkout is not able to be opened by comped members.
2021-07-06 12:59:32 +01:00
Fabien O'Carroll
9841a33c83 Published new versions
- @tryghost/members-api@1.18.1
2021-07-06 11:54:12 +01:00
Fabien O'Carroll
12a3ae77cf Fixed creating members without products
refs https://github.com/TryGhost/Team/issues/790

We were missing a check for the existence of memberData.products before
attempting to read the length property from it, which can result in an
Uncaught TypeError
2021-07-06 11:52:08 +01:00
Fabien O'Carroll
7545e67f2c Published new versions
- @tryghost/magic-link@1.0.5
 - @tryghost/members-api@1.18.0
 - @tryghost/members-csv@1.1.1
 - @tryghost/members-ssr@1.0.5
2021-07-06 11:18:01 +01:00
Fabien O'Carroll
631e78631f Updated linkSubscription to handle comped status
refs https://github.com/TryGhost/Team/issues/790

When linking a subscription to a member we must also update their
status. We could be in one of many states, so we start with the initial
values of either 'free' or 'comped' based on whether the member has any
products. We then make sure to updated the status to 'paid' if we find
any active subscriptions associated with the member, otherwise we leave
it as the initial value.
2021-07-06 11:14:49 +01:00
Fabien O'Carroll
8d8d886705 Supported comped status for create/update methods
refs https://github.com/TryGhost/Team/issues/790

Both creating and updating members only ever need to explicitly set
either the 'comped' or 'free' status as these methods do not deal with
Stripe. When updating a member if the products are not changing, we do
not attempt to change the status either.
2021-07-06 11:14:49 +01:00
Renovate Bot
7f71e28392 Update dependency nock to v13.1.0 2021-06-29 21:43:45 +01:00
Daniel Lockyer
21ec26ea08 Removed used of ghost-ignition dependency
no issue

- we're killing off `ghost-ignition` in favor of explicit packages
  containing its individual components
- this commit switches the Members repo to using the
  `@tryghost/ignition-errors` and `@tryghost/debug` dependencies,
  updates the code with relevant changes and removes the `ghost-ignition`
  dependency
2021-06-29 21:43:05 +01:00
Fabien O'Carroll
5ea642c8c1 Published new versions
- @tryghost/members-api@1.17.0
2021-06-29 15:14:10 +01:00
Fabien O'Carroll
1fbbdcfc2e Included benefits with products when writing
refs https://github.com/TryGhost/Team/issues/806

This allows API consumers to not need to pass an `includes` for benefits
when creating or updating products.
2021-06-29 15:06:35 +01:00
Fabien O'Carroll
4ea7cdc8fe Published new versions
- @tryghost/members-api@1.16.0
2021-06-24 17:13:56 +01:00
Fabien O'Carroll
57233f7295 Updated ProductRepository to support benefits
refs https://github.com/TryGhost/Team/issues/806

We need to explicitly pass data through to the model layer so that the
benefits relation can be handled.
2021-06-24 16:53:56 +01:00
Fabien O'Carroll
45c3de71d6 Published new versions
- @tryghost/magic-link@1.0.4
 - @tryghost/members-api@1.15.0
 - @tryghost/members-ssr@1.0.4
2021-06-16 18:25:48 +01:00
Fabien O'Carroll
83d25f71f4 Restricted Members to only one Product
refs https://github.com/TryGhost/Team/issues/748

This ensures that you cannot add more than one product to a Member.

However it does allow a Member which already exists with more than one
Product to continue using the API. This is to account for edgecases such
as a Member going through the Stripe flow twice and ending up with
multiple subscriptions for multiple products
2021-06-16 15:50:42 +01:00
Fabien O'Carroll
54c3340503 Used tpl & errors packages in MemberRepository
no-issue

Cleaning up this file to be adhere with our new standard for errors.
2021-06-16 15:50:42 +01:00
Fabien O'Carroll
5ad0c624e3 Required no active subscriptions when modifying products
refs https://github.com/TryGhost/Team/issues/748

This ensures that a member cannot be attached to a product directly if
they have active subscriptions.
2021-06-16 15:50:42 +01:00
Fabien O'Carroll
9079a9b9e0 Fixed products being removed when canceling subscriptions
refs https://github.com/TryGhost/Team/issues/748

Previously when a change happened to a subscription the member's
products would be reset purely based on the subscriptions. Since we now
support setting products outside of subscriptions, we must make sure
than a change to a subscription will only affect the product for which
the subscription was for
2021-06-16 15:50:42 +01:00
Fabien O'Carroll
5a74c614c5 Updated event storage to use sharedOptions
no-issue

This makes sure that DB operations can be performed in the same
transaction
2021-06-16 15:50:42 +01:00
Fabien O'Carroll
d064a1ea82 Checked existing subscriptions when updating products
refs https://github.com/TryGhost/Team/issues/748

This ensures that products are not removed from members who have an
active subscription for them.
2021-06-16 15:50:42 +01:00
Fabien O'Carroll
11067c4b08 Updated create & update to accept products
refs https://github.com/TryGhost/Team/issues/748

This allows us to start modifying products directly in order to give
complimentary access without using Stripe
2021-06-16 15:50:42 +01:00
Renovate Bot
f6e12a3da7 Update dependency ghost-ignition to v4.6.3 2021-06-15 18:28:07 +00:00
Fabien O'Carroll
30f835b511 Published new versions
- @tryghost/members-api@1.14.0
2021-06-10 17:15:55 +01:00
Fabien O'Carroll
a4dcb66080 Updated cancelSubscription to take member id
refs https://github.com/TryGhost/Team/issues/775

Exposing this to the Admin API means that we want to be able to cancel
by id, not just email. The same pattern from editSubscription has been
used.
2021-06-10 17:10:58 +01:00
Rishabh
b2fccb2e34 Published new versions
- @tryghost/members-api@1.13.1
2021-06-04 17:18:06 +05:30
Rishabh
d37a470f20 Removed redundant portal plans setting migration
refs 7d8e18c802

Since we have now gone back to using `monthly` / `yearly` named values in portal plan settings instead of price ids, the old portal plan migration which was converting named values to ids is now redundant. Moreoever, the old migration is incorrectly resetting the `portal_plans` setting to `[free]` by removing the paid plans as its not found in `stripePlans` setting anymore.
2021-06-04 17:15:05 +05:30
Rishabh
daeacfbd89 Removed setting existing legacy prices to inactive
refs fd40e04105

The current implementation of setting legacy prices as inactive has a bug where it also sets the active price to inactive if only one of monthly/yearly price is edited while the other is not changed. This is a temporary reversal till we can narrow down the issue and fix to correctly set legacy plans to inactive.
2021-06-04 12:20:22 +05:30
Rishabh
7d8e18c802 Added migration to revert portal_plans setting to named values
closes https://github.com/TryGhost/Team/issues/753

Currently, the portal_plans setting is storing price ids for active monthly/yearly prices for the default product, which was done to allow multiple prices in Portal. Since we only want to limit the prices for a Product to monthly/yearly, we are reverting the earlier migration and only store the available prices as monthly / yearly in portal setting instead of ids. Its also in sync with the approach in theme/API where we use named prices for monthly/yearly instead of price id list.
2021-06-04 12:14:57 +05:30
Fabien O'Carroll
bf4467753a Published new versions
- @tryghost/members-api@1.13.0
2021-06-03 14:46:02 +01:00
Fabien O'Carroll
fd40e04105 Handled monthly and yearly prices in product repo
refs https://github.com/TryGhost/Team/issues/712

This allows prices to be created and assigned to a product as the
default monthly or yearly price.
2021-06-03 14:45:36 +01:00
Fabien O'Carroll
601d40320e Published new versions
- @tryghost/members-api@1.12.0
 - @tryghost/members-csv@1.0.1
2021-06-02 09:57:04 +01:00
Fabien O'Carroll
f660405937 Populated {monthly,yearly}_price_id from settings
refs https://github.com/TryGhost/Team/issues/711

As this migration relies on the settings being populated, it cannot be a
standard migration in Ghost core, as the settings are populated by these
code migrations.
2021-06-02 09:04:54 +01:00
Fabien O'Carroll
c84d7c7c10 Published new versions
- @tryghost/members-api@1.11.1
2021-05-24 17:42:33 +01:00
Fabien O'Carroll
a126764dcd Updated error message for Stripe not connected
refs https://github.com/TryGhost/Team/issues/704

This improves the error messaging by explaining exactly what the problem
is and including a link to our documentation
2021-05-24 17:41:49 +01:00
Fabien O'Carroll
bac55fcfb7 Published new versions
- @tryghost/magic-link@1.0.3
 - @tryghost/members-api@1.11.0
 - @tryghost/members-ssr@1.0.3
2021-05-24 10:34:04 +01:00
Fabien O'Carroll
6fb7b46f39 Uninstalled jsdom
no-issue

This package is no longer used
2021-05-24 10:32:26 +01:00
Renovate Bot
bc99b1810d Update dependency nock to v13 2021-05-24 10:23:22 +01:00
Renovate Bot
26e3834d59 Pin dependency @types/node-jose to 1.1.6 2021-05-24 10:22:07 +01:00
Fabien O'Carroll
40012160ed Errored when Stripe connection is missing and used
refs https://github.com/TryGhost/Team/issues/704

Currently when attempting to create stripe_prices without a Stripe
connection, it will fail silently. This is an issue when initially
configuring Members as the Stripe connection can take some time to be
established. By erroring we allow the client to be notifed that the
connection does not yet exist, so that it can be retried later.
2021-05-24 10:19:55 +01:00
Fabien O'Carroll
7ba838cf4c Published new versions
- @tryghost/members-api@1.10.0
2021-05-20 17:38:21 +01:00
Fabien O'Carroll
98fe7785d6 Handled week & day interval for calculating MRR
refs https://github.com/TryGhost/Team/issues/635

It's possible that we have subscriptions in the system which have been
created externally, and so using an interval of week or day. This change
ensures that we handle the mrr_delta for these subscriptions correctly.
2021-05-20 16:56:14 +01:00
Fabien O'Carroll
f3ecb44e08 Updated migration to use getPrice method
refs https://github.com/TryGhost/Team/issues/657

Since we have removed the getPlan method we need to update the migration
which is the last piece of code which used it. Prices are backwards
compatible with Plans - so this will continue to work as expected.
2021-05-20 15:35:58 +01:00
Fabien O'Carroll
1b628a1637 Refactored Token Service to use async/await
refs https://github.com/TryGhost/Team/issues/657

- Removes the use of "plans" from token service - method wasn't used
- Updates to use async/await so the code is clearer
- Install types for the node-jose module
- Install types for the jsonwebtoken module
2021-05-20 15:18:46 +01:00
Fabien O'Carroll
10b40dfd16 Added comment for deprecation of plan_from_trial
refs https://github.com/TryGhost/Team/issues/657

We must still use the "plan" approach of creating Checkout Sessions so
that we are able to maintain our current functionality of setting the
free trial from the one associated with the Plan/Price used for the
Checkout Session.

In future we would handle free trials internally in Ghost and apply them
on a subscription-by-subscription basis.
2021-05-20 15:15:33 +01:00
Fabien O'Carroll
16b984e2f6 Fixed types for StripeAPIService
no-issue
2021-05-20 15:15:24 +01:00
Fabien O'Carroll
162722b9d3 Removed unused plan related code
refs https://github.com/TryGhost/Team/issues/657

This code is no longer used since we got rid of the StripePlans service
2021-05-20 15:14:24 +01:00
Fabien O'Carroll
98e6ba8028 Published new versions
- @tryghost/members-api@1.9.0
2021-05-20 12:13:13 +01:00
Fabien O'Carroll
26e2cb98e9 Removed environment checks from webhook service
refs https://github.com/TryGhost/Team/issues/598
refs https://github.com/TryGhost/Ghost/commit/5cdf910e

Since we have included these checks in the Ghost codebase we do not need
to run them here.
2021-05-20 12:11:43 +01:00
Fabien O'Carroll
0d3014a87a Published new versions
- @tryghost/members-api@1.8.0
2021-05-19 15:28:17 +01:00
Fabien O'Carroll
ee32528006 Populated members_{monthly,yearly}_price_id settings
refs https://github.com/TryGhost/Team/issues/698

As this migration relies on the `stripe_prices` table being populated,
it can not be in a standard versioned migration in Ghost core.
2021-05-19 15:16:15 +01:00
Fabien O'Carroll
81d96bbdd3 Published new versions
- @tryghost/members-api@1.7.0
2021-05-17 14:52:46 +01:00
Fabien O'Carroll
25d3d42427 Removed use of 'comped' status for Members
refs https://github.com/TryGhost/Team/issues/693

With the new system of Custom Products, the concept of Complimentary is
not longer a thing, and will instead be handled by explicitly creating
prices with no amount. This means that the 'comped' status for members
will be replaced with 'paid'.
2021-05-17 13:06:41 +01:00
Fabien O'Carroll
3beb1b21e7 Published new versions
- @tryghost/members-api@1.6.1
2021-05-11 12:06:56 +01:00
Fabien O'Carroll
d5269d8a9a Fixed finding newly created zero-amount price
no-issue

The condition in the find statement was incorrecly referring to the
subscription rather than the price for the subscription.
2021-05-11 10:58:41 +01:00
Fabien O'Carroll
12d4e42bb1 Published new versions
- @tryghost/members-api@1.6.0
2021-05-10 20:18:43 +01:00
Fabien O'Carroll
d32e44c73b Mapped Stripe Product name to Product name
closes https://github.com/TryGhost/Team/issues/682

This ensures that the Stripe Product name is updated during the
migrations of an existing site and any future updates to the Product
name.
2021-05-10 19:21:41 +01:00
Fabien O'Carroll
15b535fd45 Removed unused stripe-plans service
no-issue

This module is no longer used!
2021-05-10 19:21:41 +01:00
Fabien O'Carroll
45d338730c Updated webhook service to work with multiple products
no-issue

Since we do not necessarily have a single stripe product anymore, we
should be checking if an invoice webhook is for a stripe product which
we know about. We use the Products repository to search our database for
one.
2021-05-10 19:21:41 +01:00
Fabien O'Carroll
a3f7f3d1a0 Updated setComplimentary to work with new system
closes https://github.com/TryGhost/Team/issues/650

Despite the fact we're getting rid of the concept of Complimentary, we
must maintain backwards compatibility for the `comped` flag in the Admin
API & the importer. This flag is handled via the `setComplimentary`
method, which has been updated to work with the new system.
2021-05-10 19:21:32 +01:00
Kevin Ansfield
cdd52917fd Published new versions
- @tryghost/members-api@1.5.0
2021-05-10 12:07:00 +01:00
Kevin Ansfield
2f7664e1a8 Added labels and products to fetched member identity data (#271)
refs https://github.com/TryGhost/Team/issues/581
refs https://github.com/TryGhost/Team/issues/582

Content gating in Ghost is being expanded from basic public/members/free/paid to allowing full NQL queries. To facilitate quick matching of a member to the visibility query we need details of the associated labels and products alongside the basic member data.
2021-05-10 11:46:34 +01:00
Kevin Ansfield
ca473fc273 🐛 Fixed potential member data loss when assigning geolocation data
no issue

- `setMemberGeolocationFromIp()` was passing a raw model instance through to `users.update()` rather than a data object causing the `model.edit()` call to overwrite existing data such as labels because `modelInstance.labels` is a function rather than an array
- removed unnecessary `withRelated: ['labels']` as it's not necessary for the update, member data is fetched again with all necessary includes by `getMemberIdentityData()` before returning
2021-05-10 11:24:10 +01:00
Renovate Bot
40aabc7539 Update dependency node-jose to v2 2021-05-07 18:08:16 +01:00
Fabien O'Carroll
f2123d07db Added support for un/archiving Prices
https://github.com/TryGhost/Team/issues/665

We update both Stripe and our database based on the `active` flag for
existing stripe prices.
2021-05-07 17:01:00 +01:00
Rishabh
1dd2c4f656 Added prices object to logged in member's identity data
refs https://github.com/TryGhost/Team/issues/637

As we move away from `plan` data to `prices`, this change updates member identity data to include `prices` object in subscriptions object to get the price data for subscription instead of relying on `plan` data.
2021-05-06 15:27:01 +05:30
Rishabh
aa640ada5e Added migration for stripe plans to custom prices
refs https://github.com/TryGhost/Team/issues/637

- Adds one-off migration that reads from current `stripe_plans data` for a price, and ensures that the corresponding price is present in `stripe_prices` table at start.
- Currently, the portal_plans setting is used to determine the prices available to Portal for showing on Signup or Subscription change screen. The values allowed in portal_plans currently only allow [free, monthly, yearly] , which needs to be updated now to store price ids of available prices instead. Uses above migration to populate `portal_plans` with ids instead of names.
2021-05-04 21:52:51 +05:30
Rishabh
460dd09f8b Added description to product repository
refs https://github.com/TryGhost/Team/issues/586
refs https://github.com/TryGhost/Ghost/commit/b4d9ee0b

The `products` and `stripe_prices` were missing a description
column which will be used by Portal to display information about the
products and prices
2021-05-04 21:52:51 +05:30
Rishabh
3a27d1bd0c Updated APIs to use price ids
refs https://github.com/TryGhost/Team/issues/637

All the APIs that currently work with price names needs to be updated to work with price ids instead to work with custom prices/products. This change updates APIs to work with Price IDs in `checkout` , `updateSubscription` and other APIs/methods.
2021-05-04 21:52:51 +05:30
Fabien O'Carroll
fabff2e7e1 Published new versions
- @tryghost/members-api@1.4.0
2021-04-26 17:18:24 +01:00
Fabien O'Carroll
4e98c62b71 Fixed update method for Products repository
no-issue

When updating a Product we can pass existing Stripe Prices, these will
either be adding to the database, or updated if they already exist. When
updating them we were attemping to use the `id` passed in the update,
which is not necessarily included. Instead we should use the `id` of the
StripePrice which we have already retrieved from the database.
2021-04-26 17:15:17 +01:00
Fabien O'Carroll
20e5dcc91d Added createSubscription method to member repo
refs https://github.com/TryGhost/Team/issues/616

This is a generic method for adding a subscription to a member for a
particular price/product pair. This will be used in the Admin for e.g.
giving complimentary subscriptions.
2021-04-23 17:34:04 +01:00
Rishabh Garg
a08690363e Updated product repo to allow editing price names (#265)
refs https://github.com/TryGhost/Team/issues/616

For existing prices linked to a Product, we only allow site owners/admins to edit their nickname and nothing else. This change handles the update in Ghost, but needs extension to update the name in Stripe as well.
2021-04-23 21:46:07 +05:30