wip
This commit is contained in:
parent
0ef2f58379
commit
177dd78592
11 changed files with 148 additions and 1 deletions
32
frontend/src/app/deposit/deposit.component.ts
Normal file
32
frontend/src/app/deposit/deposit.component.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { loadStripe, Stripe } from '@stripe/stripe-js';
|
||||
|
||||
@Component({
|
||||
selector: 'app-deposit',
|
||||
standalone: true,
|
||||
imports: [
|
||||
ReactiveFormsModule,
|
||||
],
|
||||
templateUrl: './deposit.component.html',
|
||||
styleUrl: './deposit.component.css'
|
||||
})
|
||||
export class DepositComponent implements OnInit{
|
||||
protected form = new FormGroup({amount: new FormControl(50, [Validators.min(50)])});
|
||||
private stripe: Stripe | null;
|
||||
|
||||
async ngOnInit() {
|
||||
this.stripe = await loadStripe('pk_test_51');
|
||||
}
|
||||
|
||||
submit() {
|
||||
if (this.stripe) {
|
||||
fetch('/backend/deposit/checkout', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(this.form.value),
|
||||
}).then(response => response.json()).then(response => {
|
||||
this.stripe?.redirectToCheckout({sessionId: response.sessionId});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in a new issue