Fixed checkout logic (again)

This commit is contained in:
itzMiney committed 2025-08-07 19:52:24 +02:00
1 parent 7c193d8ad7
commit 108b05c89d
2 files changed
+7 -7

No files matched your search

+1 -1
View File
@@ -36,7 +36,7 @@
<button
class="buy-button"
*ngIf="getActivePriceId(service, activeTab[i])"
(click)="checkout(getActivePriceId(service, activeTab[i]) || '')">
(click)="checkout(getActivePriceId(service, activeTab[i])!)">
Buy Service
</button>
</div>
+6 -6
View File
@@ -5,7 +5,6 @@ import {Title} from '@angular/platform-browser';
import {isPlatformBrowser, NgIf, NgFor, NgStyle} from '@angular/common';
import {TranslatePipe, TranslateService} from '@ngx-translate/core';
import {HttpClient} from '@angular/common/http';
import {Observable, tap} from 'rxjs';
@Component({
selector: 'app-services',
@@ -154,16 +153,17 @@ export class ServicesComponent implements OnInit, OnDestroy, AfterViewInit {
this.vantaService.resizeVanta(this.elementId);
}
checkout(priceId: string): Observable<any> {
return this.http.post<any>(this.apiUrl, { priceId }).pipe(
tap((response) => {
checkout(priceId: string): void {
this.http.post<any>(this.apiUrl, { priceId }).subscribe({
next: (response) => {
if (response.url) {
window.location.href = response.url;
} else {
alert('Checkout session failed.');
}
})
);
},
error: () => alert('Checkout session failed.')
});
}
getActivePriceId(service: any, activeTab: string): string | null {