2
votes

So I am trying to create a Stripe Connect account using a Firestore trigger function (onUpdate), but I keep getting the error: Error: Received unknown parameter: business_type in my Firebase Function logs. This makes me feel like I have poorly formatted the stripe.accounts.create() call. I followed the Stripe docs here. I got it working if I just include the values type, country, and email, but would like to include all important values right off the bat, but maybe I have to update other values after the account is created by stripe? If so is there a way to update these more values in the function(error, account) call below? Not a whole lot of example code I can find for this, so if anyone has worked with this and has some tips that would be great!

Snippet:

const response = await stripe.accounts.create({ 
  type: 'custom',
  country: 'US',
  // Optional Values
  requested_capabilities: ['platform_payments'],
  email: newValue.email,
  // tos_acceptance: newValue.stripeTosAcceptance,
  business_type: 'individual',
  individual: {
    //some other options values we could include (see docs)
    // address? Gender? default currency? verification docs?
    first_name: newValue.firstName,
    last_name: newValue.lastName,
    ssn_last_4: newValue.ssnLast4,
    dob: {
      day: newValue.dob.day,
      month: newValue.dob.month,
      year: newValue.dob.year
    }
  },
}, function(error, account) {
  if(error){
    console.log("Error: " + error);
  } else {
    console.log("Writing account.id to user DB...");
    admin
      .firestore()
      .collection("users")
      .doc(context.params.userId)
      .set({ connect_id: account.id }, { merge: true });
  }
});
1
When does this error happen? If the functions is deployed or during deployment?Sebastian Vischer
When the function is deployed to firebase, but on that note, perhaps there is a better way to test my function than deploying them to firebase every time?douglasrcjames
What version of the Stripe API is your account using? The way that Stripe handles connect accounts changed significantly very recently. I recommend upgrading your account to the latest and I suspect that will fix the issue. stripe.com/docs/upgrades#2019-02-19duck
Do you use Typescript? As @duck mentioned there were some recent changes and the @types/stripe type definitions are not updated. You could try npm i @types/stripe maybe they have added the missing types. Or you have to modify the type definition yourself. Had this problem with the Payment Intent API recently.Sebastian Vischer
Update: I went to my Stripe dashboard to upgrade the API version and it fixed that error! Thanks guys! (See stripe.com/docs/upgrades)douglasrcjames

1 Answers

3
votes

As @duck and @Sebe suggested, I went to the Stripe dashboard to upgrade the API version and it fixed that error! (See stripe.com/docs/upgrades) Seems Stripe recently changed/updated the values expected for the stripe.accounts.create() function, which was why the value mismatched the docs.