#outfitxr-support_api
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/1296017897964965948
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi
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?
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?
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
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'
}
)
You should assign the ID to this Customer's property: https://docs.stripe.com/api/customers/create#create_customer-invoice_settings-rendering_options-template
I think it's based on the locales of the Customer: https://docs.stripe.com/api/customers/update#update_customer-preferred_locales
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.
Could you please share the Invoice ID generated via API?
You can try applying the ID directly to the Invoice: https://docs.stripe.com/api/invoices/create#create_invoice-rendering-template
in_1QASKZAAnLCdGvzV350W2h9c
but I am not creating an invoice directly this is done by the checkout session.
Still looking...
I see that the Invoice was created ~15 min ago, but Customer was updated <10 min ago. Could you try this again?
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
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.
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)
You can create a Checkout Session in mode=setup to collect the PaymentMethod and then use it to create a Subscription on the backend.
I do not create subscription, this is one-off payment.
๐ taking over for my colleague. Let me catch up.
Understood
I think you can just create invoices with collection_method: send_invoice which is more suited in your case then creating Checkout Sessions
but how do I create a payment link then?
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
no that will not work in our use case
you can also use the pay link that was generated as well
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.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
do you mean I do not need to do this "session = stripe.checkout.Session.create(" and just create an invoice?
no
I mean you create the invoice in the API https://docs.stripe.com/invoicing/integration
and then you return the hosted_invoice_url
to your frontend
and redirect the customer to that page
you can see how this would look like here https://docs.stripe.com/invoicing/quickstart-guide
when they click on Pay this invoice, it will ask for their payment method
interesting
Ok
Let me test it
I am not getting the hosted_invoice_url instantly?
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
not there, because that's a $0 invoice so there's nothing to pay
your code seems to be using an old approach for old API versions where you'd create the invoice item first. If you're using an newer API version that code will give you an empty Invoice. Use https://docs.stripe.com/invoicing/integration#create-invoice-code instead where you create an Invoice first.
now
generating invoice now
ok
the template is used
why is the branding logo not applied to the invoice?
what's the invoice ID
in_1QAU55AAnLCdGvzVbnlnMicC
what logo are you referring to? I looked at your settings and you don't seem to have a logo in your branding. https://dashboard.stripe.com/test/settings/branding
I cannot press save button?
are you the admin/owner of the account?
yes
I've uploaded logo but I cannot press save button
I can save in production but I cannot save in test env
yeah I think that's normal, there's no such thing as testmode-specific settings, they're shared
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
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?
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
for hosted invoice page, no.
then we have a problem
we need to have a flow
- user submits form
- user pays
- user is redirected after payment.
then consider doing the payment a different way like via Elements (https://docs.stripe.com/invoicing/integration?method=elements#accept-invoice-payment) if that's a hard requirement
elements are integrated components in my web app?
I think that's a fair description yep
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
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
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