#eriktoor
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- eriktoor, 22 hours ago, 25 messages
Did you expand ['latest_invoice.payment_intent'] ?
Yes this is my full code
try {
// Create the subscription. Note we're expanding the Subscription's
// latest invoice and that invoice's payment_intent
// so we can pass it to the front end to confirm the payment
const subscription = await stripe.subscriptions.create({
customer: customerId,
items: [{
price: priceId,
}],
payment_behavior: 'default_incomplete',
payment_settings: { save_default_payment_method: 'on_subscription' },
expand: ['latest_invoice.payment_intent'],
});
res.send({
subscriptionId: subscription.id,
clientSecret: subscription.latest_invoice?.payment_intent?.client_secret,
});
} catch (error) {
return res.status(400).send({ error: { message: error.message } });
}
I guess the ts doesn't get it?
src/routes/premium/createStripeSubscription.ts:31:50 - error TS2339: Property 'payment_intent' does not exist on type 'string | Invoice'.
Property 'payment_intent' does not exist on type 'string'.
31 clientSecret: subscription.latest_invoice?.payment_intent?.client_secret,
~~~~~~~~~~~~~~
You have latest_invoice.payment_intent expanded
Yes
When you do console.log(subscription), what do you get?
lol i can't run it bc i use nodemon so it won't run unless if all of the ts works
Property 'payment_intent' does not exist on type 'string | Invoice'.
Property 'payment_intent' does not exist on type 'string'.
So I have this error
Let me check my version
"stripe": "^14.1.0",
what version would be better? I see there is up to 14.9.0
This might do the job -- https://stackoverflow.com/questions/74003147/payment-intent-is-not-definedtypescript
ya fyi that has seemed to the do the job
Wait @wraith sable I am now getting that there is no latest_invoice in here hmmm
This is my object
I can see a latest_invoice in the json file that you just sent
Hm why can't i parse it that's sus
const invoice = subscription.latest_invoice as Stripe.Invoice;
if (invoice.payment_intent) {
const intent = invoice.payment_intent as Stripe.PaymentIntent;
res.send({
subscriptionId: subscription.id,
clientSecret: intent.client_secret,
});
}
it thinks that there is no payment intent in there
but there clearly is