#deathraven_api

1 messages ¡ Page 1 of 1 (latest)

brazen apexBOT
#

👋 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/1479192903309070510

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

nimble laurel
#

basically i wanted to add a minimum balance to avoid the 2 dollars per account fee for sellers that havent met the sell limit

for (const user of users.data) {
try {
const balanceSettings = await stripe.balanceSettings.update(
{
payments: {
payouts: {
schedule: {
interval: "monthly",
monthly_payout_days: [5, 20],
},
"minimum_balance_by_currency": {
"usd": 10000,
},
},
},
},
{
stripeAccount: user.stripe_account,
},
);
} catch (e) {
console.error(e);
return useJsonResponse({
message: "Error updating balance settings",
error: e.message,
}, 500);
}
}

warm pasture
#

hello! looking at this shortly, gimme just a bit

#

can you share an example request ID (e.g. req_xxxxxx) that resulted in this error?

nimble laurel
#

i would love to

warm pasture
#

can you copy + paste the ID itself here so i don't run the risk of misreading characters?

#

also all of those look like 200s, is there an example 400 / other error?

nimble laurel
#

no you misunderstood me: i dont have any errors in the logs the api just returns it

warm pasture
#

can you share a connected account ID where you tried to make this update? i can try to look up the logs from there

nimble laurel
#

req_OH6GfuwLtIIu5D

#

ok found it via error.requestId

warm pasture
#

the request ID should also be available in the response you get from stripe

#

ok cool

#

i don't think i've seen this specific error before so gimme a bit to dig through our logs + code etc to figure out what causes it

nimble laurel
#

yeah no problem. i will take the chat with me but i wont be able to make changes. my timing sucked there :D

just for reference

import { useJsonResponse } from "../_shared/general/jsonResponse.ts";
import { sendNewPublishEmailToFollowers } from "../_shared/Services/EmailService.ts";
import {
deferedImageOptimisation,
downloadImage,
getPublicUrlForImages,
makeS3SafeFilename,
} from "../_shared/Services/ImageService.ts";
import { useAdminSupabase } from "../_shared/useAdminSupabase.ts";
import Stripe from "npm:stripe";

const STRATO_URL = Deno.env.get("STRATO_SERVER")!;
const stripe = new Stripe(Deno.env.get("STRIPE_API_KEY") as string, {});

Deno.serve(async (req) => {
if (req.method === "OPTIONS") {
return useJsonResponse({ message: "ok" });
}

const users = await useAdminSupabase().from("private_profiles").select("*")
.eq("account_status", "Seller");

if (users.error) {
console.error(users.error.message);
return useJsonResponse({
message: "Error fetching users",
error: users.error.message,
}, 500);
}

for (const user of users.data) {
try {
const balanceSettings = await stripe.balanceSettings.update(
{
payments: {
payouts: {
schedule: {
interval: "monthly",
monthly_payout_days: [5, 20],
},
"minimum_balance_by_currency": {
"usd": 10000,
},
},
},
},
{
stripeAccount: user.stripe_account,
},
);
} catch (e) {
console.log(e.requestId);
console.error(e);
return useJsonResponse({
message: "Error updating balance settings",
error: e.message,
}, 500);
}
}

return useJsonResponse({ message: "Image optimization completed" });
});

this is the hole updater code

warm pasture
#

ok i thiiiink in this case you're getting the error because the account in question only has EUR external accounts... have you tried setting a minimum balance on EUR for that account?

#

looking at the code i think we restrict this to a baseline set of currencies and then those for which the connected account has external accounts, although there are some other restrictions too (the logic is a little complex unfortunately)

nimble laurel
#

I thought so too but: how do I even check that. I tried receiving it first but nothing there

warm pasture
#

how do you check what external accounts the connected account has? (is this your question)

nimble laurel
#

Yes

warm pasture
#

good question, lemme double check

nimble laurel
#

Okay okay last thing: it isn't my tea but the doc for this is extremely weird for the balance object

warm pasture
#

can you explain what you mean and share specific examples?

nimble laurel
#

I mean exactly my problem. You have examples for updating the data but not reference to the error or that This restriction exists

warm pasture
#

but can you share which doc you're referencing?

#

i can take a look at it and provide feedback to our docs team

#

i also think the error you're running into could be a lot better and could tell you exactly what the problem is, so that's some additional feedback i'll provide to the product team

nimble laurel
#

Extra question: why isnt this in the normal API doc?

brazen apexBOT
warm pasture
#

do you mean why don't we describe the error in the API doc?

nimble laurel
#

Here we are in the API docs. When I click on the link I get redirected to the page above

warm pasture
#

sorry i still don't think i understand, what's the problem with the API reference docs linking to the guide?

nimble laurel
#

Cause I am just searching for the object reference

#

I just want to know what I put in there

warm pasture
#

oh you mean it doesn't define the structure of the object in the reference docs, so you have to click through to the guide? is that the issue?

#

if so i can pass that feedback along to our docs team too

nimble laurel
#

Yes

warm pasture
#

ok cool! i'll pass that feedback along too

#

i need to run but my colleague snufkin should be able to help you out with any followup questions you might have