feat: add deposit with stripe (CAS-28) #23
@ -18,5 +18,5 @@ export const routes: Routes = [
|
|||||||
path: 'deposit',
|
path: 'deposit',
|
||||||
component: DepositComponent,
|
component: DepositComponent,
|
||||||
canActivate: [authGuard],
|
canActivate: [authGuard],
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
@if (errorMsg) {
|
@if (errorMsg) {
|
||||||
<div>{{ errorMsg }}</div>
|
<div>{{ errorMsg }}</div>
|
||||||
}
|
}
|
||||||
<input type="number" formControlName="amount">€
|
<input type="number" formControlName="amount" />€
|
||||||
<br>
|
<br />
|
||||||
<button type="button" (click)="submit()">Einzahlen</button>
|
<button type="button" (click)="submit()">Einzahlen</button>
|
||||||
</form>
|
</form>
|
||||||
|
@ -7,9 +7,7 @@ import { debounceTime } from 'rxjs';
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-deposit',
|
selector: 'app-deposit',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [ReactiveFormsModule],
|
||||||
ReactiveFormsModule,
|
|
||||||
],
|
|
||||||
templateUrl: './deposit.component.html',
|
templateUrl: './deposit.component.html',
|
||||||
styleUrl: './deposit.component.css',
|
styleUrl: './deposit.component.css',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
@ -25,15 +23,15 @@ export class DepositComponent implements OnInit {
|
|||||||
amount: new FormControl(50, [Validators.min(50)]),
|
amount: new FormControl(50, [Validators.min(50)]),
|
||||||
});
|
});
|
||||||
|
|
||||||
this.form.controls['amount'].valueChanges
|
this.form.controls['amount'].valueChanges.pipe(debounceTime(1000)).subscribe((value) => {
|
||||||
.pipe(debounceTime(1000))
|
|
||||||
.subscribe((value) => {
|
|
||||||
if (value < 50) {
|
if (value < 50) {
|
||||||
this.errorMsg = 'Minimum Einzahlungsbetrag ist 50€';
|
this.errorMsg = 'Minimum Einzahlungsbetrag ist 50€';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.stripe = await loadStripe('pk_test_51QrePYIvCfqz7ANgMizBorPpVjJ8S6gcaL4yvcMQnVaKyReqcQ6jqaQEF7aDZbDu8rNVsTZrw8ABek4ToxQX7KZe00jpGh8naG');
|
this.stripe = await loadStripe(
|
||||||
|
'pk_test_51QrePYIvCfqz7ANgMizBorPpVjJ8S6gcaL4yvcMQnVaKyReqcQ6jqaQEF7aDZbDu8rNVsTZrw8ABek4ToxQX7KZe00jpGh8naG'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
submit() {
|
submit() {
|
||||||
|
@ -2,14 +2,13 @@ import { inject, Injectable } from '@angular/core';
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class DepositService {
|
export class DepositService {
|
||||||
private http: HttpClient = inject(HttpClient);
|
private http: HttpClient = inject(HttpClient);
|
||||||
|
|
||||||
handleDeposit(amount: number): Observable<{ sessionId: string }> {
|
handleDeposit(amount: number): Observable<{ sessionId: string }> {
|
||||||
return this.http.post<{sessionId: string}>('/backend/deposit/checkout', {amount});
|
return this.http.post<{ sessionId: string }>('/backend/deposit/checkout', { amount });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user