#kun_api

1 messages · Page 1 of 1 (latest)

dense tideBOT
#

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

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

desert fiber
#

Hello
I don't believe you need a webhook endpoint to process the transactions.
If you want to automatically transfer funds to the Connected Accounts then you can build Destination Charges flow as described here - https://docs.stripe.com/connect/destination-charges

manic berry
#

can I explain my question in detail again?

desert fiber
#

Sure

manic berry
#

Step 1: Affiliate Onboarding
An affiliate joins your platform and connects their Stripe account using Stripe Onboarding, either by creating a new Stripe account or linking an existing one.

Step 2: User Signup
Users can sign up on your application using the affiliate's unique link.

Step 3: Commission Distribution
When a user signs up with an affiliate's link and subscribes to your application, 10% of each successful invoice payment should be automatically distributed to the affiliate's connected Stripe account.

I have completed the step1 and step2
for the step3 I dont want to rely on webhooks

west hare
#

Gotcha, and what kind of Stripe dashboard access do your connected accounts have? Full dashboard, express dashboard, or no dashboard? Our subscriptions support splitting payments automatically like that, but specifically how can differ based on your setup

manic berry
#

I am using these methods for affiliates strip onboarding

stripe.accounts.create
stripe.accountLinks.create

west hare
#

Can you show me your code for the accounts.create call?

#

As in the snippet for making the call itself? I am specifically interested in what you are passing in as the account's type or for its controller options

manic berry
#

if (!accountId) {
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' },
});

  accountId = account.id;

  // Persist account id
  await supabase
    .from('affiliates')
    .update({ stripe_account_id: accountId })
    .eq('user_id', userId);
}

/* 5️⃣  Generate Stripe-hosted onboarding link */
const baseUrl = VALITRON_APPLICATION_URL.replace(/\/$/, '');
const accountLink = await stripe.accountLinks.create({
  account: accountId,
  refresh_url: `${baseUrl}/affiliate/dashboard?stripe=refresh`,
  return_url: `${baseUrl}/affiliate/dashboard?stripe=return`,
  type: 'account_onboarding',
});
west hare
manic berry
#

So it mean I am using the correct method for onboarding

and in step3: when normal user subscribe to my application subscriotion plan I need to add these
transfer_data: {
destination: '{{CONNECTED_ACCOUNT_ID}}',
},

this is my original snippet for creating subscription
const subParams: Stripe.Checkout.SessionCreateParams | any = {
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' },
};
if (customerId) subParams.customer = customerId;
session = await stripe.checkout.sessions.create(subParams);

west hare
#

Yep, transfer_data is how you specify the amount and account to send funds to. The code snippet in that doc should also show application_fee_percent which is how you specify how much to send to the connected account.
https://docs.stripe.com/api/subscriptions/object#subscription_object-application_fee_percent

manic berry
#

can you tell me what other types i can have in stripe onboarding flow?
right now I am using type:"express"

west hare
#

The parameter is part of that transfer_data param

    destination: '{{CONNECTED_ACCOUNT_ID}}',
    application_fee_percent: 5,
  },```
#

And yes, after you set that, any successful payment from that subscription will send that percent of the payment to the connected account automatically.

manic berry
#

Got it

#

const account = await stripe.accounts.create({
type: 'express',
email: userEmail,
business_type: 'individual',
capabilities: {
card_payments: { requested: true },
transfers: { requested: true },
},

what are other options for type here

can i have a details on it

west hare
manic berry
#

Got it You have guided me excatly what I am looking for

#

God Bless you