arbis
arbis

Reputation: 1950

terms of service stripe connect

I've created a function to create a stripe custom company account for my users, and everything is working great, but when I try and update the terms of service data in node.js, it comes up with no errors, but when I go to the Stripe dashboard it says the account still requires a terms of service acceptance. What should I do?

Here is the function that creates the account:

export const createStripeMerchant = async(connectId: any, line1: any, line2: any, city: any, country: any, postCode: any,
  day: any, month: any, year: any, uid: any, email: any, firstName: any, lastName: any, phoneNumber: any) => {

  const account = await stripe.accounts.createPerson(
    connectId, {
      address: {
        line1: line1,
        line2: line2,
        city: city,
        country: country,
        postal_code: postCode,
      },
      dob: {
        day: day,
        month: month,
        year: year,
      },
      first_name: firstName,
      last_name: lastName,
      email: email,
      relationship: {
        executive: true,
        director: true,
        representative: true,
        title: 'Director',
      },
      phone: phoneNumber,
      metadata: {
        firebaseUID: uid
      },
    });

  await updateMerchantId(uid, {
    personAccountId: account.id
  });

  return account;
}

Here is the function that adds on the terms of service acceptance:

export const updateStripeConnect = async(connectId: any, uid: any, date: any, ip: any, userName: any) => {

  const account = await stripe.accounts.update(
    connectId, {
      tos_acceptance: {
        date: date,
        ip: ip,
        service_agreement: 'full',
        user_agent: userName,
      },
    }
  );
  return account;
}

I'm calling it like this:

createStripePerson({
  connectId: connectId,
  line1: address1.val(),
  line2: address2.val(),
  city: cityTown.val(),
  country: 'GB',
  postCode: postCode.val(),
  day: $("#dateOB").val().substring(8, 10),
  month: $("#dateOB").val().substring(5, 7),
  year: $("#dateOB").val().substring(0, 4),
  uid: uid,
  email: email.val(),
  firstName: firstName.val(),
  lastName: lastName.val(),
  phoneNumber: phoneInput.getNumber(),
}).then((result) => {
  /** @type {any} */
  const data = result.data;
  const textData = data.text;
  console.log("Result data: " + data);
  console.log("Text data: " + textData);


  updateStripeConnect({
    connectId: connectId,
    uid: uid,
    date: unixTimestamp,
    ip: ip,
    userName: firstName.val() + " " + lastName.val(),
  }).then((result) => {
    /** @type {any} */
    const data = result.data;
    const textData = data.text;
    console.log("Result data: " + data);
    console.log("Text data: " + textData);
  }).catch((error) => {
    console.log("Error message: " + error.message);
    console.log("Error details: " + error.details);
  });


}).catch((error) => {
  console.log("Error message: " + error.message);
  console.log("Error details: " + error.details);
});

So, as I said, it all goes through, but the terms of service does not get fulfilled / is still required in Stripe's dashboard:

Stripe Dashboard Image

Upvotes: 0

Views: 250

Answers (1)

koopajah
koopajah

Reputation: 25632

The code you shared that calls the Update Account API looks correct overall. The main issue you have is that you are not calling it synchronously with await so the call is likely failing/erroring but you are not properly catching the errors.

You should start by running that code on its own with a hardcoded account id to confirm that part of the code works. Make sure to use await or handle the callback and also handle errors properly. Once that works, you can then add clear logs to debug the other call that isn't working for you

Upvotes: 1

Related Questions