#devertry_api

1 messages · Page 1 of 1 (latest)

simple sluiceBOT
#

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

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

shut furnace
#

its the event you need ?

#

hello alex

valid wigeon
shut furnace
#

req_NiIosPylS5cygE

#

whops

#

its test data so its ok

valid wigeon
#

for context, you're creating a Customer

#

what is undefined specifically?

#

the request is successful, and a Customer is successfully created

shut furnace
#

yes but doestn return me it in the front end

#

in the backend .... 6am and not sleeping

#
TypeError: Cannot read properties of undefined (reading 'accounts')

    async generateAccountUrl(email: string, business: number | null = null  ) {


        const payload = business ? {business} : null;

        email = "tim." +  123 + ".@gmail.com"

        console.log(email);
        

        const accountId =  await this.client.accounts.create({
            type: 'express',
            settings: {
                payouts: {
                    schedule: {
                        interval: 'manual'
                    }
                }
            },
            email});


            console.log(accountId);
            

        const {url} = await  this.client.accountLinks.create({
            account: accountId.id,
            type: 'account_onboarding',
            refresh_url: 'https://' + this.ctx.domain + '.' + env.ORIGIN + '/account',
            return_url: 'https://' + this.ctx.domain + '.' + env.ORIGIN + '/account'
        });

        return {
            accountId,
            url
        }
    }



#

and here the this.client.accounts block

#

export class PaymentService {


    ctx: BaseContext;
    client: Stripe;
    constructor(ctx: BaseContext) {
        this.ctx = ctx;        
        this.client = new Stripe(env.STRIPE_API_KEY);
        
        
    }

#

here I do the init of the api

valid wigeon
#

the request you shared is for creating a Customer, and your code is for creating a Stripe Account. These are two entirely different objects

shut furnace
#

yes and I dont sheat

#

so either its a bug ... or a feature

#

here stripe dashboard with request and here the requested email

#

and one both I have a customer and Itry to make a accounts

valid wigeon
#

in your backend, you use client.accounts.create and your error is

Cannot read properties of undefined (reading 'accounts')

It sounds to me like Stripe wasn't initialized / defined before you called it

#

I suggest that you add additional logs to your code to check when / whether Stripe is initialized, when you call this.client.accounts.create

shut furnace
#

its work perfectly earlier ...

valid wigeon
#

Perhaps you should revert to your previous code and give it another try? I'm not aware of what changes you made to the code earlier.

shut furnace
#

I change nothing .... reall

#

ok I see nodejs is really not good at

#


        const content = await get_custom_database.affiliate.generateOrganization({
            domain: payload.domain,
            email: payload.email,
            firstname: payload.firstname,
            lastname: payload.firstname,
            name: payload.name,
            userId: userId,
            roles: rolesPromised,
            affiliate_organization: organization,
            affiliate: business,
            generateBusinessAccount: get_custom_services.payment.generateAccountUrl,// <--
            billing_email: '',
            customer_account: customerAccount.id
        });

#

I do a function injection and doesnt work at all

valid wigeon
#

so when you add a log line before const accountId = await this.client.accounts.create({ to log this.client - what do you get?

shut furnace
#

I sen dyou the full object ?

#

ok fix it we can close the ticket

#

its was just a problem of function injection : like I do in dotnet/java and dont work in node

#

thanks for all !

#

will sleep a little bit 😴 have a good ?