2
votes

I'm trying to make an app/platform where a user can sign up for an account using Stripe Connect. I have a database with Firestore and the backend is using firebase cloud functions and nodejs.

Eventually the aim will be to take the data from the Stripe Connect sign up form and put it into my database (ID, email etc), but at the moment I am struggling to simply successfully sign them up.

I have created a cloud function with the following:

const functions = require('firebase-functions');
const express = require('express');
const stripe = require('stripe')('sk_test_51XXX');
const admin = require('firebase-admin');
admin.initializeApp();


exports.createStripeUser = functions.https.onRequest((req, res) => {

    var auth_code = stripe.oauth.token({
        grant_type: 'authorization_code',
        code: req.query.code,
})
})

When I use a test account it then eventually redirects me to a page that says "Error: could not handle the request". When I look at the Firebase Cloud Functions log it has a timeout error.

However, my Stripe dashboard shows the connected test accounts are being created. But clearly the process is not working as it should.

Could anyone help me or point me in the right direction?

1

1 Answers

2
votes

Funny after days of looking I find an answer that works minutes after posting this!

An HTTP request needs to end properly (with a send(), end(), or redirect()).

I added:

return res.send("Please close this page")