#guimatos_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/1357455055959232765
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
{
"totalTransacted": {
"booking": 0,
"fastLinks": 0,
"overall": 31562
},
"totalNet": 25312,
"transactions": [
{
"id": "txn_1R9qSX5B9DbZrfIWuMmxUNWQ",
"type": "payment",
"gross": 6562,
"fee": 0,
"net": 6562,
"created": 1743697061,
"description": null
},
{
"id": "txn_1R9aib5B9DbZrfIWV6zBvMHH",
"type": "payment",
"gross": 25000,
"fee": 6250,
"net": 18750,
"created": 1743636552,
"description": null
}
]
}
.region("southamerica-east1")
.https.onCall(async (data, context) => {
// Retrieve the connected account ID from the input data.
const { stripeAccountId } = data;
if (!stripeAccountId) {
throw new functions.https.HttpsError(
"invalid-argument",
"Connected account stripeAccountId is required."
);
}
try {
// List balance transactions for the connected account.
// This returns the full ledger of money movements.
const balanceTransactions = await stripe.balanceTransactions.list(
{ limit: 100 },
{ stripeAccount: stripeAccountId }
);
// Initialize totals.
let bookingTotal = 0;
let fastLinksTotal = 0;
let overallTotal = 0;
let totalNet = 0;
const transactions = [];
// Process each balance transaction.
balanceTransactions.data.forEach((transaction) => {
overallTotal += transaction.amount;
totalNet += transaction.net;
transactions.push({
id: transaction.id,
type,
gross: transaction.amount, // Amount in centavos
fee: transaction.fee, // Fee deducted by Stripe
net: transaction.net, // Net amount after fees
created: transaction.created, // Unix timestamp
description: transaction.description,
});
});
// Return the compiled summary.
return {
totalTransacted: {
booking: bookingTotal, // Total from booking transactions (transfers)
fastLinks: fastLinksTotal, // Total from fast link transactions (charges)
overall: overallTotal, // Overall total transacted
},
totalNet, // Overall net amount after fees
transactions, // Detailed list of transactions
};
}
});
Hi there! looking
Want I'm trying to create is a function that return the gross of transaction for a specific account.
In the image, the first row is of a transfer. The charge source amount was 100.
The second, is a charge directly to this account through a payment link (250).
So the gross amount is 350, but using balance api I just get 315,62
How to get the gross values ?
So your overall goal is to understand balance activity, is that right?
yes!
Have you looked at our Balance Transaction Reports? https://docs.stripe.com/reports/balance
Yes, I'm using the balance api as in the code above
The Balance Transactions API isn't the same as the Reports API
But, in the case of transfers with source_transaction, the amount is the net. What I'm trying it's to get the amount of the transaction
this is my page
i need to understand the best way to get the gross value of a specific transaction in balance/transactions, that was listed due to a transfer
Could you pass over the id of the transaction in the screenshot?
The original PaymentIntent would be great (pi_abc123)
You can ignore that - I found some examples.
Okay, so issue is, when you create Separate Charges & Transfers and then retrieve the balance transaction on the platform, you only get the amount that wasn't transfered?
In which case I think you want to use the type filter when listing balance transactions - you want Balance Transactions where type="charge"
And that's on the platform - none of the payment objects exist on the Connected Account when using Destination Charges or Separate Charges & Transfers. Your Checkout Sessions, PaymentIntents, & Charges exist only on the platform so to understand transaction activity you kind of have to do it at the platform level because the connected accounts don't "know" about the original Payment
sorry for delay, @wary imp
there's a more performer solution ?
using metadata it's a better option instead?
The problem is that the request to create the transfer is also on the platform and I don't think the destination payment will inherit that metadata
You'd have to do something like making a request on the Connected account to update the destination payment with metadata about the charge on the platform