-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stripe.redirectToCheckout does not exist on type stripe #69
Comments
Its really of a big concern because i really need it to redirect me to stripe checkout from my angular app |
@donemmx it looks like you're importing the stripe node library rather than Stripe.js. You will want to do this instead: https://github.com/stripe/stripe-js#installation
|
please how where do i add const stripe = await loadStripe('pk_test_TYooMQauvdEDq54NiTphI7jx'); this line that won't make it throw errors. |
import { AngularFirestore } from '@angular/fire/firestore'; @component({ async subscribe() { ngOnInit(): void {} |
You need to make the // Wait for the CheckoutSession to get attached by the extension
docRef.onSnapshot(async (snap) => {
const { sessionId } = snap.data();
if (sessionId) {
// We have a session, let's redirect to Checkout
// Init Stripe
const stripe = await loadStripe("pk_test_*****************");
stripe.redirectToCheckout({ sessionId });
}
}); |
thank you so much it works. no more errors...hurray... awesome |
Glad to hear that 🎉 |
please how do i fix this issue.
import { AngularFirestore } from '@angular/fire/firestore';
import { ServicesClass } from './../services/service';
import { Component, OnInit } from '@angular/core';
import Stripe from 'stripe';
@component({
selector: 'app-plans',
templateUrl: './plans.component.html',
styleUrls: ['./plans.component.css'],
})
export class PlansComponent implements OnInit {
plans;
constructor(private afs: AngularFirestore, public service: ServicesClass) {
this.afs
.collection('products')
.ref.where('active', '==', true)
.get()
.then(function (querySnapshot) {
querySnapshot.forEach(async function (doc) {
console.log(doc.id, ' => ', doc.data());
// const priceSnap = await doc.ref.collection('prices').get();
// priceSnap.docs.forEach((doc) => {
// console.log(doc.id, ' => ', doc.data());
// });
});
});
}
async subscribe() {
const docRef = await this.afs
.collection('users')
.doc(this.service.userData.uid)
.collection('checkout_sessions')
.add({
price: 'price_1GqIC8HYgolSBA35zoTTN2Zl',
success_url: window.location.origin,
cancel_url: window.location.origin,
});
// Wait for the CheckoutSession to get attached by the extension
docRef.onSnapshot((snap) => {
const { sessionId } = snap.data();
if (sessionId) {
// We have a session, let's redirect to Checkout
// Init Stripe
}
ngOnInit(): void {}
}
The text was updated successfully, but these errors were encountered: