#kun_api

1 messages · Page 1 of 1 (latest)

tulip anchorBOT
#

đź‘‹ 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/1405973543275200552

📝 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.

sand zodiac
#

hi! i'm working on a few threads but i'll get back to you asap

#

it looks like your question got cut off, can you share the rest of it here?

karmic light
#

sure

#

I’m integrating Stripe subscriptions with Connect (Express accounts) for an affiliate system.

First, I create a connected account with this configuration:

const account = await stripe.accounts.create({
  type: 'express',
  email: userEmail,
  business_type: 'individual',
  capabilities: {
    card_payments: { requested: true },
    transfers: { requested: true },
  },
  metadata: {
    supabaseUserId: userId,
    role: 'affiliate',
    affiliateCommissionPercentage: '10%',
    transferFormula: 'Affiliate commission percentage applied to all successful recruiter payments',
  },
});

Later, when a recruiter gets a subscription, I try to send a percentage of the payment to the affiliate’s connected account:

const subParams = {
  mode: 'subscription',
  line_items: [
    { price: process.env.VALITRON_SUBSCRIPTION_PRICE_ID, quantity: 1 },
    { price: process.env.VALITRON_OVERAGE_PRICE_ID },
  ],
  success_url: `${process.env.VALITRON_APPLICATION_URL}/recruiter/credits/success?session_id={CHECKOUT_SESSION_ID}`,
  cancel_url: `${process.env.VALITRON_APPLICATION_URL}/recruiter/credits/cancel`,
  metadata: recruiterEmail
    ? { recruiter_email: recruiterEmail, plan: 'SUB' }
    : { plan: 'SUB' },
};

const affiliate = await fetchAffiliatePayoutByUserId(referred_by_affiliate_id);
if (affiliate?.destination) {
  subParams.subscription_data = {
    ...(subParams.subscription_data ?? {}),
    transfer_data: { destination: affiliate.destination },
    application_fee_percent: affiliate.feePercent, // e.g., 10
  };
}

The issue: When the subscription’s invoice is successfully paid, the entire payment goes to the destination (affiliate’s connected account). I expected only the application_fee_percent (e.g., 10%) to go there, with the rest staying on the platform account.

How can I configure the subscription so that only the specified percentage is transferred to the destination account, and the remainder stays with the platform?

#

any help?

sand zodiac
#

hi! sorry, as i mentioned earlier i'm juggling a few issues at the moment and my responses might be delayed

karmic light
#

sure ill wait

#

is it posisble you can switch this chat to other assistant

sand zodiac
#

not currently. i have read through your question though and i think i know what the issue is

karmic light
#

sure ill wait for your response

sand zodiac
#

the application fee is the amount that is kept by the platform account, so what you're describing is the expected behavior

karmic light
#

I wanted that 10% should go to connected account and 90% stays in platform

sand zodiac
#

can you share an example subscription ID you've created like this so i can double check some things?

karmic light
#

sure

#

you wanted code snippet of stripe siubscription

sand zodiac
#

no, the actual ID of the subscription you've created

#

it looks like this: sub_[random characters]

karmic light
#

sure

#

si_SrooToT7E1KoxL

sand zodiac
#

the short answer though is that you want to set application_fee_percent to 90% if you want to keep 90% of the payment in the platform's balance

karmic light
#

by the way I am working on stripe test enviorment

#

ohhh i got it now

#

transfer_data: { destination: affiliate.destination },
application_fee_percent: affiliate.feePercent, (this should be 90)
then automatically 10 % will go to destionation account?

sand zodiac
#

ok yep, it looks like for the invoice in_1Rw73CFrwl37tCGiUJi4NTSD you have amount set to $50.00 and the application fee set to $5.00. so the application fee is working correctly, you were just thinking it did the opposite of what it does

#

yep!

karmic light
#

the connected account gets $50.00

and my platform gets nothing

sand zodiac
#

double checking some things

#

so everything looks like it's working to me (aside from the fact that you need to swap the application_fee_percent to 90)

karmic light
#

please look at this

#

there is no $50.00 transction i can see

#

even my connected account gets total 50 usd

sand zodiac
#

when you create a destination charge with application_fee_percent and with this connect account configuration, what happens is:

  1. we collect the $50 payment
  2. we charge the platform account the stripe transaction fee
  3. we transfer the full amount of the payment to the connect account
  4. we transfer the application fee back to the platform account
karmic light
#

so that is why I in connceted account I see the full value transaction

but when I see the the details of transaction 10 % recieved by the connected accoout?

sand zodiac
#

so that is why I in connceted account I see the full value transaction
yes!

but when I see the the details of transaction 10 % recieved by the connected accoout?
i'm not sure i understand what you mean by this? the 10% in this case is received by your platform account

tulip anchorBOT
karmic light
#

when you create a subscription with transfer_data.destination set to the affiliate's connected account and also set application_fee_percent, the entire payment (100%) is being routed to the connected account instead of only the application_fee_percent going there with the remainder staying in your platform account.

is it true?

sand zodiac
#

yes, as i mentioned above, 100% of the funds are transferred to the destination account, and the application fee is transferred back to the platform

karmic light
#

got it man

#

last thing sho I should make application_fee_precentage to 90 so that my platform gets 90% of what transfered to connected account?

sand zodiac
#

yep!

karmic light
#

No i got it

#

a last quick question
before that the percentage value wa 10

then how my platform gets 90% instead it should get 10%

we saw it in transaction history

sand zodiac
#

your platform got the $5 fee, which is expected since you set the application fee to 10%