mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-27 10:42:45 +03:00
Added plan nickname fallback to empty string (#126)
no issue - This solves a problem when connected Stripe plan doesn't have plan `nickname` filled out (possible with older versions of Stripe API) - Defaulting to empty string instead of creating a migration because SQLite doesn't support `ALTER ... MODIFY` syntax and thus knex can't altter the table that easy - "Marks the column as an alter / modify, instead of the default add. Note: This only works in .alterTable() and is not supported by SQlite or Amazon Redshift. Alter is not done incrementally over older column type so if you like to add notNull and keep the old default value, the alter statement must contain both .notNull().defaultTo(1).alter(). If one just tries to add .notNull().alter() the old default value will be dropped." (ref. https://knexjs.org/#Chainable)
This commit is contained in:
parent
6de6a15376
commit
f2a7790cc9
@ -126,6 +126,8 @@ module.exports = class StripePaymentProcessor {
|
||||
|
||||
await this._updateCustomer(member, customer);
|
||||
|
||||
debug(`Linking customer:${id} subscriptions`, JSON.stringify(customer.subscriptions));
|
||||
|
||||
if (customer.subscriptions && customer.subscriptions.data) {
|
||||
for (const subscription of customer.subscriptions.data) {
|
||||
await this._updateSubscription(subscription);
|
||||
@ -287,9 +289,8 @@ module.exports = class StripePaymentProcessor {
|
||||
});
|
||||
return this._updateSubscription(subscriptionWithPayment);
|
||||
}
|
||||
debug(`Attaching subscription to customer ${subscription.customer} ${subscription.id}`);
|
||||
await this.storage.set({
|
||||
subscription: {
|
||||
|
||||
const mappedSubscription = {
|
||||
customer_id: subscription.customer,
|
||||
|
||||
subscription_id: subscription.id,
|
||||
@ -300,11 +301,17 @@ module.exports = class StripePaymentProcessor {
|
||||
default_payment_card_last4: payment && payment.card && payment.card.last4 || null,
|
||||
|
||||
plan_id: subscription.plan.id,
|
||||
plan_nickname: subscription.plan.nickname,
|
||||
plan_nickname: subscription.plan.nickname || '', // NOTE: defaulting to empty string here as migration to nullable field turned to be too much bigger problem
|
||||
plan_interval: subscription.plan.interval,
|
||||
plan_amount: subscription.plan.amount,
|
||||
plan_currency: subscription.plan.currency
|
||||
}
|
||||
};
|
||||
|
||||
debug(`Attaching subscription to customer ${subscription.customer} ${subscription.id}`);
|
||||
debug(`Subscription details`, JSON.stringify(mappedSubscription));
|
||||
|
||||
await this.storage.set({
|
||||
subscription: mappedSubscription
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user