Added stripe support
This commit is contained in:
1 parent
f000688d4e
commit
b4020ee40b
12 files changed
+313
-13
No files matched your search
@@ -12,6 +12,8 @@ import {TosComponent} from './tos/tos.component';
|
||||
import {ImprintComponent} from './imprint/imprint.component';
|
||||
import {ShortenerComponent} from './shortener/shortener.component';
|
||||
import {PrivacyComponent} from './privacy/privacy.component';
|
||||
import {SuccessComponent} from './checkout/success/success.component';
|
||||
import {CancelComponent} from './checkout/cancel/cancel.component';
|
||||
|
||||
export const routes: Routes = [
|
||||
{ path: '', component: AboutComponent },
|
||||
@@ -27,5 +29,7 @@ export const routes: Routes = [
|
||||
{ path: 'imprint', component: ImprintComponent },
|
||||
{ path: 'blog/:slug', component: ArticlePageComponent },
|
||||
{ path: 'shortener', component: ShortenerComponent },
|
||||
{ path: 'checkout/success', pathMatch: 'full', component: SuccessComponent },
|
||||
{ path: 'checkout/cancel', pathMatch: 'full', component: CancelComponent },
|
||||
{ path: '**', pathMatch: 'full', component: NotFoundComponent }
|
||||
];
|
||||
@@ -0,0 +1,41 @@
|
||||
@keyframes fadeIn {
|
||||
0% {
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
|
||||
#vanta-cancel-bg {
|
||||
animation: fadeIn 1s ease-out;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
z-index: -100;
|
||||
}
|
||||
|
||||
.cancel-container {
|
||||
position: relative;
|
||||
color: white;
|
||||
padding-bottom: 60px;
|
||||
max-width: 960px;
|
||||
margin: 160px auto 80px auto;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.height-container {
|
||||
min-height: 100vh;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
.privacy-content {
|
||||
font-weight: 400;
|
||||
margin-bottom: 10px;
|
||||
font-family: Roboto, sans-serif;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<div id="vanta-cancel-bg"></div>
|
||||
<div class="height-container">
|
||||
<div class="cancel-container">
|
||||
<h1>{{ 'CANCEL' | translate }}</h1>
|
||||
<p>{{ 'CANCEL_SUB' | translate }}</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,51 @@
|
||||
import {AfterViewInit, Component, Inject, OnDestroy, OnInit, PLATFORM_ID} from '@angular/core';
|
||||
import {TranslatePipe} from "@ngx-translate/core";
|
||||
import {VantaBackgroundService} from '../../shared/services/vanta-background.service';
|
||||
import {DeviceDetectorService} from '../../shared/services/device-detector.service';
|
||||
import {Title} from '@angular/platform-browser';
|
||||
import {isPlatformBrowser} from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-cancel',
|
||||
imports: [
|
||||
TranslatePipe
|
||||
],
|
||||
templateUrl: './cancel.component.html',
|
||||
styleUrl: './cancel.component.css'
|
||||
})
|
||||
export class CancelComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
private readonly elementId = 'vanta-cancel-bg';
|
||||
isMobile: boolean = false;
|
||||
|
||||
constructor(
|
||||
private vantaService: VantaBackgroundService,
|
||||
private deviceService: DeviceDetectorService,
|
||||
private titleService: Title,
|
||||
@Inject(PLATFORM_ID) private platformId: Object
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.titleService.setTitle('Checkout | itzMiney');
|
||||
this.isMobile = this.deviceService.isMobile;
|
||||
if (isPlatformBrowser(this.platformId)) {
|
||||
window.addEventListener('resize', this.onResize.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.vantaService.initVanta(this.elementId, {
|
||||
color: 0x5b417a,
|
||||
backgroundColor: 0x41e3c
|
||||
});
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.vantaService.destroyVanta(this.elementId);
|
||||
if (isPlatformBrowser(this.platformId)) {
|
||||
window.removeEventListener('resize', this.onResize);
|
||||
}
|
||||
}
|
||||
|
||||
onResize() {
|
||||
this.vantaService.resizeVanta(this.elementId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
@keyframes fadeIn {
|
||||
0% {
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
|
||||
#vanta-success-bg {
|
||||
animation: fadeIn 1s ease-out;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
z-index: -100;
|
||||
}
|
||||
|
||||
.success-container {
|
||||
position: relative;
|
||||
color: white;
|
||||
padding-bottom: 60px;
|
||||
max-width: 960px;
|
||||
margin: 160px auto 80px auto;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.height-container {
|
||||
min-height: 100vh;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
.privacy-content {
|
||||
font-weight: 400;
|
||||
margin-bottom: 10px;
|
||||
font-family: Roboto, sans-serif;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<div id="vanta-success-bg"></div>
|
||||
<div class="height-container">
|
||||
<div class="success-container">
|
||||
<h1>{{ 'SUCCESS' | translate }}</h1>
|
||||
<p>{{ 'SUCCESS_SUB' | translate }}</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,51 @@
|
||||
import {AfterViewInit, Component, Inject, OnDestroy, OnInit, PLATFORM_ID} from '@angular/core';
|
||||
import {isPlatformBrowser} from '@angular/common';
|
||||
import {TranslatePipe} from '@ngx-translate/core';
|
||||
import {VantaBackgroundService} from '../../shared/services/vanta-background.service';
|
||||
import {DeviceDetectorService} from '../../shared/services/device-detector.service';
|
||||
import {Title} from '@angular/platform-browser';
|
||||
|
||||
@Component({
|
||||
selector: 'app-success',
|
||||
imports: [
|
||||
TranslatePipe
|
||||
],
|
||||
templateUrl: './success.component.html',
|
||||
styleUrl: './success.component.css'
|
||||
})
|
||||
export class SuccessComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
private readonly elementId = 'vanta-success-bg';
|
||||
isMobile: boolean = false;
|
||||
|
||||
constructor(
|
||||
private vantaService: VantaBackgroundService,
|
||||
private deviceService: DeviceDetectorService,
|
||||
private titleService: Title,
|
||||
@Inject(PLATFORM_ID) private platformId: Object
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.titleService.setTitle('Checkout | itzMiney');
|
||||
this.isMobile = this.deviceService.isMobile;
|
||||
if (isPlatformBrowser(this.platformId)) {
|
||||
window.addEventListener('resize', this.onResize.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.vantaService.initVanta(this.elementId, {
|
||||
color: 0x5b417a,
|
||||
backgroundColor: 0x41e3c
|
||||
});
|
||||
}
|
||||
ngOnDestroy() {
|
||||
this.vantaService.destroyVanta(this.elementId);
|
||||
if (isPlatformBrowser(this.platformId)) {
|
||||
window.removeEventListener('resize', this.onResize);
|
||||
}
|
||||
}
|
||||
|
||||
onResize() {
|
||||
this.vantaService.resizeVanta(this.elementId);
|
||||
}
|
||||
}
|
||||
@@ -116,6 +116,24 @@
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.buy-button {
|
||||
background-color: rgba(187, 107, 209, 0.5);
|
||||
border: none;
|
||||
border-radius: 25px;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin-inline: 15px;
|
||||
margin-top: 20px;
|
||||
font-size: 1rem;
|
||||
cursor: pointer;
|
||||
width: 110px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.buy-button:hover {
|
||||
background-color: rgba(187, 107, 209, 0.62);
|
||||
}
|
||||
|
||||
.tab-content {
|
||||
margin-top: 10px;
|
||||
font-size: 0.9rem;
|
||||
|
||||
@@ -22,16 +22,23 @@
|
||||
<button
|
||||
class="tab-btn"
|
||||
[class.active]="activeTab[i] === 'basic'"
|
||||
(click)="switchTab(i, 'basic')">Basic</button>
|
||||
(click)="switchTab(i, 'basic')">
|
||||
Basic
|
||||
</button>
|
||||
<button
|
||||
class="tab-btn"
|
||||
[class.active]="activeTab[i] === 'advanced'"
|
||||
(click)="switchTab(i, 'advanced')">Advanced</button>
|
||||
</div>
|
||||
<div *ngIf="activeTab[i] === 'basic'" class="tab-content" [innerHTML]="service.basic">
|
||||
</div>
|
||||
<div *ngIf="activeTab[i] === 'advanced'" class="tab-content" [innerHTML]="service.advanced">
|
||||
(click)="switchTab(i, 'advanced')">
|
||||
Advanced
|
||||
</button>
|
||||
</div>
|
||||
<div class="tab-content" [innerHTML]="activeTab[i] === 'basic' ? service.basic : service.advanced"></div>
|
||||
<button
|
||||
class="buy-button"
|
||||
*ngIf="getActivePriceId(service, activeTab[i])"
|
||||
(click)="checkout(getActivePriceId(service, activeTab[i]) || '')">
|
||||
Buy Service
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -22,7 +22,13 @@ export class ServicesComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
isMobile: boolean = false;
|
||||
activeTab: string[] = [];
|
||||
|
||||
services: { name: string; basic: string; advanced: string }[] = [];
|
||||
services: {
|
||||
name: string;
|
||||
basic: string;
|
||||
advanced: string;
|
||||
basicPriceId: string;
|
||||
advancedPriceId: string;
|
||||
}[] = [];
|
||||
|
||||
constructor(
|
||||
private vantaService: VantaBackgroundService,
|
||||
@@ -48,6 +54,9 @@ export class ServicesComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
|
||||
loadServices(): void {
|
||||
this.translate.get([
|
||||
'SERVICES.PTERO_NAME',
|
||||
'SERVICES.PTERO_BASIC',
|
||||
'SERVICES.PTERO_ADVANCED',
|
||||
'SERVICES.SUPPORT_NAME',
|
||||
'SERVICES.SUPPORT_BASIC',
|
||||
'SERVICES.SUPPORT_ADVANCED',
|
||||
@@ -68,35 +77,54 @@ export class ServicesComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
'SERVICES.SERVER_SETUP_ADVANCED'
|
||||
]).subscribe(translations => {
|
||||
this.services = [
|
||||
{
|
||||
name: translations['SERVICES.PTERO_NAME'],
|
||||
basic: translations['SERVICES.PTERO_BASIC'],
|
||||
advanced: translations['SERVICES.PTERO_ADVANCED'],
|
||||
basicPriceId: 'price_1RscMR2LT0gYeSqcQ7SDj6gG',
|
||||
advancedPriceId: 'price_1RscMR2LT0gYeSqcQ7SDj6gG'
|
||||
},
|
||||
{
|
||||
name: translations['SERVICES.SUPPORT_NAME'],
|
||||
basic: translations['SERVICES.SUPPORT_BASIC'],
|
||||
advanced: translations['SERVICES.SUPPORT_ADVANCED']
|
||||
advanced: translations['SERVICES.SUPPORT_ADVANCED'],
|
||||
basicPriceId: '',
|
||||
advancedPriceId: ''
|
||||
},
|
||||
{
|
||||
name: translations['SERVICES.WP_FILES_NAME'],
|
||||
basic: translations['SERVICES.WP_FILES_BASIC'],
|
||||
advanced: translations['SERVICES.WP_FILES_ADVANCED']
|
||||
advanced: translations['SERVICES.WP_FILES_ADVANCED'],
|
||||
basicPriceId: '',
|
||||
advancedPriceId: ''
|
||||
},
|
||||
{
|
||||
name: translations['SERVICES.WP_SETUP_NAME'],
|
||||
basic: translations['SERVICES.WP_SETUP_BASIC'],
|
||||
advanced: translations['SERVICES.WP_SETUP_ADVANCED']
|
||||
advanced: translations['SERVICES.WP_SETUP_ADVANCED'],
|
||||
basicPriceId: '',
|
||||
advancedPriceId: ''
|
||||
},
|
||||
{
|
||||
name: translations['SERVICES.ANGULAR_FILES_NAME'],
|
||||
basic: translations['SERVICES.ANGULAR_FILES_BASIC'],
|
||||
advanced: translations['SERVICES.ANGULAR_FILES_ADVANCED']
|
||||
advanced: translations['SERVICES.ANGULAR_FILES_ADVANCED'],
|
||||
basicPriceId: '',
|
||||
advancedPriceId: ''
|
||||
},
|
||||
{
|
||||
name: translations['SERVICES.ANGULAR_SETUP_NAME'],
|
||||
basic: translations['SERVICES.ANGULAR_SETUP_BASIC'],
|
||||
advanced: translations['SERVICES.ANGULAR_SETUP_ADVANCED']
|
||||
advanced: translations['SERVICES.ANGULAR_SETUP_ADVANCED'],
|
||||
basicPriceId: '',
|
||||
advancedPriceId: ''
|
||||
},
|
||||
{
|
||||
name: translations['SERVICES.SERVER_SETUP_NAME'],
|
||||
basic: translations['SERVICES.SERVER_SETUP_BASIC'],
|
||||
advanced: translations['SERVICES.SERVER_SETUP_ADVANCED']
|
||||
advanced: translations['SERVICES.SERVER_SETUP_ADVANCED'],
|
||||
basicPriceId: '',
|
||||
advancedPriceId: ''
|
||||
}
|
||||
];
|
||||
|
||||
@@ -121,4 +149,29 @@ export class ServicesComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
// Update the minHeight and minWidth when the window is resized
|
||||
this.vantaService.resizeVanta(this.elementId);
|
||||
}
|
||||
|
||||
checkout(priceId: string): void {
|
||||
fetch('http://localhost:7020/api/stripe/create-checkout-session', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ priceId })
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
if (data.url) {
|
||||
window.location.href = data.url;
|
||||
} else {
|
||||
alert('Checkout session failed.');
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Stripe error:', err);
|
||||
alert('Error creating checkout session.');
|
||||
});
|
||||
}
|
||||
|
||||
getActivePriceId(service: any, activeTab: string): string | null {
|
||||
const priceId = activeTab === 'basic' ? service.basicPriceId : service.advancedPriceId;
|
||||
return priceId?.trim() || null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user