Refactored payment methods into shared global

ref ENG-812
ref https://linear.app/tryghost/issue/ENG-812

This will make it easier to switch to long term
This commit is contained in:
Fabien O'Carroll 2024-04-04 10:05:01 -04:00 committed by Fabien 'egg' O'Carroll
parent 7107b092fd
commit 1d13a9c549

View File

@ -47,6 +47,10 @@ module.exports = class StripeAPI {
this._configured = false;
}
get PAYMENT_METHOD_TYPES() {
return ['card'];
}
get configured() {
return this._configured;
}
@ -458,7 +462,7 @@ module.exports = class StripeAPI {
}
let stripeSessionOptions = {
payment_method_types: ['card'],
payment_method_types: this.PAYMENT_METHOD_TYPES,
success_url: options.successUrl || this._config.checkoutSessionSuccessUrl,
cancel_url: options.cancelUrl || this._config.checkoutSessionCancelUrl,
// @ts-ignore - we need to update to latest stripe library to correctly use newer features
@ -552,7 +556,7 @@ module.exports = class StripeAPI {
await this._rateLimitBucket.throttle();
const session = await this._stripe.checkout.sessions.create({
mode: 'setup',
payment_method_types: ['card'],
payment_method_types: this.PAYMENT_METHOD_TYPES,
success_url: options.successUrl || this._config.checkoutSetupSessionSuccessUrl,
cancel_url: options.cancelUrl || this._config.checkoutSetupSessionCancelUrl,
customer_email: customer.email,