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

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

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

8
apps/client/src/main.ts

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

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

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

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

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

15
package-lock.json

@ -76,7 +76,6 @@
"ngx-device-detector": "10.1.0", "ngx-device-detector": "10.1.0",
"ngx-markdown": "20.0.0", "ngx-markdown": "20.0.0",
"ngx-skeleton-loader": "11.3.0", "ngx-skeleton-loader": "11.3.0",
"ngx-stripe": "20.7.0",
"open-color": "1.9.1", "open-color": "1.9.1",
"papaparse": "5.3.1", "papaparse": "5.3.1",
"passport": "0.7.0", "passport": "0.7.0",
@ -25113,20 +25112,6 @@
"@angular/core": ">=19.0.0" "@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": { "node_modules/nice-try": {
"version": "1.0.5", "version": "1.0.5",
"resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", "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-device-detector": "10.1.0",
"ngx-markdown": "20.0.0", "ngx-markdown": "20.0.0",
"ngx-skeleton-loader": "11.3.0", "ngx-skeleton-loader": "11.3.0",
"ngx-stripe": "20.7.0",
"open-color": "1.9.1", "open-color": "1.9.1",
"papaparse": "5.3.1", "papaparse": "5.3.1",
"passport": "0.7.0", "passport": "0.7.0",

Loading…
Cancel
Save