#akshatg_code

1 messages ยท Page 1 of 1 (latest)

pine pastureBOT
#

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

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

crude totem
#

Hii

spare phoenix
#

Hello there

crude totem
#

Here's my code:

const updateAccountData = {
business_profile: {
mcc: data?.business_profile?.mcc,
url: 'https://www.placeholder.com', //dummy placeholder,
support_phone:data?.individual?.phone
},
individual: {
first_name: data?.individual?.firstName,
last_name: data?.individual?.lastName,
email: data?.individual?.email,
phone: data?.individual?.phone,
dob: {
day: data?.individual?.dob?.day,
month: data?.individual?.dob?.month,
year: data?.individual?.dob?.year,
},
address: {
line1: data?.individual?.address?.line1,
city: data?.individual?.address?.city,
postal_code: data?.individual?.address?.postalCode,
country: 'LV',
},
verification: {
document: { front: fileUpload?.id }
}
},
capabilities: {
transfers: { requested: true },
},
};

account = await stripe.accounts.update(stripeMerchantAccountId, updateAccountData);

const bankAccount = await stripe.accountLinks.create({
    account: stripeMerchantAccountId,
    refresh_url: stripe_refresh_url_staging, // URL for user to retry onboarding
    return_url: stripe_return_url_staging,  // URL to redirect after onboarding
    type: 'account_onboarding',
    collect: 'eventually_due',
  });

When i get the onboarding link it still take me to the screen where i had to add the phone and email again whyyy??

spare phoenix
#

Yeah that's not how Express Accounts work

#

With Express Accounts the user creates their own login, based on email/phone.

#

This isn't data that you access or preset as the platform

#

If you want that level of control you would use Custom Accounts and you would generate your own Dashboard for the user.

crude totem
#

Hii i am still confused can i elaborate more

spare phoenix
#

Sure

crude totem
#

Thanks alot bismark for your patience let me share you the scene

spare phoenix
#

That doesn't share any new information. You can't prefill email/phone for an Express Account.

#

That information is specific to the user and is their login information.

#

You don't handle that part for them.

crude totem
#

Okay Okay fine. SO it's a non -skippable mandatory part

spare phoenix
#

Yes

crude totem
#

And Please confirm the flow i am doing is right because in future i have to recieve payouts also

spare phoenix
#

I'm not sure what you mean by that?

#

If your Connected Account is fully onboarded and has an external account then yes they are set up for payouts

crude totem
#

Okay so what is connected account actually means ?

async createOne(data = null) {
try {
console.log("UsersResource@createOne");
if (!data || data === "") {
throw new Error("data_required");
}
if (!data.location) {
data.location = null;
}
const customer = data.email ? await stripe.customers.create({ email: data.email }) : await stripe.customers.create({});

if (data.role === 'driver' || data.role === 'company') {
const businessType = data.role === 'company' ? 'company' : 'individual';

    const account = await stripe.accounts.create({
      type: 'express',
      country: data?.countryFlag || 'LV',
      capabilities: {
        card_payments: { requested: true },
        transfers: { requested: true },
        sepa_debit_payments: { requested: true },
      },
      business_type: businessType,
      settings: {
        payouts: {
          schedule: {
            interval: 'daily'
          },
          statement_descriptor: 'PAYOUT'   //support for diffrent payoutt currencies
        }
      },
    });

    if (account) {
      data.stripeMerchantAccountId = account?.id;
    }
  } 

  let user = await User.create(data);

} catch (err) {
Error.payload = err.errors ? err.errors : err.message;
throw new Error(err.message);
}


?

spare phoenix
#

I'm sorry I don't understand your question.

crude totem
#

I mean to say what connected account means?

Below in the code:

async createOne(data = null) {
try {
console.log("UsersResource@createOne");
if (!data || data === "") {
throw new Error("data_required");
}
if (!data.location) {
data.location = null;
}
const customer = data.email ? await stripe.customers.create({ email: data.email }) : await stripe.customers.create({});

if (data.role === 'driver' || data.role === 'company') {
const businessType = data.role === 'company' ? 'company' : 'individual';

    const account = await stripe.accounts.create({
      type: 'express',
      country: data?.countryFlag || 'LV',
      capabilities: {
        card_payments: { requested: true },
        transfers: { requested: true },
        sepa_debit_payments: { requested: true },
      },
      business_type: businessType,
      settings: {
        payouts: {
          schedule: {
            interval: 'daily'
          },
          statement_descriptor: 'PAYOUT'   //support for diffrent payoutt currencies
        }
      },
    });

    if (account) {
      data.stripeMerchantAccountId = account?.id;
    }
  } 

  let user = await User.create(data);

} catch (err) {
Error.payload = err.errors ? err.errors : err.message;
throw new Error(err.message);
}

spare phoenix
crude totem
#

Okay fine

SO - const customer = data.email ? await stripe.customers.create({ email: data.email }) : await stripe.customers.create({});
This is the customer account just normal

And this-
const account = await stripe.accounts.create({
type: 'express',
country: data?.countryFlag || 'LV',
capabilities: {
card_payments: { requested: true },
transfers: { requested: true },
sepa_debit_payments: { requested: true },
},
business_type: businessType,
settings: {
payouts: {
schedule: {
interval: 'daily'
},
statement_descriptor: 'PAYOUT'
}
},
});

Is the connected account??

RIght

spare phoenix
#

Yes

crude totem
#

So is it necessary to create this- const customer = data.email ? await stripe.customers.create({ email: data.email }) : await stripe.customers.create({});

before creating connect account

spare phoenix
#

No

#

The Customer object is used to collect payments

#

The Connected Account is used to receive those payments (or transfers from your platform) and then payout.

#

You would onboard the Connected Account first.

#

Then you would create Customers when you collect payments for that Connected Account

crude totem
#

Okayyy got thattt

#

And let me now i created connect account:
then i do for payouts is-

const balance = await this.getBalance();
const availableBalance = balance?.availableBalance?.amount; //available balance of platform account(whose stripe keys i am using)

async getBalance() {
try {
const balance = await stripe.balance.retrieve();

        const availableBalance = balance.available.find(b => b.currency === 'eur');
        const pendingBalance = balance.pending.find(b => b.currency === 'eur');

        return {
            availableBalance,
            pendingBalance,
        };
    } catch (error) {
        console.error('Error retrieving balance:', error);
        throw error;
    }
}

Then i do:

transfer = await stripe.transfers.create(
{
amount: Math.round(earningAmount * 100), // Convert to cents
currency: 'eur',
destination: stripeMerchantAccountId, // driver's connected account id
transfer_group: DRIVER_PAYOUT_${Date.now()},
}
);

Then initiate payout to the bank

const payout = await stripe.payouts.create({
amount: earningAmount * 100, // amount in cents
currency: 'eur',
method: 'standard',
}, {
stripeAccount: stripeMerchantAccountId, // driver's connected account id
});

Is this right flow of payouts i am following ?

spare phoenix
#

Overall that's fine -- you could also just use automatic payouts so all you would need to do is transfer funds to the Connected Account and they would be automatically paid out at the next earliest time.

crude totem
#

So you mean to say as i am doing

  1. creating connect account
  2. creating transfers to connected account
  3. initiating payouts to bank.

So the way you taught will be -

#
  1. creating connect account
  2. Automated payouts

Right?

spare phoenix
#
  1. Create Connected Accunt
  2. Transfer funds to Connected Account after a payment
#

Then the payout would happen automatically.

crude totem
#

SO could you please help me with the code?

Below is my current code-

I created connect account:
then i do for payouts is-

const balance = await this.getBalance();
const availableBalance = balance?.availableBalance?.amount; //available balance of platform account(whose stripe keys i am using)

async getBalance() {
try {
const balance = await stripe.balance.retrieve();

        const availableBalance = balance.available.find(b => b.currency === 'eur');
        const pendingBalance = balance.pending.find(b => b.currency === 'eur');

        return {
            availableBalance,
            pendingBalance,
        };
    } catch (error) {
        console.error('Error retrieving balance:', error);
        throw error;
    }
}

Then i do:

transfer = await stripe.transfers.create(
{
amount: Math.round(earningAmount * 100), // Convert to cents
currency: 'eur',
destination: stripeMerchantAccountId, // driver's connected account id
transfer_group: DRIVER_PAYOUT_${Date.now()},
}
);

Then initiate payout to the bank

const payout = await stripe.payouts.create({
amount: earningAmount * 100, // amount in cents
currency: 'eur',
method: 'standard',
}, {
stripeAccount: stripeMerchantAccountId, // driver's connected account id
});

spare phoenix
crude totem
#

Okayyyy Thankkk you so muchhhh.

#

ALso let me know now as i am creating the same connected express for company too so how could i make payouts via company connected account to my driver connected account

spare phoenix
#

Not exactly sure what you mean by that?

crude totem
spare phoenix
#

Dropping in a bunch of code doesn't help

#

I need you to explain what you are trying to do and what you are confused about

#

Transfers move money to your Connected Account, which I assume are your drivers?

#

So you are paying them out here already?

#

So overall I don't understand your question

crude totem
#

I am paying them using platform account( whose stripe keys i am using).
like this-

transfer = await stripe.transfers.create(
{
amount: Math.round(earningAmount * 100), // Convert to cents
currency: 'eur',
destination: stripeMerchantAccountId, // driver's connected account id
transfer_group: DRIVER_PAYOUT_${Date.now()},
}
);

then
await stripe.payouts.create({
amount: earningAmount * 100, // amount in cents
currency: 'eur',
method: 'standard',
}, {
stripeAccount: stripeMerchantAccountId, // driver's connected account id
});

But now i want it should be paid by an other connected account.

spare phoenix
#

What does "paid by an other connected account" mean?

crude totem
#

While doing signup i am creating the role base account either company or driver.

if (data.role === 'driver' data.role === 'company') {
const businessType = data.role === 'company' ? 'company' : 'individual';

    const account = await stripe.accounts.create({
      type: 'express',
      country: data?.countryFlag || 'LV',
      capabilities: {
        card_payments: { requested: true },
        transfers: { requested: true },
        sepa_debit_payments: { requested: true },
      },
      business_type: businessType,
      settings: {
        payouts: {
          schedule: {
            interval: 'daily'
          },
          statement_descriptor: 'PAYOUT'   //support for diffrent payoutt currencies
        }
      },
    });

    if (account) {
      data.stripeMerchantAccountId = account?.id;
    }
  } 

As you can see both are connected account i want i now instead of platform account ( whose stripe keys i am using).-
await stripe.transfers.create(
{
amount: Math.round(earningAmount * 100), // Convert to cents
currency: 'eur',
destination: stripeMerchantAccountId, // driver's connected account id
transfer_group: DRIVERPAYOUT${Date.now()},
}
);

I could make payout from this company connected account to my driver.

spare phoenix
#

You are asking if you can move funds from one Connected Account to another?

crude totem
#

YES

spare phoenix
#

Gotcha, that's not possible.

#

You can only move funds from your platform to a Connected Account

#

You can't move funds directly between your Connected Accounts.

crude totem
#

Okay Thanks alot mate it really helped me alot.

I just have a last thing then no more disturbing

#

May I

#

As i am doing

First- creating connect account
const account = await stripe.accounts.create({
type: 'express',
country: data?.countryFlag || 'LV',
capabilities: {
card_payments: { requested: true },
transfers: { requested: true },
sepa_debit_payments: { requested: true },
},
business_type: businessType,
settings: {
payouts: {
schedule: {
interval: 'daily'
},
statement_descriptor: 'PAYOUT' //support for diffrent payoutt currencies
}
},
});

Second- creating transfers to connected account
Then i do:
transfer = await stripe.transfers.create(
{
amount: Math.round(earningAmount * 100), // Convert to cents
currency: 'eur',
destination: stripeMerchantAccountId, // driver's connected account id
transfer_group: DRIVER_PAYOUT_${Date.now()},
}
);

Third- initiating payouts to bank.
const payout = await stripe.payouts.create({
amount: earningAmount * 100, // amount in cents
currency: 'eur',
method: 'standard',
}, {
stripeAccount: stripeMerchantAccountId, // driver's connected account id
});

And you said-

First - creating connect account
Second- Automated payouts

What i have to change in my code.

spare phoenix
#

You just remove the:

Third- initiating payouts to bank.
const payout = await stripe.payouts.create({
            amount: earningAmount * 100, // amount in cents
            currency: 'eur',
            method: 'standard', 
        }, {
            stripeAccount: stripeMerchantAccountId, // driver's connected account id
        });
#

That part will happen automatically now

crude totem
#

Okay FInee

So i need to remove the Third part
And just add this object while creating connect account- settings: {
payouts: {
schedule: {
interval: 'daily',
},
},
},

spare phoenix
#

Yes if you want to use automatic payouts