Bugfix/fix price when creating subscription (#2037)

* Fix price

* Update changelog
pull/2039/head
Thomas Kaul 2 years ago committed by GitHub
parent 97bcd8ff49
commit 6e5f0086a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,6 +18,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated the URL of the Ghostfolio Slack channel - Updated the URL of the Ghostfolio Slack channel
- Removed the _Ghostfolio in Numbers_ section from the about page - Removed the _Ghostfolio in Numbers_ section from the about page
### Fixed
- Fixed an issue with the price when creating a `Subscription`
## 1.275.0 - 2023-05-30 ## 1.275.0 - 2023-05-30
### Changed ### Changed

@ -1,10 +1,6 @@
import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service';
import { PrismaService } from '@ghostfolio/api/services/prisma/prisma.service'; import { PrismaService } from '@ghostfolio/api/services/prisma/prisma.service';
import { import { DEFAULT_LANGUAGE_CODE } from '@ghostfolio/common/config';
DEFAULT_LANGUAGE_CODE,
PROPERTY_STRIPE_CONFIG
} from '@ghostfolio/common/config';
import { Subscription as SubscriptionInterface } from '@ghostfolio/common/interfaces';
import { UserWithSettings } from '@ghostfolio/common/types'; import { UserWithSettings } from '@ghostfolio/common/types';
import { SubscriptionType } from '@ghostfolio/common/types/subscription-type.type'; import { SubscriptionType } from '@ghostfolio/common/types/subscription-type.type';
import { Injectable, Logger } from '@nestjs/common'; import { Injectable, Logger } from '@nestjs/common';
@ -101,19 +97,8 @@ export class SubscriptionService {
aCheckoutSessionId aCheckoutSessionId
); );
let subscriptions: SubscriptionInterface[] = [];
const stripeConfig = (await this.prismaService.property.findUnique({
where: { key: PROPERTY_STRIPE_CONFIG }
})) ?? { value: '{}' };
subscriptions = [JSON.parse(stripeConfig.value)];
const coupon = subscriptions[0]?.coupon ?? 0;
const price = subscriptions[0]?.price ?? 0;
await this.createSubscription({ await this.createSubscription({
price: price - coupon, price: session.amount_total / 100,
userId: session.client_reference_id userId: session.client_reference_id
}); });

Loading…
Cancel
Save