#j_code
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1289300829513187339
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
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.
- j_invoice-promotioncode, 3 days ago, 10 messages
? await stripe.promotionCodes.retrieve(promotionCodeId)
: undefined;```
aaand here's how we get maybePromotionCode,
and here's the error.
```Type '{ default_tax_rates: string[]; discounts?: { promotion_code: string; }[]; customer: string; collection_method: "charge_automatically"; default_payment_method: string; auto_advance: true; }' is not assignable to type 'InvoiceCreateParams'.
Types of property 'discounts' are incompatible.
Type '{ promotion_code: string; }[]' is not assignable to type 'Emptyable<Discount[]>'.
Type '{ promotion_code: string; }[]' is not assignable to type 'Discount[]'.
Object literal may only specify known properties, and 'promotion_code' does not exist in type 'Discount'.ts(2322)```
Hey there, taking a look at this, please bear with me
That looks like a typescript error, not a stirpe error
It seems like you're not actually sending a request yet, or are you?
its using. type in your code-- specifically RE: the discount type
/**
* ID of the coupon to create a new discount for.
*/
coupon?: string;
/**
* ID of an existing discount on the object (or one of its ancestors) to reuse.
*/
discount?: string;
}```
im trying specifically to send a one time invoice for the promotion code and not the coupon, how would i adjust an invoiceCreateParams call
What version of stripe-node are you using?
Your parameter shape looks valid, so no idea why TS is upset about it
But I don't know what Emptyable<Discount[]> means
This might be an inference problem, you might need to force the type for discounts when you're passing it in line like that
8.222.0.?
"In TypeScript, Emptyable<T> is typically a utility type that allows a type T to also be null or undefined. It effectively means that the type can either be the specified type or nothing at all." apparently.
Type 'Discount[]' is not assignable to type 'Emptyable<Discount[]>'.
Type 'import("stripe").Stripe.Discount[]' is not assignable to type 'import("stripe").Stripe.InvoiceCreateParams.Discount[]'.
Type 'import("stripe").Stripe.Discount' is not assignable to type 'import("stripe").Stripe.InvoiceCreateParams.Discount'.
Types of property 'coupon' are incompatible.
Type 'Coupon' is not assignable to type 'string'.ts(2322)```
Updated error with fix
fix being
doing this gives you "cannot find type discount"
even getting this out of the way, the interface provided does not contain "promotion_code" at all.
This type first appears in release 15.0.0
Your version is quote old, so i would recommend updating to a newer release
Yeah. That would do it... time to get my team to update Stripe
but in the interim you can ignore the type error
Will do! Thank you