#josula_api

1 messages ¡ Page 1 of 1 (latest)

wary capeBOT
#

👋 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/1485992106529919108

📝 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.

fleet tapir
#

Basically I'm trying to tie the payment intent to the invoice. The customer should be able to then go on to the invoice to pay. We do not know up front what payment method they will choose but in case they choose the bank transfer (which many of our customers do), I want the bank details of the payment intent on the invoice PDF and not of the invoice-specific payment intent.

I know this is not the typical Stripe logic because what you would usually do is take the invoice, finalize it, and then take the payment intent of that invoice. This breaks with our other flows because we have multiple ways that customers can pay, for example via our e-commerce shop but they can also manually pay or via other channels. We want to keep one straight flow for all of these to keep things tidy and in line. That's why I need to go the other way around by creating the payment intent first and then attaching it to the invoice once it is finalized.

#

I know this can be a bit confusing so let me know if you have any questions or if something is not clear

#

Maybe here again, written down in the logical steps when we create a manual order from our admin UI

  1. We create a new Stripe invoice in draft.
  2. We create a payment intent with all possible payment methods, including the bank transfer.
  3. Once the goods have been shipped from our warehouse, we finalize the invoice so that it's in state open and in the exact same step we attach the payment intent from step one to this invoice.
  4. When the customer now goes onto the invoice PDF and sees the payment details from the invoice, I want the payment details to be shown from the payment intent that I attached in step three and not the payment intent details of the invoice-specific payment intent that is automatically created when finalising the invoice
tulip tapir
#

I want the bank details of the payment intent on the invoice PDF and not of the invoice-specific payment intent.
Can you say more about this, i dont really understand what you mean here by bank details on the PDF

fleet tapir
#

Okay, say I sent out an invoice to a customer which has not been paid yet. At the bottom, they will see the bank details of that invoice: like in the screenshot

#

However, this would be - from my understanding the INVOICEs bank details, not the one from the payment intent

#

see Reference, which is an invoice number

#

However, I want the customer to pay the PAYMENT INTENT attached to that invoice. which has a different Reference in that case

#

When I send out this PDF to our customer, they will most likely transfer it to the wrong account with the wrong reference

#

Ideally, the reference would be generated from the attached payment intent, which has a payment method bank transfer enabled

#

The customer thinks they would be paying the invoice, but actually they are paying the payment intent, which in turn is attached to the invoice. This would then also mark the invoice as paid

tulip tapir
#

So the way this works is a single virtual bank account (VBAN) for the customer which should be the same for all use cases, and only the recommended reference for the individual payment changes

#

but auto reconciliation should handle that even where its not a match

#

This will not include any specific reference because its not payment-specific at this point, its just setting up the payment destination VBAN

fleet tapir
#

ok I decided to go on here with the classic flow in this case

#

so we do this from the invoice perspective here

#

create the invoice

#

finalise it

#

how can I retrieve the payment intent of a finalised invoice in the current node sdk?

wary capeBOT
tulip tapir
#

Can you share an example invoice / request?

#

Likely you'll need to access that via the InvoicePayments API

fleet tapir
#

ok this works but the types do not:

` async retrieveInvoicePaymentIntentId(invoiceId: string): Promise<string | null> {
// Extend the Stripe.Invoice type to include a typed payment_intent (with Stripe.PaymentIntent type)
type InvoiceWithExpandedPI = Stripe.Invoice & { payment_intent: Stripe.PaymentIntent | null };

const invoice = await this.stripe_.invoices.retrieve(invoiceId, {
  expand: ["payment_intent"],
}) as InvoiceWithExpandedPI;

const pi = invoice.payment_intent;
if (!pi) return null;
return pi.id ?? null;

}`

#

how could I correctly expand the type here so it returns to me type Invoice with payment_intent type Stripe.PaymentINtent?

woeful falcon
#

Hello! Taking over for my colleague who had to step away.

fleet tapir
#

Ah I managed

#

sorry

#

` type InvoiceWithExpandedPI = Stripe.Invoice & { payment_intent: Stripe.PaymentIntent | null };

const invoice = await this.stripe_.invoices.retrieve(invoiceId, {
  expand: ["payment_intent"],
}) as Stripe.Response<InvoiceWithExpandedPI>;`
#

this works

#

had to augment the type via Stripe.Response

#

is there a cleaner way to do this in typescript?