ff5fceafc8
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
23 lines
603 B
JavaScript
23 lines
603 B
JavaScript
let currentLogger = {
|
|
error: global.console.error,
|
|
info: global.console.info,
|
|
warn: global.console.warn
|
|
};
|
|
|
|
module.exports = {
|
|
get logging() {
|
|
const loggerInterface = Object.create(currentLogger);
|
|
return Object.assign(loggerInterface, {
|
|
setLogger(newLogger) {
|
|
currentLogger = newLogger;
|
|
// Overwrite any existing reference to loggerInterface
|
|
Object.assign(loggerInterface, Object.create(newLogger));
|
|
}
|
|
});
|
|
},
|
|
|
|
get errors() {
|
|
return require('ghost-ignition').errors;
|
|
}
|
|
};
|