You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.0 KiB
TypeScript

import { Component } from '@angular/core';
import { StripeService } from 'src/app/services/stripe.service';
import { environment } from 'config';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss']
})
export class HomeComponent {
constructor(private stripeService: StripeService) { }
payment(): void {
const priceId = environment.PriceIdKey; // Replace with your Stripe price object ID
const quantity = '1'; // Replace with your desired quantity
this.stripeService.createPaymentLink(priceId, quantity)
.subscribe(
(response) => {
console.log('Payment link created successfully:', response);
// You can handle the payment link here
// Open the URL in a new window
if (response.url) {
window.open(response.url, '_blank');
}
},
(error) => {
console.error('Error creating payment link:', error);
// Handle the error here
}
);
}
}