#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/1280902373883248753
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
hey @fast gate
Hello, can you tell me more about what connect charge flow you are using? It sounds like you are making destination charges potentially?
im creating a dashboard with some visualizations to show my user all of his earnings
i first tried stripe.transfers.list
`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.');
}
const params = {
limit: data.limit || 100, // Default to 10 items, allow passing via function data
};
// Optionally, filter by a connected account
if (data.customerId) {
params.customer = data.customerId;
}
// List balance transactions
const balanceTransactions = await stripe.transfers.list(params);
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');
}
});`
then i tried stripe.charges.list
`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.');
}
const params = {
limit: data.limit || 100, // Default to 10 items, allow passing via function data
};
// Optionally, filter by a connected account
if (data.stripeAccountId) {
params.destination = data.stripeAccountId;
}
// List balance transactions
const balanceTransactions = await stripe.charges.list(params);
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');
}
});`
neither worked in filtering . they retrived all transactions for all users
i need to filter either by stripeAccountId (stripe connect id) or customerId (stripe customer id)
I was more asking about how you are charging your users in the first place
https://docs.stripe.com/connect/direct-charges
https://docs.stripe.com/connect/destination-charges
That determines what options you have here
// Create a PaymentIntent with the order amount and currency const paymentIntent = await stripe.paymentIntents.create({ amount: amount, currency: 'brl', payment_method: paymentMethodId, confirmation_method: 'manual', confirm: true, return_url: 'http://localhost:3000/thankyou', });
i think i create a payment intent
Gotcha, sounds like you are using Separate Charges and transfers if you don't have the account ID involved at that point. Can you show me your code for creating transfers as well?
The code that you shared doesn't have anything that would make a transfer automatically
Oh was that code from the doc, not your codebase?
its from my codebase
Gotcha. So transfers will only happen automatically if you set transfer_data.destination on the intent. Your code doesn't show that being set, so it sounds like either you set it later or your integration is creating a transfer via the API when it sees that the intent succeeds