#raphael-invoice

1 messages · Page 1 of 1 (latest)

thin current
#

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?

past topaz
#

Yes, I don't have any typescript errors

#

I'm using NestJS and Lerna (I don't know if it can help for context 🤷‍♂️ )

thin current
#

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)
past topaz
#

When I write console.log(stripe.VERSION) I have a ts error:
Property 'VERSION' does not exist on type 'Stripe'

thin current
#

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?

past topaz
#

I'm using '2022-08-01'

#

I define it there

#
this._stripe = new Stripe(this.secretService.STRIPE_SECRET_KEY, {
      apiVersion: '2022-08-01',
    });
thin swallow
#

👋 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?

past topaz
#
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

thin swallow
#

and how are you using that service?

past topaz
#

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();

thin swallow
#

I don't think you need to await for the getStripe