#doki_api

1 messages ยท Page 1 of 1 (latest)

ionic ingotBOT
#

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

jovial radish
#

hi there!

near bobcat
#

Hey there! tsym for the quick response!

jovial radish
#

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?

near bobcat
#

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?

jovial radish
#

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?

near bobcat
#

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?

jovial radish
#

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?

near bobcat
#

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?

jovial radish
near bobcat
#

but in my api response im not seeing any invoice

jovial radish
#

why are you talking about Charges? Charges should be irelevant here.

near bobcat
#

when i do this. my lines.data array is empty .

#

so i cannot see the product data in that part of the response

near bobcat
#

I want the product id from a specific invoice yes

jovial radish
#

when i do this. my lines.data array is empty .
can you share the Invoice ID with this issue (in_xxx)?

near bobcat
#

in_1ROi88BBASerX4N3flTMWGvN

jovial radish
#

this invoice does have lines. can you share the code you are using to retrive the invoice and check the lines property?

near bobcat
#

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);

}
}

jovial radish
#

can you add a console.log(invoice.lines) and share the output?

near bobcat
#

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
},

jovial radish
#

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.

near bobcat
#

okay thank you let me just apply that and ill get back to you in a moment

ionic ingotBOT
near bobcat
#

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

jovial radish
#

happy to help ๐Ÿ™‚