Browse Source

Eliminate ngx-stripe

pull/6116/head
Thomas Kaul 1 month ago
parent
commit
33db012071
  1. 3
      apps/api/src/app/subscription/subscription.service.ts
  2. 20
      apps/client/src/app/components/user-account-membership/user-account-membership.component.ts
  3. 24
      apps/client/src/app/pages/pricing/pricing-page.component.ts
  4. 8
      apps/client/src/main.ts
  5. 3
      libs/common/src/lib/interfaces/info-item.interface.ts
  6. 3
      libs/common/src/lib/interfaces/responses/create-stripe-checkout-session-response.interface.ts
  7. 15
      package-lock.json
  8. 1
      package.json

3
apps/api/src/app/subscription/subscription.service.ts

@ -100,7 +100,8 @@ export class SubscriptionService {
);
return {
sessionId: session.id
sessionId: session.id,
sessionUrl: session.url
};
}

20
apps/client/src/app/components/user-account-membership/user-account-membership.component.ts

@ -21,9 +21,8 @@ import { MatCardModule } from '@angular/material/card';
import { MatSnackBar } from '@angular/material/snack-bar';
import { RouterModule } from '@angular/router';
import ms, { StringValue } from 'ms';
import { StripeService } from 'ngx-stripe';
import { EMPTY, Subject } from 'rxjs';
import { catchError, switchMap, takeUntil } from 'rxjs/operators';
import { catchError, takeUntil } from 'rxjs/operators';
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
@ -62,7 +61,6 @@ export class GfUserAccountMembershipComponent implements OnDestroy {
private dataService: DataService,
private notificationService: NotificationService,
private snackBar: MatSnackBar,
private stripeService: StripeService,
private userService: UserService
) {
const { baseCurrency, globalPermissions } = this.dataService.fetchInfo();
@ -113,23 +111,17 @@ export class GfUserAccountMembershipComponent implements OnDestroy {
priceId: this.priceId
})
.pipe(
catchError((error) => {
catchError((error: Error) => {
this.notificationService.alert({
title: error.message
});
throw error;
return EMPTY;
}),
switchMap(({ sessionId }) => {
return this.stripeService.redirectToCheckout({ sessionId });
})
takeUntil(this.unsubscribeSubject)
)
.subscribe((result) => {
if (result.error) {
this.notificationService.alert({
title: result.error.message
});
}
.subscribe(({ sessionUrl }) => {
window.location.href = sessionUrl;
});
}

24
apps/client/src/app/pages/pricing/pricing-page.component.ts

@ -27,9 +27,8 @@ import {
informationCircleOutline
} from 'ionicons/icons';
import { StringValue } from 'ms';
import { StripeService } from 'ngx-stripe';
import { Subject } from 'rxjs';
import { catchError, switchMap, takeUntil } from 'rxjs/operators';
import { EMPTY, Subject } from 'rxjs';
import { catchError, takeUntil } from 'rxjs/operators';
@Component({
host: { class: 'page' },
@ -98,7 +97,6 @@ export class GfPricingPageComponent implements OnDestroy, OnInit {
private changeDetectorRef: ChangeDetectorRef,
private dataService: DataService,
private notificationService: NotificationService,
private stripeService: StripeService,
private userService: UserService
) {
addIcons({
@ -155,23 +153,17 @@ export class GfPricingPageComponent implements OnDestroy, OnInit {
priceId: this.priceId
})
.pipe(
switchMap(({ sessionId }) => {
return this.stripeService.redirectToCheckout({ sessionId });
}),
catchError((error) => {
catchError((error: Error) => {
this.notificationService.alert({
title: error.message
});
throw error;
})
return EMPTY;
}),
takeUntil(this.unsubscribeSubject)
)
.subscribe((result) => {
if (result.error) {
this.notificationService.alert({
title: result.error.message
});
}
.subscribe(({ sessionUrl }) => {
window.location.href = sessionUrl;
});
}

8
apps/client/src/main.ts

@ -23,7 +23,6 @@ import { ServiceWorkerModule } from '@angular/service-worker';
import { provideIonicAngular } from '@ionic/angular/standalone';
import { provideMarkdown } from 'ngx-markdown';
import { provideNgxSkeletonLoader } from 'ngx-skeleton-loader';
import { NgxStripeModule, STRIPE_PUBLISHABLE_KEY } from 'ngx-stripe';
import { CustomDateAdapter } from './app/adapter/custom-date-adapter';
import { DateFormats } from './app/adapter/date-formats';
@ -50,8 +49,6 @@ import { environment } from './environments/environment';
(window as any).info = info;
environment.stripePublicKey = info.stripePublicKey;
if (environment.production) {
enableProdMode();
}
@ -65,7 +62,6 @@ import { environment } from './environments/environment';
MatNativeDateModule,
MatSnackBarModule,
MatTooltipModule,
NgxStripeModule.forRoot(environment.stripePublicKey),
RouterModule.forRoot(routes, {
anchorScrolling: 'enabled',
preloadingStrategy: ModulePreloadService,
@ -92,10 +88,6 @@ import { environment } from './environments/environment';
provide: MAT_DATE_FORMATS,
useValue: DateFormats
},
{
provide: STRIPE_PUBLISHABLE_KEY,
useFactory: () => environment.stripePublicKey
},
{
provide: TitleStrategy,
useClass: PageTitleStrategy

3
libs/common/src/lib/interfaces/info-item.interface.ts

@ -18,6 +18,9 @@ export interface InfoItem {
platforms: Platform[];
statistics: Statistics;
/** @deprecated */
stripePublicKey?: string;
subscriptionOffer?: SubscriptionOffer;
}

3
libs/common/src/lib/interfaces/responses/create-stripe-checkout-session-response.interface.ts

@ -1,3 +1,6 @@
export interface CreateStripeCheckoutSessionResponse {
/** @deprecated */
sessionId: string;
sessionUrl: string;
}

15
package-lock.json

@ -76,7 +76,6 @@
"ngx-device-detector": "10.1.0",
"ngx-markdown": "20.0.0",
"ngx-skeleton-loader": "11.3.0",
"ngx-stripe": "20.7.0",
"open-color": "1.9.1",
"papaparse": "5.3.1",
"passport": "0.7.0",
@ -25113,20 +25112,6 @@
"@angular/core": ">=19.0.0"
}
},
"node_modules/ngx-stripe": {
"version": "20.7.0",
"resolved": "https://registry.npmjs.org/ngx-stripe/-/ngx-stripe-20.7.0.tgz",
"integrity": "sha512-gwrjOSfGKXgdjlqyxt61Tz6kKnlJhs38iMqAuyZH+UJ2TeClBA4+iywIheTU3GOg8DLnaANKunr7BDO/gjQkPQ==",
"license": "MIT",
"dependencies": {
"tslib": "^2.3.0"
},
"peerDependencies": {
"@angular/common": ">=20.0.0 <21.0.0",
"@angular/core": ">=20.0.0 <21.0.0",
"@stripe/stripe-js": ">=7.0.0 <8.0.0"
}
},
"node_modules/nice-try": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz",

1
package.json

@ -120,7 +120,6 @@
"ngx-device-detector": "10.1.0",
"ngx-markdown": "20.0.0",
"ngx-skeleton-loader": "11.3.0",
"ngx-stripe": "20.7.0",
"open-color": "1.9.1",
"papaparse": "5.3.1",
"passport": "0.7.0",

Loading…
Cancel
Save