#doki_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/1384499874770190391
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi there!
Hey there! tsym for the quick response!
but for some reason can not differentiate for the exact products data
can you clarify what that means? which API calls are you making, and which exact information can't you differenciate?
of course. I'll share some screenshots so I don't butcher the explanation. All the data is fake and test mode anyway so no privacy issues
"[{"stripe_user_id":"acct_1ROPXqBBASerX4N3","total_revenue_lifetime":"202800","total_purchases_lifetime":7,"product_ids":["prod_SJ1uw9WVkqRX2z","prod_SJ1gh5bPMgp32v"],"repeat_customers":1,"unique_customers":2,"created_at":"2025-06-17 11:43:33.030915","updated_at":"2025-06-17 11:43:33.030915"}]"
just grabbed the json. so essentially all this data is from a test account. the revenue and customer stuff works brilliantly then however when i try take it over and split it into the products
"[{"product_id":"prod_SJ1gh5bPMgp32v","total_revenue_lifetime":"0","total_purchases_lifetime":0,"repeat_customers":0,"unique_customers":0,"created_at":"2025-06-17 11:43:33.72319","updated_at":"2025-06-17 11:43:33.72319","stripe_user_id":"acct_1ROPXqBBASerX4N3","product_name":"Tets1"},{"product_id":"prod_SJ1uw9WVkqRX2z","total_revenue_lifetime":"0","total_purchases_lifetime":0,"repeat_customers":0,"unique_customers":0,"created_at":"2025-06-17 11:43:33.231069","updated_at":"2025-06-17 11:43:33.231069","stripe_user_id":"acct_1ROPXqBBASerX4N3","product_name":"awr323"}]"
the data does not show.
I believe I am missing something painfully obvious or it might be test mode but essentially I think I might be trying to check which product it belongs to incorrectly. As right now its going through every invoice.
I think there must be such an easier approach than per invoice reading but I have yet to actually find something unless I've missed a docs page?
I'm still confused. what is this JSON you are sharing? is this coming from Stripe? if so, which exact API calls are you making?
GET /v1/charges?limit=100
GET /v1/invoices/{invoice_id}
then through the api response from the invoice one im trying to link it to a product id.
I think I just am doing this so wrong as going through every invoice seems a little overkill?
GET /v1/charges?limit=100
GET /v1/invoices/{invoice_id}
Got it.
then through the api response from the invoice one im trying to link it to a product id.
I still don't understand what you are trying to do. can you give a concrete example of what you are trying to "link" with what?
do you want to find the Product ID for each Charge object?
yes. so ive created what I think are test payments. as seen in img 1 for a product. I want to able to get the product id thats on the invoice basically
product id I believe
as that would be easier
but any identifier of what was purchased could work?
a Charge object doesn't contain any information about the Product bought (except the final price). if you want information about the product, then you need to look at the Invoice object, in the lines property: https://docs.stripe.com/api/invoices/object?api-version=2025-05-28.basil&lang=php#invoice_object-lines
i think i might be messing this up. I've gone onto the "https://dashboard.stripe.com/test/invoices" and ive created one for a product on my test account
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
but in my api response im not seeing any invoice
again, can you clarify what your goal is? do you want to know the products associated with a specific Invoice?
if so, jsut retrieve the Invoice with this API, and check the lines property.
https://docs.stripe.com/api/invoices/retrieve?api-version=2025-05-28.basil
why are you talking about Charges? Charges should be irelevant here.
when i do this. my lines.data array is empty .
so i cannot see the product data in that part of the response
I am doing this right now
I want the product id from a specific invoice yes
when i do this. my lines.data array is empty .
can you share the Invoice ID with this issue (in_xxx)?
in_1ROi88BBASerX4N3flTMWGvN
this invoice does have lines. can you share the code you are using to retrive the invoice and check the lines property?
yeah of course
const stripe = require('stripe')('sk_test_...');
async function getInvoiceLines(invoiceId) {
const invoice = await stripe.invoices.retrieve(invoiceId);
const lines = await stripe.invoices.listLineItems(invoiceId);
for (const line of lines.data) {
console.log('Line item:');
console.log(' Description:', line.description);
if (line.price) {
console.log(' Price ID:', line.price.id);
console.log(' Product ID:', line.price.product);
console.log(' Unit amount:', line.price.unit_amount);
}
console.log(' Quantity:', line.quantity);
console.log(' Amount:', line.amount);
}
}
can you add a console.log(invoice.lines) and share the output?
Charge has no invoice: ch_3ROhtGBBASerX4N30GH1x6Dg {
id: 'ch_3ROhtGBBASerX4N30GH1x6Dg',
object: 'charge',
amount: 2000,
amount_captured: 2000,
amount_refunded: 0,
application: null,
application_fee: null,
application_fee_amount: null,
balance_transaction: 'txn_3ROhtGBBASerX4N30d6dZZus',
billing_details: {
address: {
city: null,
country: null,
line1: null,
line2: null,
postal_code: null,
state: null
},
email: null,
name: null,
phone: null,
tax_id: null
},
but why are you sharing a Charge object? I really don't understand.
You need to do something like this:
// check the Invoice ID, it should look like `in_xxx`
console.log(invoiceID);
// retrieve the Invoice
const invoice = await stripe.invoices.retrieve(invoiceId);
// print the items of the invoice
console.log(invoice.lines);
as you see, Charges are completely unrelated to this.
okay thank you let me just apply that and ill get back to you in a moment
omg wow that actually fixed it omg
that was all my fault yes thank you
I was still messing around trying to use charge objects to get the invoices instead of going direct
honestly soma you're a life saver
I've been at this for hours now haha
happy to help ๐