mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
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.
This commit is contained in:
parent
b2fccb2e34
commit
a4dcb66080
1 changed files with 12 additions and 3 deletions
|
@ -437,9 +437,18 @@ module.exports = class MemberRepository {
|
|||
throw new Error('Cannot update Stripe Subscription with no Stripe Connection');
|
||||
}
|
||||
|
||||
const member = await this._Member.findOne({
|
||||
email: data.email
|
||||
});
|
||||
let findQuery = null;
|
||||
if (data.id) {
|
||||
findQuery = {id: data.id};
|
||||
} else if (data.email) {
|
||||
findQuery = {email: data.email};
|
||||
}
|
||||
|
||||
if (!findQuery) {
|
||||
throw new Error('Cannot update Subscription without an id or email for the Member');
|
||||
}
|
||||
|
||||
const member = await this._Member.findOne(findQuery);
|
||||
|
||||
const subscription = await member.related('stripeSubscriptions').query({
|
||||
where: {
|
||||
|
|
Loading…
Add table
Reference in a new issue