|
|
|
@ -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; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|