#outfitxr-support_api

1 messages ยท Page 1 of 1 (latest)

hybrid heraldBOT
#

๐Ÿ‘‹ 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/1296017897964965948

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

errant spear
#

Hi

granite gull
#

Hi, could you elaborate a bit more on template ID? do you define a template and want to apply it?

#

Or just a piece of information you want to save to the Invoice?

errant spear
#

I've created a template invoice in the dashboard

#

now I want to use the template invoice during the creation of a session checkout

#

session = stripe.checkout.Session.create(

    payment_method_types=['ideal'],
    line_items=[
        {
            'price': price_id,
            'quantity': 1,
        },
    ],
    mode='payment',
    success_url='%s/payment-confirmation' % app.config["ENDPOINT_BACKOFFICE"],
    cancel_url='%s/payment-canceled?user_id=%s&appeals_id=%s' % (app.config["ENDPOINT_BACKOFFICE"], user_id, appeals_id),
    customer=customer.id,
    allow_promotion_codes=False,
    client_reference_id=id,
    invoice_creation={"enabled": True,
                      "invoice_data": {
                          "metadata": {
                              "appeals_id": appeals_id,
                              "user_id": user_id,
                              "invoice_template": "MB_invoice_001"
                          }
                      }
                      },

    automatic_tax={"enabled": True},

    metadata={
        "appeals_id": appeals_id,
        "user_id": user_id
    }
)
#

I've tried adding it to the metadata but nothing is happening. My template is not being used

#

"invoice_template": "MB_invoice_001"

#

How can I specify which invoice_template_id I want to use here?

granite gull
#

I think if you use a Customer which already has the template applied, then the Checkout Session with that Customer should generate an Invoice in yourtemplate

hybrid heraldBOT
errant spear
#

oh

#

I need to apply it to a customer?

#

how can I apply it to a customer?

#

customer = stripe.Customer.create(
email=customer_email,
name=company_name,
address={
'line1': line1,
'city': city,
'postal_code': postcode,
'country': 'NL'
}

    )
errant spear
#

thx

#

it is working

#

How can I change the content to my language?

lyric storm
errant spear
#

Ok

#

I've passed my invoice template id but it is still not being used. I do not see my customer footer in the latest generated invoice.

#

I do see the footer in the preview but not in the generated invoice pdf.

lyric storm
#

Could you please share the Invoice ID generated via API?

errant spear
#

in_1QASKZAAnLCdGvzV350W2h9c

#

but I am not creating an invoice directly this is done by the checkout session.

lyric storm
#

Still looking...

#

I see that the Invoice was created ~15 min ago, but Customer was updated <10 min ago. Could you try this again?

errant spear
#

Sure

#

Let me just create a new one

#

it is not working

#

in_1QASfTAAnLCdGvzVKZr6sJPR

#

try this invoice id

#

I justed generated it with a new client

#

I see the default invoice template but it is not being used

lyric storm
#

This might not be supported on Stripe Checkout... Confirming now.

#

Ok, it seems like Stripe Checkout uses it's own "template" and doesn't fall back to the Customer's default template, unfortunately. So this is not possible right now.

hybrid heraldBOT
errant spear
#

hmm

#

that is unfortunate

#

what is the work around?

#

because I tried to create custom invoice before or after the checkout but that results into creating 2x invoices everytime (one is automatically created by checkout)

lyric storm
#

You can create a Checkout Session in mode=setup to collect the PaymentMethod and then use it to create a Subscription on the backend.

errant spear
#

I do not create subscription, this is one-off payment.

wide warren
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

errant spear
#

Understood

wide warren
#

I think you can just create invoices with collection_method: send_invoice which is more suited in your case then creating Checkout Sessions

errant spear
#

but how do I create a payment link then?

wide warren
#

you don't have to, when using send_invoice as a collection_method, the customer will get an email with a link to a Stripe-Hosted Invoice page where they can directly pay the invoice

errant spear
#

no that will not work in our use case

wide warren
#

you can also use the pay link that was generated as well

errant spear
#

our use case: use submits a form in our web app then after pressing pay button the user will be redirected to stripe pay screen.

wide warren
errant spear
#

do you mean I do not need to do this "session = stripe.checkout.Session.create(" and just create an invoice?

wide warren
#

no

#

and then you return the hosted_invoice_url

#

to your frontend

#

and redirect the customer to that page

errant spear
#

understood

#

but that is not really a payment checkout page.

wide warren
#

when they click on Pay this invoice, it will ask for their payment method

errant spear
#

interesting

#

Ok

#

Let me test it

#

I am not getting the hosted_invoice_url instantly?

hybrid heraldBOT
errant spear
#

invoice_item = stripe.InvoiceItem.create(
customer=customer.id, # Associate the item with the customer
price=price_id, # Use the existing price object ID
quantity=1, # The quantity of the item
metadata={
"appeals_id": appeals_id,
"user_id": user_id
}
)

# Now, create the invoice itself
invoice = stripe.Invoice.create(
    customer=customer.id,  # The customer being billed
    auto_advance=True,  # Automatically finalize the invoice
    collection_method='send_invoice',  # Send the invoice to the customer
    days_until_due=14,  # Set payment due date in 14 days
    metadata={
        "appeals_id": appeals_id,
        "user_id": user_id
    },
    automatic_tax={"enabled": True},  # Enable automatic tax calculations
)

# Optionally, finalize and send the invoice right away
stripe.Invoice.finalize_invoice(invoice.id)

# Send the invoice (if not automatically sent)
stripe.Invoice.send_invoice(invoice.id)
#

This is my code

wide warren
#

you need to finalize the invoice first

#

then you'll get the url

errant spear
#

I am getting it

#

sorry

#

Where is the pay button?

mellow sleet
#

not there, because that's a $0 invoice so there's nothing to pay

errant spear
#

I saw it

#

I do see pay button

mellow sleet
errant spear
#

now

#

generating invoice now

#

ok

#

the template is used

#

why is the branding logo not applied to the invoice?

mellow sleet
#

what's the invoice ID

errant spear
#

in_1QAU55AAnLCdGvzVbnlnMicC

mellow sleet
errant spear
#

I cannot press save button?

mellow sleet
#

are you the admin/owner of the account?

errant spear
#

yes

#

I've uploaded logo but I cannot press save button

#

I can save in production but I cannot save in test env

mellow sleet
#

yeah I think that's normal, there's no such thing as testmode-specific settings, they're shared

errant spear
#

strange

#

how can I test if the invoice is generated succesfully?

mellow sleet
#

it should just work. I don't know, I help with the API/code questions and this seems more like a Dashboard issue.
I'd suggest logging out/clearing cache and trying again to go in and edit and save the settings until it works

#

quite possible there's a bug or a bad deploy/revision your browser is still using

errant spear
#

strange

#

for some reason it is now working

#

at least it is generating the pdf with branding

#

it seems all good now

#

should we keep this thread open for future questions?

mellow sleet
#

do you have any further questions?

#

otherwise I'll close this in ~30 minutes or so of being idle, you can open a new thread later for new questions

errant spear
#

one sec

#

after the payment can stripe do a redirect to our web app?

mellow sleet
#

for hosted invoice page, no.

errant spear
#

then we have a problem

#

we need to have a flow

  1. user submits form
  2. user pays
  3. user is redirected after payment.
mellow sleet
errant spear
#

elements are integrated components in my web app?

mellow sleet
#

I think that's a fair description yep

errant spear
#

that is heavy

#

why do you not just support invoice template with Session Checkouts?

mellow sleet
#

doesn't it work if you set rendering_options[template] on a Customer and then pass customer:cus_xxx into the CheckoutSession create request?

#

that's what you were talking to my colleague about 2 hours ago

errant spear
#

customer = stripe.Customer.create(
email=customer_email,
name=company_name,
address={
'line1': line1,
'city': city,
'postal_code': postcode,
'country': 'NL'
},
invoice_settings={
"rendering_options":{
"template": "inrtem_1QAR7IAAnLCdGvzVqQHsqJWs"
}
},
preferred_locales= ["nl"]

    )
#

I am doing that

#

but the template is not applied

mellow sleet
#

ok apparently it doesn't work? well if you want a "why" answer it's probably just because templates are extremely new and there hasn't been enough feedback yet to prioritise supporting it in Checkout. Maybe it's on the team's roadmap.

#

templates only launched in September so there's probably still active work and fast-follows. I'll mention the feedback to them. You should open a support ticket too to raise feedback