mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-18 02:21:47 -05:00
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
This commit is contained in:
parent
e2a46863d8
commit
999acc60d7
1 changed files with 12 additions and 3 deletions
|
@ -424,9 +424,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