#davidstanton_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/1334858572097523762
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
I don't really think that's possible with Checkout today unfortunately. You can't pass metadata to the sub/invoice to display on PDFs etc
not even with a invoice template? seems like that is actual what "invoice templates" are for. i'm tried setting custom field, no go, tried setting metadata, no go
Yes if you create a Customer object ahead of Checkout and assign the template to the customer (and use it with Checkout)
I think that will work
But you can't create them programmatically so manual work :/
but how you set the custom_field?
i got it working with metadata on the payments:Description
Adysis Floors for Prebid - Monthly, Domain for this subscription is: wethere.com but juts not invoices, which just dont make sense, it should flow throw from one to the other
this dont work: body: new URLSearchParams({
'invoice_settings[rendering_options][template]': TEMPLATE_ID, // Replace with your template ID
'invoice_settings[custom_fields][0][name]': 'Domain',
'invoice_settings[custom_fields][0][value]': domain,
}),
On which API/object?
if (event.type === 'customer.subscription.created') {
i get a success, but its a NO SHOW in invoices etc:const domain = subscription.metadata.domain;
// โ
Assign Invoice Template to Customer
await fetch(`https://api.stripe.com/v1/customers/${customerId}`, {
method: 'POST',
headers: {
Authorization: `Bearer ${STRIPE_SECRET_KEY}`,
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({
'invoice_settings[rendering_options][template]': TEMPLATE_ID, // Replace with your template ID
'invoice_settings[custom_fields][0][name]': 'Domain',
'invoice_settings[custom_fields][0][value]': domain,
}),
});
console.log(`Customer ${customerId} updated with invoice template and custom field: Domain = ${domain}`);
return new Response(JSON.stringify({ message: "Customer updated with invoice template and custom field." }), { status: 200 });
Well yes because at that point the initial invoice has created so setting the invoice settings will only apply to future invoices
Like I said, you want to create the Customer object before the Checkout Session, pass the cus_xxx ID to customer param. Then the invoices should inherit whatever invoice settings you set
{
"id":
"cus_RgflfP7LEFPcUc"
,
"object":
"customer",
"address":
null,
"balance":
0,
"created":
1738322997
,
"currency":
"usd",
"default_source":
null,
"delinquent":
false,
"description":
null,
"discount":
null,
"email":
"davidstanton@spormeon.com",
"invoice_prefix":
"2889B91B",
"invoice_settings": {
"custom_fields": [
"0": {
"name":
"Domain",
"value":
"wethere.com",
},
],
"default_payment_method":
null,
"footer":
null,
"rendering_options": {
"amount_tax_display":
null,
"template":
"inrtem_1QnFufE7dsAdGvZeM3N25ss0",
},
},
"livemode":
false,
"metadata": {},
"name":
null,
"phone":
null,
"preferred_locales": [],
"shipping":
null,
"tax_exempt":
"none",
"test_clock":
null,
}
Request POST body
{
"invoice_settings": {
"custom_fields": {
"0": {
"name":
"Domain",
"value":
"wethere.com",
},
},
"rendering_options": {
"template":
"inrtem_1QnFufE7dsAdGvZeM3N25ss0",
},
},
}
Not sure what you're showing me here? You didn't set the invoice fields on creation: https://dashboard.stripe.com/test/logs/req_i7xOQ0skTSFS7Q
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
right ok, i think i see, its seems to be after /v1/checkout/sessions
They were set in an update (https://dashboard.stripe.com/test/logs/req_fgmP8p27L4mDZf) after the subscription/invoice was generated
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
โ๏ธ
still not liking it, im getting it there now, before /checkout/sessions but its not showing on invoices, it shows the custom_field that has been setup in the actual invoice template
Yes, the template takes precedence: https://docs.stripe.com/invoicing/invoice-rendering-template#override-and-update-templates
ye, but we are setting the custom_fields in the api now, dont it "override" the ones set in the template?, i they need to be deleted out the template?
Yes, the custom fields on the template take precedence over the invoice settings on the customer. See 3 and 4
so, just delete the custom field out the tempalte?
Sure, I guess. Whatever gives you the extensibility you need
yay at last!, cheers for the help
how about getting it to here, possible? tried numerious things again, and got zip
I guess it's the description of the Invoice? So you could modify it to add the URL.
na, tried that
Could you please share this Invoice ID?
in_1QnKNZE7dsAdGvZerfFCcLu4
it sets on the payment , just cant get it to add it to the end of the subscription description
also tried setting a 0 price line item, with "Domain this subscription relates to: blar.com", didn't work
I see you updated the description on the PaymentIntent - "Adysis Floors for Prebid - Monthly, Domain for this subscription is: get.com". I suspect it didn't help?
ye, never showed in custome portal, i treied loads of things
best log i got on one was "cant update finaziled invoice" or something like that
Which request was that?
no clue there been so many now
this is one:POST
/v1/invoices/in_1Qn59ME7dsAdGvZeCPrDVpk9
Request ID
HTTP status code
400
Time
30 Jan 2025, 22:20:47
IP address
108.162.245.212
API version
2024-12-18.acacia
Default
Idempotency key
7accc685-d862-4cf9-ae49-1ff661b26b30
User agent
No user agent information
API key
Error insight
Finalized invoices can't be updated in this way
Was this useful?
Yes
No
Response body
{
"error": {
"message":
"Finalized invoices can't be updated in this way",
"param":
"description",
"request_log_url":
"https://dashboard.stripe.com/test/logs/req_0rNmW8xB8XueY9?t=1738275647",
"type":
"invalid_request_error",
},
}
Request POST body
{
"description":
"Subscription domain: N/A",
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
req_0rNmW8xB8XueY9
I suspect you need to set the description before the Invoice is finalized. Have you tried it?
ye sure i did
I don't think there's any other way to update it unfortunately.
here is an eventID where i managed to get the description in there, but it didn't show in the user portal:evt_3Qmyw0E7dsAdGvZe1TvSvmB2
actually sorry, i think thats on the payment, where it does work
๐ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
same question still, as in how can someone get a "extra" dewcription onto the end of a subscription description?
it's possible to update the invoice before it gets finalized https://docs.stripe.com/invoicing/integration/workflow-transitions#finalized