Ghost/ghost/members-api/lib
Naz Gargol ff5fceafc8 Added subscription update middleware (#107)
refs #https://github.com/TryGhost/Ghost/pull/11434

- Added method to allow updating single subscription. Only `cancel_at_period_end` field can be updated. 
- Middleware is needed to allow Ghost Core to cancel/uncancel member's subscription. 
- Relies on the request containing identity information to be able to verify if subscription belongs to the user
- When member could not be identified by the identity information present in the request we should throw instead of continuing processing
- Handling and messaging inspired by https://github.com/TryGhost/Ghost/blob/3.1.1/core/server/services/mega/mega.js#L132
- When the user initiates subscription cancellation we can safely mark the subscription as canceled so that it's not shown in the interface on subsequent request. Otherwise, we end up in a situation where we still return the subscription in the period until Stripe triggers the webhook.
- Added boolean coercion for cancel_at_period_end parameter. If anything but boolean is passed to Stripe API it throws an error.  Coercing the value on our side is a gives a better dev experience
2019-12-12 15:19:36 +07:00
..
stripe Added subscription update middleware (#107) 2019-12-12 15:19:36 +07:00
common.js Added subscription update middleware (#107) 2019-12-12 15:19:36 +07:00
tokens.js Updated members-api to use magic-link 2019-09-03 15:35:04 +08:00
users.js Changed members-api constructor to accept Member model directly (#105) 2019-12-05 18:16:18 +07:00