Stripe Integration
This commit is contained in:
32
bizmatch/src/app/components/payment/payment.service.ts
Normal file
32
bizmatch/src/app/components/payment/payment.service.ts
Normal 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 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user