#raphael-invoice
1 messages · Page 1 of 1 (latest)
let me have a look into this
I'm trying this on my side and it seems to be working
maybe it's just a missing Typescript definition?
although the definition does exist(https://github.com/stripe/stripe-node/blob/master/types/2022-08-01/Invoices.d.ts#L3012-L3024) so I don't think it's that really. Is there any more context you can give?
Yes, I don't have any typescript errors
I'm using NestJS and Lerna (I don't know if it can help for context 🤷♂️ )
I honestly don't know what those are
are you sure you're using the version of the library you say you are? console.log(stripe.VERSION) is a way to check at runtime
in any case your code as written won't work since you don't finalize the invoice before paying it(see my code for a more complete example), so that has to be addressed too
invoice = await stripe.invoices.finalizeInvoice(invoice.id, {expand:["payment_intent"]});
console.log(stripe.VERSION)
await stripe.invoices.pay(invoice.id)
When I write console.log(stripe.VERSION) I have a ts error:
Property 'VERSION' does not exist on type 'Stripe'
I'm not sure what would cause that either, to be honest.
what's the invoice ID in_xxx so we can look at your API logs and see what version of the library you might be using?
I'm using '2022-08-01'
I define it there
this._stripe = new Stripe(this.secretService.STRIPE_SECRET_KEY, {
apiVersion: '2022-08-01',
});
👋 taking over for my colleague. Let me catch up.
I'm seeing you using this._stripe and sometimes using stripe directly
how are you defining your stripe instance? Are you exposing it through some sort of service?
import Stripe from 'stripe';
@Injectable()
export class StripeService {
private _stripe: Stripe;
constructor(
@Inject(SecretKeysProvider)
private readonly secretService: OwnAppSecrets,
) {}
private initStripe(): void {
if (this._stripe) {
return;
}
this._stripe = new Stripe(this.secretService.STRIPE_SECRET_KEY, {
apiVersion: '2022-08-01',
});
}
}
I define it like that
and how are you using that service?
In the service I have a getStripe function
public getStripe(): Stripe {
this.initStripe();
return this._stripe;
}
That I call in other service like that:
const stripe = await this.stripeService.getStripe();
I don't think you need to await for the getStripe