#vtor-zucher_api

1 messages ยท Page 1 of 1 (latest)

lofty cipherBOT
#

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

stoic horizon
#

hi

fiery latch
#

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

stoic horizon
#

ill try

fiery latch
#

That isn't a summary lol

#

Sounds like you are having issues filtering by Connected Account?

#

When listing objects?

stoic horizon
#

im trying to retrieve all the money an user made from my marketplace platform

#

i have like three options

#
  1. stripe.balanceTransactions.list
  2. stripe.transfers.list
  3. 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

fiery latch
#

That will list the Balance Transactions on your Connected Account

stoic horizon
#

what method should i use ?

#

stripe. ?

#

i don't understand

fiery latch
#

And pass the Stripe Account Header as indicated in the doc I shared

stoic horizon
#

i tried this and it didnt worked

fiery latch
#

Then you did it incorrectly and you should try again

stoic horizon
#

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

fiery latch
#

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

stoic horizon
#

i have logged my variable

fiery latch
#

What's the account ID that you are trying to list Balance Transactions for?

stoic horizon
#

acct_1PqKDB4UOZEkAIgJ

#

this one

fiery latch
stoic horizon
#

ok

#

how can i pass the stripe account header

#

?

fiery latch
#

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

stoic horizon
#

what do you mean ? it should have

fiery latch
#

Have you logged into your Dashboard and actually looked at that account?

stoic horizon
#

yeah lol

fiery latch
stoic horizon
#

why are we seeing different things for the same acc?

fiery latch
#

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

stoic horizon
#

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

fiery latch
#

Right so you actually have to Transfer funds to your Connected Account for there to be revenue on a Connected Account....

stoic horizon
#

even this function

fiery latch
#

Dropping a bunch of code doesn't help here

stoic horizon
#

my function is passing stripeAccount on headers now and it is still returning allitme all platform balance listings.

fiery latch
#

You need to pause and actually understand how Connect works

#

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

stoic horizon
#

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

fiery latch
#

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

stoic horizon
#

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

});
`

fiery latch
#

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

stoic horizon
#

where in stripe dashboard can i check the response result?

fiery latch
#

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.

stoic horizon
#

what's annoying me is that im passing stripeAccountId and it's retrieving ALL balance listings

#

on the docs the stripe.balanceTransactions.list doesn't accepts stripe account id param

fiery latch
stoic horizon
#

ok

#

can you help me?

#

i can not manage to pass connect acc id on headers

fiery latch
#

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

stoic horizon
#

trying

#

no good bro

#

either retrieves 0 ,

#

or all balances

fiery latch
#

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?

stoic horizon
#

it shouldn't be empty

fiery latch
#

I can't tell you that

stoic horizon
#

from logs

fiery latch
#

These logs are client-side though right?

#

That doesn't look like your terminal

stoic horizon
#

this is server side bro

fiery latch
#

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

stoic horizon
#

its from firebase server side.

fiery latch
#

Gotcha

#

That isn't the full payload though

stoic horizon
#

Failed to list balance transactions: Error: Stripe: Unknown arguments ([object Object]). Did you mean to pass an options object?

fiery latch
#

What is the exact code that you are using?

stoic horizon
#

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

});

fiery latch
#

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

stoic horizon
#

now i think it is working.

#

but

#

it's empty

#

what is this warning on my connect acc?

fiery latch
stoic horizon
#

hmmm

#

this will enable me to enter some fake transaction data to this connect acc?

fiery latch
stoic horizon
#

in your intuition

#

what u think i might could be doing wrong?

fiery latch
#

In terms of onboarding?

#

Have you gone through Hosted Onboarding?

stoic horizon
#

im confused

#

...

fiery latch
stoic horizon
#

This account needs to accept the terms of service. Please register this using the API.

#

what does this means?

fiery latch
#

It means you need to go through Hosted Onboarding like I linked above

stoic horizon
#

i think i already do this

#

i use embedded onboarding instead

fiery latch
#

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

stoic horizon
#

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

fiery latch
#

Did you actually go through the UI and enter the test info when you create the Embedded Components Session?

stoic horizon
#

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

fiery latch
#

Okay well as noted above, I'd do that again for this account as it doesn't seem like you finished onboarding it.

stoic horizon
#

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

fiery latch
#

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

stoic horizon
#

what is missing in my onboarding ?

fiery latch
#

Sounds like Terms of Service acceptance based on what you said above

stoic horizon
#

got it

#

thanks bismarck

fiery latch
#

Sure