#ruul_api

1 messages ¡ Page 1 of 1 (latest)

restive swallowBOT
#

👋 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. Thank you for your patience!

⏱️ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime! If this thread is closed and you have another question you'll need to start a new thread.

🔗 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/1214881376231497789

📝 Have more to share? You can add more detail below, including code, screenshots, videos, etc.

verbal sluiceBOT
frigid heath
#

Hi
the error message of the request API call is quiet explicit:
Missing required param: customer.

winter haven
#

I'm already passing the customer attribute

#

the problem here is

#

when the user is created we create a customer corresponding to that user

#

const customer = await this.paymentService.createCustomer(
email,
${firstName} ${lastName}
);

  await this.collections.teams.updateOne(
    { _id: teamId },
    { $set: { stripeCustomerId: customer.id } }
  );
#

however we don't have anything stored in mongo for stripeCustomerId which makes it an issue with the part here

#

not the actual call to purchase

#

/**

  • Creates stripe customer
  • @param email string : customer email
  • @param name string : customer name
  • @param testClockId string : test clock id
  • @returns customer object
    */
    public async createCustomer(
    email: string,
    name: string,
    testClockId?: string
    ): Promise<Stripe.Customer> {
    return this.stripe.customers.create({
    email: email,
    name: name,
    ...(testClockId && { test_clock: testClockId }),
    });
    }
#

or yesterday depending on the timezone

#

but I don't see it in v1/customers

#

can you please confirm if it's the case, then it's a problem on our end

frigid heath
winter haven
#

ok I see it req_8VvRJwwnjU0RE0

frigid heath
winter haven
#

/**

  • Purchase subscription
  • @param customer customer id
  • @param price stripe price id
  • @param paymentMethodId id of the payment method (optional)
  • @param quantity number of items (optional)
  • @param trialDays trial days (optional)
  • @returns subscription object
    */
    public async purchaseSubscriptionWithPaymentMethodPresent(
    customer: string,
    price: string,
    paymentMethodId: string,
    quantity?: number,
    trialDays?: number
    ): Promise<Stripe.Subscription> {
    return this.stripe.subscriptions.create({
    customer,
    items: [{ price, ...(quantity && { quantity }) }],
    default_payment_method: paymentMethodId,
    ...(trialDays && { trial_period_days: trialDays }),
    });
    }
#

this is the method that we use

frigid heath
#

The issue is that you are not passing the customer in the request payload of the request req_9s7kSYwx7OqgFY

winter haven
#

I'm trying to tell that the customer parameter is null/undefined

#

and that's why its failing

#

the problem here is not the request itself but

#

there wasn't a customer created for that user I mentioned earlier

frigid heath
#

I'm trying to tell that the customer parameter is null/undefined
and that's why its
You need to double check your integration why it's not sending the correct customer id.

winter haven
#

the id is missing

frigid heath
#

Mayeb it is missing in your database/integration

#

but you need to make sure that you are sending it to Stripe APIs

winter haven
#

it's probably something weird on our side but

#

just to make sure

#

because the user I created just now got a customer id from the exact same method

frigid heath
#

Yes you need to double check/debug your integration and make sure to send the customer Id and not undefined

winter haven
frigid heath
winter haven
#

thanks

frigid heath
#

Happy to help!