#vtor-zucher_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/1280967566054920215
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- vtor-zucher_api, 3 hours ago, 23 messages
hi
Hello
We can't re-open tickets. They are closed after a period of inactivity.
If you'll summarize your issue/question then I'm happy to help
That isn't a summary lol
Sounds like you are having issues filtering by Connected Account?
When listing objects?
im trying to retrieve all the money an user made from my marketplace platform
i have like three options
- stripe.balanceTransactions.list
- stripe.transfers.list
- stripe.charges.list
i need to filter the results to get only the amount for the user.
i tried passing either stipe account id or stripe customer id
all three methods retrieve all platforms alltime transactions
You want to list Balance Transactions and use the Stripe Account Header: https://docs.stripe.com/connect/authentication
That will list the Balance Transactions on your Connected Account
i tried this and it didnt worked
Then you did it incorrectly and you should try again
const transactions = await stripe.balanceTransactions.list( { limit: 100 }, // You can specify other filters here { stripeAccount: connectedAccountId } // Pass the connected account ID in the request options );
`const functions = require('firebase-functions');
const stripe = require('stripe')(functions.config().stripe.secret_test);
exports.listArtistBalanceTransactions = functions.https.onCall(async (data, context) => {
try {
// Authenticate request
if (!context.auth) {
throw new functions.https.HttpsError('unauthenticated', 'The function must be called while authenticated.');
}
// Ensure you have the Stripe Connect Account ID
if (!data.stripeAccountId) {
throw new functions.https.HttpsError('failed-precondition', 'The Stripe Connect account ID is required.');
}
const params = {
limit: data.limit || 100, // Default to 100 items, allow passing via function data
};
// List balance transactions for a specific Stripe Connect account
const balanceTransactions = await stripe.balanceTransactions.list({
...params,
stripeAccount: data.stripeAccountId, // Use the `stripeAccount` parameter to specify the connected account
});
return balanceTransactions; // Return the data directly to the client
} catch (error) {
console.error('Failed to list artist balance transactions:', error);
throw new functions.https.HttpsError('internal', 'Internal Server Error');
}
}); `
it doesn't works bro
it retrieves all balancaTransactions
It does work. Have you logged out your variable? Have you hard coded the account ID?
Have you looked at the request in your Dashboard?
What have you actually done to troubleshoot
i have logged my variable
What's the account ID that you are trying to list Balance Transactions for?
Okay yeah I can see plenty of list Balance Transaction requests that do not pass the Stripe Account header in your Dashboard. Like: https://dashboard.stripe.com/test/logs/req_MlU1g7fVDCxXqR
So your code is not running as you believe it is.
Ah, that test account also doesn't have any balance transactions
So even if you do it correctly, you aren't going to get any results
Have you logged into your Dashboard and actually looked at that account?
yeah lol
That is not what I see: https://dashboard.stripe.com/test/connect/accounts/acct_1PqKDB4UOZEkAIgJ/activity
why are we seeing different things for the same acc?
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
That is a Customer
Not a Connected Account
That Customer is on your platform
Not on your Connected Account
So let's pause.
im trying to retrieve all the money an user made from my marketplace platform
Is what you said
To me that means you want to retrieve the total revenue of your Connected Account(s), right?
The screenshot above for cus_QfmMzYrx8cuwCQ is a test Customer on your platform account where you have created Subscriptions
There is no tie to a Connected Account for these
i dont want to retrive all revenue of all connected accounts for me as myself as an admin
im creating a wallet dashboard to retrieve all revenue of my user connect account only
only the money and transactions he earned in my marketplace
Right so you actually have to Transfer funds to your Connected Account for there to be revenue on a Connected Account....
Dropping a bunch of code doesn't help here
my function is passing stripeAccount on headers now and it is still returning allitme all platform balance listings.
You need to pause and actually understand how Connect works
The first thing is to decide on what charge type you are going to use -- you likely want Destination Charges: https://stripe.com/docs/connect/destination-charges
Then you need to actually create test destination charges so there is a balance in your Connected Account
Then you need to list Balance Transactions as we have already discussed
bro, i do transfer
const accountSession = await stripe.checkout.sessions.create({ payment_method_types: ['card'], line_items: lineItems, payment_intent_data: { application_fee_amount: totalPrice*20, transfer_data: { destination: artist.stripeAccountId, }, },
Well then you need to list balance transactions for an account that actually has balance transactions
The one you provided above does not
And you need to debug your own code for why your Stripe Account header isn't getting passed through
Because you aren't making these List Balance Transaction requests on the Connected Account, which means you have a bug in your code
i understand
can you help me ?
const response = await listArtistBalancaTransactions({ limit: 100, stripeAccountId });
`const functions = require('firebase-functions');
const stripe = require('stripe')(functions.config().stripe.secret_test);
exports.listArtistBalanceTransactions = functions.https.onCall(async (data, context) => {
try {
// Authenticate request
if (!context.auth) {
throw new functions.https.HttpsError('unauthenticated', 'The function must be called while authenticated.');
}
// Specify the Stripe account to filter transactions for the connected account
const stripeAccountId = data.stripeAccountId;
const params = {
limit: data.limit || 100, // Default to 100 items, allow passing via function data
};
// Set up the request to list balance transactions for the connected account
const options = {
stripeAccount: stripeAccountId // Pass the connected account ID
};
const balanceTransactions = await stripe.balanceTransactions.list(params, options);
return balanceTransactions; // Return the data directly to the client
} catch (error) {
console.error('Failed to list balance transactions:', error);
throw new functions.https.HttpsError('internal', 'Internal Server Error');
}
});
`
I'd recommend pulling the List Balance Transaction outside your application code and just running it separate as a one-off script until you get it to work
where in stripe dashboard can i check the response result?
You can't see the response for a GET request in your Dashboard. However you can look at https://dashboard.stripe.com/test/logs?method[0]=post&method[1]=delete&direction[0]=connect_in&direction[1]=self and filter for GET requests as well as outbound Connect requests to see if you are properly making the request. Really though you should just log out the response in your code.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
what's annoying me is that im passing stripeAccountId and it's retrieving ALL balance listings
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
on the docs the stripe.balanceTransactions.list doesn't accepts stripe account id param
All endpoints accept the Stripe Account ID as an options object: https://docs.stripe.com/api/connected-accounts
Sure, if you are using our Node SDK then your code should look like:
const balanceTransactions = await stripe.balanceTransactions.list({}, {
stripeAccount: "acct_1PQsYxPZOxSutXrq"
});
console.log(balanceTransactions);
So replace that account ID with your own Connected Account that has balance transactions
And then run that code in an isolated Node environment
Not in your application code
What account ID did you use?
As noted already, if you pass an Account ID without any balance transactions then it will return an empty array
Can you show me the full payload from the log?
how come is this connect acc empty? https://dashboard.stripe.com/test/connect/accounts/acct_1PqKDB4UOZEkAIgJ/activity?tab=actionsRequired
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
it shouldn't be empty
I can't tell you that
from logs
this is server side bro
Please stop calling me "bro"
And okay if you say it is server-side then that's fine. The screenshot above looks like the chrome dev tools to me
its from firebase server side.
Failed to list balance transactions: Error: Stripe: Unknown arguments ([object Object]). Did you mean to pass an options object?
What is the exact code that you are using?
const functions = require('firebase-functions');
const stripe = require('stripe')(functions.config().stripe.secret_test);
exports.listArtistBalanceTransactions = functions.https.onCall(async (data, context) => {
try {
// Authenticate request
if (!context.auth) {
throw new functions.https.HttpsError('unauthenticated', 'The function must be called while authenticated.');
}
console.log('data:', data);
console.log('STRIPE ACCOUNT ID:', data.stripeAccountId);
// Specify the Stripe account to filter transactions for the connected account
const stripeAccountId = data.stripeAccountId;
const params = {
limit: data.limit || 100, // Default to 100 items, allow passing via function data
};
// Set up the request to list balance transactions for the connected account
const options = {
stripeAccount: stripeAccountId // Pass the connected account ID
};
const balanceTransactions = await stripe.balanceTransactions.list(params, options);
return balanceTransactions; // Return the data directly to the client
} catch (error) {
console.error('Failed to list balance transactions:', error);
throw new functions.https.HttpsError('internal', 'Internal Server Error');
}
});
Yeah no you haven't listened to me at all
I asked you to not do this within your application
Just run it in an isolated node environment
I also asked you to use the exact code I provided you above
now i think it is working.
but
it's empty
what is this warning on my connect acc?
I think that is Portuguese but I can't read it. I'd assume you haven't actually onboarded your Connected Account using our test data: https://docs.stripe.com/connect/testing
Yeah I mean the easiest way is to create an Account Link like we show at: https://docs.stripe.com/connect/custom/hosted-onboarding and then enter this test data into the Hosted Onboarding flow in order to onboard the account
This account needs to accept the terms of service. Please register this using the API.
what does this means?
It means you need to go through Hosted Onboarding like I linked above
Okay well you haven't fully completed onboarding if it says you still need to accept ToS
So I'd go through that again for that account. When you complete the last step in the flow it accepts the ToS for you
the process I do:
createConnectAccount
createSessionAccount
createSessionCheckout
checkSessionCheckout
on createConnectAccount:
const account = await stripe.accounts.create({ type: 'custom', country: 'BR', email: data.email, capabilities: { card_payments: { requested: true }, transfers: { requested: true } }, business_type: 'individual', external_account: { object: 'bank_account', country: 'BR', currency: 'brl', account_holder_name: data.account_holder_name, account_holder_type: 'individual', routing_number: data.routing_number, account_number: data.account_number }, });
Did you actually go through the UI and enter the test info when you create the Embedded Components Session?
on createSessionAccount
const accountSession = await stripe.accountSessions.create({ account: data.stripeAccountId, // Ensure correct casing and data key names components: { account_onboarding: { enabled: true, features: { external_account_collection: false, }, }, } });
Okay well as noted above, I'd do that again for this account as it doesn't seem like you finished onboarding it.
on createSessionCheckout
const accountSession = await stripe.checkout.sessions.create({ payment_method_types: ['card'], line_items: lineItems, payment_intent_data: { application_fee_amount: totalPrice*20, transfer_data: { destination: artist.stripeAccountId, }, }, mode: 'payment', return_url: 'http://localhost:3000/checkout?session={CHECKOUT_SESSION_ID}&type=ecomm', ui_mode: 'embedded', // success_url: 'http://localhost:3000/thankyou', // cancel_url: 'https://example.com/cancel', });
on checkSessionCheckout
const accountSession = await stripe.checkout.sessions.retrieve(data.sessionId);
Yeah not sure why you are showing me that code
Your account isn't onboarded
That is why you see that error in your Dashboard
what is missing in my onboarding ?
Sounds like Terms of Service acceptance based on what you said above
Sure