Stripe Integration

This commit is contained in:
2024-08-20 23:27:07 +02:00
parent 056db7b199
commit 48bff89526
28 changed files with 728 additions and 21 deletions

View File

@@ -0,0 +1,32 @@
// 1. Shared Service (modal.service.ts)
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
@Injectable({
providedIn: 'root',
})
export class PaymentService {
private modalVisibleSubject = new BehaviorSubject<boolean>(false);
modalVisible$: Observable<boolean> = this.modalVisibleSubject.asObservable();
private resolvePromise!: (value: boolean) => void;
constructor(private http: HttpClient) {}
openPaymentModal() {
this.modalVisibleSubject.next(true);
return new Promise<boolean>(resolve => {
this.resolvePromise = resolve;
});
}
accept(): void {
this.modalVisibleSubject.next(false);
this.resolvePromise(true);
}
reject(): void {
this.modalVisibleSubject.next(false);
this.resolvePromise(false);
}
processPayment(token: string): Observable<any> {
return this.http.post('/api/subscription', { token });
}
}