Commit Graph

807 Commits

Author SHA1 Message Date
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
bf89907d33 Update dependency @types/cookies to v0.7.6 2021-05-24 10:26:15 +01:00
Renovate Bot
5497aadb62 Update dependency keypair to v1.0.3 2021-05-24 10:25:55 +01:00
Renovate Bot
dd630a74fc Update dependency @types/nodemailer to v6.4.1 2021-05-24 10:25:34 +01:00
Renovate Bot
4d98dddc89 Update dependency @types/jsonwebtoken to v8.5.1 2021-05-24 10:24:13 +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
Renovate Bot
324c008d3a Update dependency @types/node to v14 2021-05-24 10:21:52 +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
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
Fabien O'Carroll
474e052b60 Bumped @tryghost/members-csv to 1.0.0-rc.3
no-issue

We would like to release @tryghost/members-csv as version 1.0.0 but
lerna will only allow us to release packages which have had changes in
them since their last release. Well, this is a change. And it's solely
for the purpose of allowing us to release 1.0.0. This version is not
tagged, nor is it published to npm.
2021-03-10 17:20:54 +00:00
Rish
cac4ca14ff Added check for plan nickname to exist
no-issue

When seeding the database with fake members & stripe data, it's possible
to create stripe plans without a nickname. Similarly some other services
do not have a nickname on their plans. This ensures that we do not error
when working with these plans.
2021-03-10 17:15:16 +00:00
Fabien O'Carroll
907ccd9f34 Fixed creating events within transaction
no-issue

If we are to perform the `linkSubscription` method inside of a
transaction, the addition of the paid subscription events would happen
outside of the transaction, and cause errors. This ensures that we pass
the options object (containing the transaction) to the models calls to
add paid subscription events
2021-03-10 17:15:16 +00:00
Fabien O'Carroll
9be1d2de4f Updated invoice webhook handling for payment events
no-issue

1. We do not want to store payment events for payments of 0 value
2. Stripe webhooks can arrive and be processed "out of order", which can
   result in us attempting to add a payment event for a member which
   does not yet exist. The change here will 404 in such (edge) cases, so
   that Stripe will retry the webhook at a later point, when the Member
   has been created, allowing us to store the payment event.
2021-03-10 17:15:16 +00:00
Renovate Bot
5506406dbf Update dependency ghost-ignition to v4.5.4 2021-03-08 02:15:38 +00:00
Fabien O'Carroll
1602aa2d98 Published new versions
- @tryghost/members-api@1.0.0-rc.5
2021-03-05 13:03:31 +00:00
Fabien O'Carroll
d662003fdb Updated status events to happen before subscribed events
no-issue

Given that status events are used to determine signup events,
they should be the first event for a member.
2021-03-05 12:59:05 +00:00
Fabien O'Carroll
58c9c1c649 Cleaned newsletter subscription events from timeline
refs https://github.com/TryGhost/Team/issues/469

In order to reduce noise, we want to only display newsletter
subscription events which are not likely to be the result of a member
signup. The approach we've taken is to remove any newsletter
subscription (not unsubscription) event, if when sorted in chronological
order, it is to reside next to a signup event for the same member.

An improvement to this approach might be to add some kind of transaction
id  to events which would allow us to group together events which should
be considered to have happened simultaneously.
2021-03-05 12:59:05 +00:00
Fabien O'Carroll
e003c10e8b Added signup_events to the event timeline
refs https://github.com/TryGhost/Team/issues/469

Signup events are captured by status changes with no `from_status`, this
means that the member did not have a status (did not exist) before this
change.
2021-03-05 12:59:05 +00:00
Fabien O'Carroll
c8eb50bf57 Fixed ordering of event timelime
refs https://github.com/TryGhost/Team/issues/469

We order the set of all events by created_at, but were not fetching the
individual events with the same order applies, this resulted in
incorrect results.
2021-03-05 12:57:50 +00:00
Fabien O'Carroll
095c624172 🐛 Fixed cancelling subscriptions when destroying
refs https://github.com/TryGhost/Ghost/issues/12711

We must wait for the stripeSubscriptions relation to be loaded before
attempting to loop through them. As well as this we should use `upsert`
so that we can edit a subscription record by `subscription_id`, rather
than the (internal) `id`
2021-03-03 13:15:13 +00:00
Fabien O'Carroll
8b4e5f9a92 Published new versions
- @tryghost/members-api@1.0.0-rc.4
 - @tryghost/members-csv@1.0.0-rc.2
2021-02-23 17:48:22 +00:00
Fabien O'Carroll
17175c87cc Fixed bug with calculating MRR and Volume
no-issue

This was not accessing the correct data when summing the deltas
2021-02-23 17:45:52 +00:00
Fabien O'Carroll
7e2e85d531 Published new versions
- @tryghost/members-api@1.0.0-rc.3
 - @tryghost/members-csv@1.0.0-rc.1
2021-02-23 11:21:48 +00:00
Fabien 'egg' O'Carroll
e1b3b38bcd Added initial support for event timelines
refs https://github.com/TryGhost/Ghost/issues/12602

This adds initial support for sitewide event timelines
2021-02-23 11:21:48 +00:00
Fabien O'Carroll
7cde72c820 Published new versions
- @tryghost/members-api@1.0.0-rc.2
2021-02-23 11:21:48 +00:00
Rish
65cf639603 Fixed incorrect member id in status event
no refs

The member id assigned when creating a new status event on member creation was incorrectly using `data.id` instead of `member.id`, which was undefined causing a validation error.
2021-02-23 11:21:48 +00:00
Fabien O'Carroll
d93f7095f6 Published new versions
- @tryghost/members-api@1.0.0-rc.1
 - @tryghost/members-csv@1.0.0-rc.0
2021-02-23 11:21:48 +00:00
Fabien 'egg' O'Carroll
9081298517 Added initial support for Member events (#241)
refs https://github.com/TryGhost/Ghost/issues/12602

* Added Event Repository
** Added method for MRR over time
** Added method for newsletter subscriptions over time
** Added method for gross volume over time
** Added method for status segment size over time
* Captured login events
* Captured newsletter subscription/unsubscription
* Captured email address change events
* Captured paid subscription events
* Captured payment events
* Captured status events
2021-02-23 11:21:48 +00:00
Rish
b8a17f2be0 Revert "Removed unused upsertCustomer method"
This reverts commit b261c1d61e06e35657741de888fd651329101d69.
upsertCustomer method is used to overwrite customer when checkout session is completed.
2021-02-23 11:21:48 +00:00
Rish
94301e3c17 Updated parsing subscriptions for member
no refs

The data structure for subscriptions object on member has changed in 4.x from` stripe.subscriptions` to direct `subscriptions`, the change here updates parsing of subscriptions data
2021-02-23 11:21:48 +00:00
Fabien O'Carroll
f504b98e02 Published new versions
- @tryghost/members-api@1.0.0-rc.0
2021-02-23 11:21:44 +00:00
Fabien 'egg' O'Carroll
02685e3d3c Threw "fatal" errors for non-prod usage of live Stripe data (#236)
refs https://github.com/TryGhost/Ghost/issues/12448

The `fatal` property will allow Ghost to determine whether or not it should kill the process
2021-02-23 11:21:11 +00:00
Fabien O'Carroll
1932d56890 Updated linkSubscription to ensure flag is synced 2021-02-23 11:21:11 +00:00
Fabien O'Carroll
f9dbeafbbb Added helper for determining active subscriptions 2021-02-23 11:21:11 +00:00
Fabien O'Carroll
02990ce7e5 Removed unused upsertCustomer method 2021-02-23 11:21:11 +00:00
Fabien O'Carroll
5cae43b032 Published new versions
- @tryghost/members-api@0.37.11
2021-02-23 11:20:28 +00:00
Fabien 'egg' O'Carroll
2fb6708944 🐛 Fixed issues when updating payment method (#247)
refs https://github.com/TryGhost/Team/issues/479

* Fixed updating payment method for canceled subscriptions

Stripe considers canceled subscriptions as non-existent, so any attempts
to update them will fail with a 404 not found. Prior to this change we
were attempting to update *all* subscriptions for a customer, including
those which were canceled. This would cause an error and the loop to
break.

* 🐛 Fixed errors for members with multiple active customers

Members with multiple active customers would have their first active
customer found updated with the new payment method. We would then
iterate through *all* active subscription, and attempt to update their
payment method. If a subscription was not owned by the customer that was
just updated, it would error and cause the loop to break out.

* Added ability to update a specific subscription's payment method

In order to remove ambiguity we add the ability to update the payment
method for a specific subscription. This will remove room for errors as
we will not have to worry about if a subscription belong to the customer
or not.
2021-02-23 11:19:21 +00:00
Fabien O'Carroll
0d97bd7dd6 Published new versions
- @tryghost/magic-link@0.6.7
 - @tryghost/members-api@0.37.10
 - @tryghost/members-ssr@0.8.11
2021-02-22 14:02:54 +00:00
Fabien O'Carroll
8f333cc38b 🐛 Fixed comp plans for members w/ active subscriptions
refs https://github.com/TryGhost/Team/issues/475

The subscription object here is a database model rather than an
ISubscription from the stripe library, and we need to 1) use the `get`
method to read attributes and 2) read the `subscription_id` attribute,
as the `id` is our internal one.
2021-02-22 14:00:24 +00:00
Renovate Bot
6a7aaf0397 Update dependency ghost-ignition to v4.4.4 2021-02-19 21:24:49 +00:00
Fabien O'Carroll
1ffe8bc71c Published new versions
- @tryghost/members-api@0.37.9
2021-02-17 17:13:30 +00:00
Fabien 'egg' O'Carroll
274412b051 Fixed webhook handling for Checkout Sessions (#245)
no-issue

Fetching relations via the model returns a promise, and this was missing
the `await` keyword. We also need to `get` the subscription_id attribute
as we're working with models rather than subscription objects.
2021-02-17 17:12:45 +00:00
Fabien O'Carroll
5bb1706f8d Published new versions
- @tryghost/members-csv@0.4.5
2021-02-15 14:22:20 +00:00
Renovate Bot
21b8242cbe Update dependency mocha to v8.3.0 2021-02-12 23:36:03 +00:00
Daniel Lockyer
ccf9517698 Published new versions
- @tryghost/members-api@0.37.8
2021-02-11 18:27:12 +00:00
Fabien 'egg' O'Carroll
991b6e92a3 Ensured latest subscription data is always stored (#240)
no-issue

If we receive webhooks out of order, e.g. a
`customer.subscription.updated` with a status of 'active', followed by a
`customer.subscription.created` with a status of 'incomplete'. We would
overwrite the correct value with data from the "older" webhook. This
ensures that we always fetch the latest data from the Stripe API before
storing in the database.
2021-02-11 17:43:36 +00:00
Rish
8b3cd5499c Published new versions
- @tryghost/magic-link@0.6.6
 - @tryghost/members-api@0.37.7
 - @tryghost/members-ssr@0.8.10
2021-02-01 10:25:11 +05:30
Rish
4b4a990e1d Fixed default urls for checkout session
no-issue
related to ef9cb0862c

In the last patch which fixes the bug for not passing custom redirect urls when a checkout session is created, we missed updating the case where a logged in member tries to update the subscription.
2021-02-01 10:24:16 +05:30
Renovate Bot
f823334b15 Update dependency ghost-ignition to v4.4.3 2021-01-28 17:28:39 +00:00
Fabien O'Carroll
27ebd70302 Published new versions
- @tryghost/members-api@0.37.6
 - @tryghost/members-csv@0.4.4
2021-01-27 15:21:43 +00:00
Fabien 'egg' O'Carroll
ef9cb0862c Passed default URLs when creating checkout session (#235)
* Passed default URLs when creating checkout session

no-issue

This fixes a bug when a checkout session is created without passing
custom redirect URLs
2021-01-27 15:19:09 +00:00
Renovate Bot
80e2f4d817 Update dependency sinon to v9.2.4 2021-01-27 13:18:29 +00:00
Fabien O'Carroll
9ff229b8c2 Published new versions
- @tryghost/members-api@0.37.5
2021-01-26 12:16:05 +00:00
Fabien O'Carroll
0c6b92be45 Fixed Stripe Checkout for non-members
no-issue

We needed to check for  being
2021-01-26 12:14:56 +00:00
Fabien O'Carroll
8d9340534d Published new versions
- @tryghost/magic-link@0.6.5
 - @tryghost/members-api@0.37.4
 - @tryghost/members-csv@0.4.3
 - @tryghost/members-ssr@0.8.9
2021-01-26 12:02:58 +00:00
Rish
0d7c06b5a8 Fixed customer not fetched for billing update
no issue

The logic to fetch member for a checkout session was incorrectly creating a new customer instead of finding an existing one, so the member's billing details was not getting updated.
2021-01-26 17:25:40 +05:30
Fabien O'Carroll
a8782054ba Fixed Stripe Checkout displaying member email
no-issue
2021-01-26 11:26:57 +00:00
Fabien O'Carroll
0268bee13e Fixed checks for if Stripe is configured
no-issue
2021-01-26 11:26:28 +00:00
John O'Nolan
0e0b2f3cb2 2021 2021-01-25 16:34:32 +00:00
Fabien O'Carroll
c885e024ae Published new versions
- @tryghost/magic-link@0.6.4
 - @tryghost/members-api@0.37.3
 - @tryghost/members-ssr@0.8.8
2021-01-25 13:21:34 +00:00
Fabien O'Carroll
77b328bf11 Fixed bug with reapplying complimentary subscriptions
no-issue

We should have been checking for the existence of active subscriptions
in order to update them
2021-01-25 13:20:31 +00:00
Renovate Bot
40ef97e6d3 Update dependency ghost-ignition to v4.4.2 2021-01-25 01:37:03 +00:00
Fabien O'Carroll
a9c74e6ade Published new versions
- @tryghost/members-api@0.37.2
2021-01-22 15:18:45 +00:00
Fabien O'Carroll
693cc53138 Ensured transactions are passed correctly
no-issue
2021-01-22 15:15:31 +00:00
Fabien O'Carroll
0b8fc40cf3 Published new versions
- @tryghost/members-api@0.37.1
2021-01-19 10:43:41 +00:00
Fabien O'Carroll
6412cfe3c6 Fixed error responses when missing data
no-issue

We should error early when recieving a request that does not contain the
required data.
2021-01-19 10:42:41 +00:00
Fabien O'Carroll
07fea2c68c Published new versions
- @tryghost/magic-link@0.6.3
 - @tryghost/members-api@0.37.0
 - @tryghost/members-csv@0.4.2
 - @tryghost/members-ssr@0.8.7
2021-01-18 16:51:19 +00:00
Fabien 'egg' O'Carroll
e3ef01932f Refactor members-api (#231)
no-issue

This refactors the members-api module so that it is easier to test going forward,
as well as easier to understand & navigate. The Stripe API no longer contains
storage code, this is all handled via the member repository. And we have dedicated
services for webhooks, and stripe plans initialisation.
2021-01-18 13:55:40 +00:00
Renovate Bot
af13570076 Update dependency ghost-ignition to v4.3.0 2021-01-14 17:05:36 +00:00
Renovate Bot
8605c55a94 Update dependency sinon to v9.2.3 2021-01-07 17:04:52 +00:00
Renovate Bot
1a292f7188 Update dependency sinon to v9.2.2 2020-12-14 01:06:22 +00:00
Fabien O'Carroll
d82d531738 Published new versions
- @tryghost/members-csv@0.4.1
2020-12-04 12:42:09 +00:00
Fabien O'Carroll
d6acbd7b09 Fixed reference to subscribed column
no-issue

This was causing the default subscribed value to be incorrect
2020-12-04 12:39:58 +00:00
Fabien O'Carroll
b9bffadb68 Published new versions
- @tryghost/members-api@0.36.0
 - @tryghost/members-csv@0.4.0
2020-12-04 10:11:55 +00:00
Fabien O'Carroll
3abb0c543b Updated setComplimentarySubscription to error without a Stripe connection
no-issue

This allows the consumer (e.g. the importer) to surfaces errors when importing comped members
2020-12-04 10:10:59 +00:00
Fabien O'Carroll
d70aab83f6 Updated linkStripeCustomer to error rather than silently fail
no-issue

This allows the importer to surface errors when linking members to customers
2020-12-04 10:10:59 +00:00
Fabien O'Carroll
0a5f91f3d0 Refactored members-csv to remove unused columnsToExtract
no-issue

 - Was not used by the importer and removed for simplicity.
 - Updates the header mapping to happen in place, rather than in a loop
 - Updates the parsing of values to give correct types
2020-12-04 10:10:59 +00:00
Fabien O'Carroll
019d99fcc2 Updated members-csv to handle error column when unparsing
no-issue

This also allows for different the member object structure returned from parse
2020-12-04 10:10:59 +00:00
Fabien O'Carroll
05d5310343 Updated members-api to allow passing options to models
no-issue

This allows us to do multiple operations within a db transaction, which
will be used for the importer to ensure atomic inserts
2020-12-04 10:10:59 +00:00
Fabien O'Carroll
bd1173ef9f Published new versions
- @tryghost/magic-link@0.6.2
 - @tryghost/members-api@0.35.0
 - @tryghost/members-csv@0.3.3
 - @tryghost/members-ssr@0.8.6
2020-11-23 16:53:10 +00:00
Fabien 'egg' O'Carroll
ecd5bb2c01 Stored cancellation reason in local database (#222)
refs https://github.com/TryGhost/Ghost/issues/12403
refs https://github.com/TryGhost/Ghost/pull/12405

This smol change means that we keep our local cancellation_reason column in sync with what we set in Stripe metadata
2020-11-23 16:50:03 +00:00
Fabien 'egg' O'Carroll
da00444961 Added support for cancellation_reason (#221)
refs https://github.com/TryGhost/Ghost/issues/12403

Adds support for sending a cancellation_reason when cancelling a plan and store the reason on the Subscription metadata
2020-11-23 16:28:35 +00:00
Renovate Bot
5879193940 Update dependency ghost-ignition to v4.2.4 2020-11-05 12:04:34 +00:00
Renovate Bot
24b263c493 Update dependency mocha to v8.2.1 2020-11-04 01:05:30 +00:00
Renovate Bot
a4d2dcaa8c Update dependency ghost-ignition to v4.2.3 2020-11-02 01:05:58 +00:00
Renovate Bot
1b29e595ea Update dependency sinon to v9.2.1 2020-10-30 15:04:34 +00:00
Rish
ed1a1ae049 Published new versions
- @tryghost/members-api@0.34.2
2020-10-29 17:55:00 +05:30
Rish
0ec84d1948 Fixed lint
no refs
2020-10-29 17:54:18 +05:30
Rish
2c2d639838 Fixed magic link type for member email update
no issue

- In case of a member updating their email, the `updateEmail` type was overridden with `signup` or `signin` without the force option. The fix forces the correct email type for when member requests to update their email.
2020-10-29 17:53:07 +05:30
Rish
06f9eb6dfe Published new versions
- @tryghost/magic-link@0.6.1
 - @tryghost/members-api@0.34.1
 - @tryghost/members-csv@0.3.2
2020-10-29 12:38:06 +05:30