Commit Graph

788 Commits

Author SHA1 Message Date
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
Rish
4c7860483e Published new versions
- @tryghost/members-api@1.3.2
2021-04-22 21:53:08 +05:30
Rishabh Garg
42ade8fd12 Updated customer fetch from Stripe to include subscriptions (#264)
closes https://github.com/TryGhost/Team/issues/628
refs 9010a62d54

Following up on last commit, this moves up the expansion of Stripe customer fetch to always include `subscriptions` by default in api service so we don't accidentally miss it.
2021-04-22 21:51:01 +05:30
Rish
9010a62d54 🐛 Fixed members importer failing to link paid subscriptions
no refs

The latest version of Stripe doesn't return the `subscriptions` object on `Customer` resource by default and needs an extra param to do so. As we recently updated Members to use the latest Stripe version, the importer tries to fetch all subscriptions of a customer to map in Ghost but was failing due to missing `subscriptions` data. Fix updates the Stripe API to include `subscriptions` by default in response.
2021-04-22 21:22:23 +05:30
Rish
881077ad9d Published new versions
- @tryghost/members-api@1.3.1
2021-04-22 11:50:32 +05:30
Rish
c612b4d194 Ignored missing plans on Stripe for update
refs https://github.com/TryGhost/Team/issues/591

It's possible to have sites which still have subscriptions in their DB from old Stripe accounts, most likely added when we allowed Stripe Direct, as those subscriptions were not cleaned up. While populating plans and products for existing subscriptions, we want to ignore these old subscriptions which are not part of current Stripe account.
2021-04-22 11:49:08 +05:30
Rish
25a1f7d0b4 Published new versions
- @tryghost/magic-link@1.0.2
 - @tryghost/members-api@1.3.0
 - @tryghost/members-ssr@1.0.2
2021-04-20 17:23:04 +05:30
Rishabh Garg
bee619c123 Updated link subscription to handle missing stripe data (#262)
refs https://github.com/TryGhost/Team/issues/619

On linking a stripe subscription to a member, this change -

- Adds missing stripe price or stripe product from subscription to DB
  - Missing Stripe price is attached to the first Ghost Product if no matching Product exists
- Updates usage from plan to price in the `linkSubscription` method
- Updates products associated with a member based on active subscriptions
2021-04-20 17:21:16 +05:30
Fabien 'egg' O'Carroll
dc0e5b0ec8 Wired up ProductRepository to members-api
refs https://github.com/TryGhost/Team/issues/616

Working with ProductRepository as a separate package was more trouble
than it was worth, so it's been moved into members-api. We expose the
product repository so that Ghost Admin API can access it.
2021-04-19 15:09:28 +01:00
Renovate Bot
bd3b3738e5 Update dependency ghost-ignition to v4.6.2 2021-04-19 05:22:28 +00:00
Rishabh Garg
836b7f235e Populate stripe prices and products for existing customers (#258)
refs https://github.com/TryGhost/Team/issues/586

On Ghost Boot, as part of configuring Stripe, this populates stripe products and prices for existing stripe customers in the newly created `stripe_prices` and `stripe_products` table, which allows us to map existing customers to default Ghost product and on current prices. The population script on boot is only run if we find -

- A Ghost Product
- No rows in `stripe_products`
- No rows in `stripe_prices`
- One or more rows in `members_stripe_customers_subscriptions`
2021-04-12 20:38:01 +05:30
Fabien O'Carroll
3f6498c12f Published new versions
- @tryghost/members-api@1.2.0
 - @tryghost/product-repository@0.1.1
2021-04-12 15:31:32 +01:00
Fabien 'egg' O'Carroll
6602928099 Added initial ProductRepository implementation (#259)
refs https://github.com/TryGhost/Team/issues/616

WIP but needs to be released so we can start using it as a dependency
2021-04-12 15:30:17 +01:00
Rishabh Garg
72e097cdc2 Updated Stripe major version and types (#256)
refs https://github.com/TryGhost/Team/issues/593

- Bumps `stripe` node library major version to v8 - 8.142
- Bumps default Stripe version to latest - '2020-08-27'
- Updated webhook Stripe version to latest - '2020-08-27'
- Removes `@types/stripe` in favor of first-class types support in `stripe` lib directly
- Updates types across files
2021-04-09 21:11:16 +05:30
Rish
6a05d55e5d Published new versions
- @tryghost/magic-link@1.0.1
 - @tryghost/members-api@1.1.1
 - @tryghost/members-ssr@1.0.1
2021-04-06 18:44:44 +05:30
Rish
d4488b5e59 🐛 Fixed incorrect mrr delta calculation
refs https://github.com/TryGhost/Team/issues/595

For a canceled subscription, the desired MRR delta is to reduce by negative of original amount, but our logic was incorrectly reducing it by double which led to big gap between real MRR and one shown on Dashboard.

- Fixes calculation for MRR change for canceled subscriptions
2021-04-06 18:42:55 +05:30
Renovate Bot
d5c893ca5b Update dependency ghost-ignition to v4.6.1 2021-03-31 14:45:04 +00:00
Fabien O'Carroll
bd80fa6fde Published new versions
- @tryghost/members-api@1.1.0
2021-03-30 12:18:36 +01:00
Fabien O'Carroll
999acc60d7 Added support for updating subscription by id
no-issue

The Admin API uses a Member id rather than email to update
subscriptions, this ensures that we provide an interface that will
continue to work with the Admin API
2021-03-30 11:00:41 +01:00
Fabien O'Carroll
e2a46863d8 Updated MemberRepostitory with subscription methods
https://github.com/TryGhost/Team/issues/530

These are required by the smart_cancel functionality
2021-03-30 10:36:49 +01:00
Fabien O'Carroll
a302ff1597 Added support for smart_cancel options
https://github.com/TryGhost/Team/issues/530

This option will check to see if a subscription is in an unpaid or past
due state, and if so, will cancel the subscription immediately, rather
than cancelling at the period end.
2021-03-30 10:36:45 +01:00
Fabien O'Carroll
c1f5216646 Updated members-api tests to use 'dot' reporter
no-issue

This makes it much easier to see which tests have failed & why
2021-03-30 10:36:45 +01:00
Fabien O'Carroll
48ad254df3 Added tests for smart_cancel param
refs https://github.com/TryGhost/Team/issues/530
2021-03-30 10:36:17 +01:00
Fabien 'egg' O'Carroll
3ed10ecdf6 Added tests for updateSubscription
refs https://github.com/TryGhost/Team/issues/530

The RouterController was a grab bag of all controller methods, making it
difficult to mock & test. This adds a MemberController with a smaller
API - making it easier to test.
2021-03-25 12:19:01 +00:00
Fabien O'Carroll
0629791824 Published new versions
- @tryghost/magic-link@1.0.0
 - @tryghost/members-api@1.0.0
 - @tryghost/members-csv@1.0.0
 - @tryghost/members-ssr@1.0.0
2021-03-10 17:23:30 +00:00