Skip to content

Commit

Permalink
Updating Rocket Rides for Express support in Canada, reworked databas…
Browse files Browse the repository at this point in the history
…e connection handler.
  • Loading branch information
mg-stripe committed Aug 7, 2019
1 parent 54c0e31 commit 7ef7c92
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ config.js
# Xcode
xcuserdata/

# VS Code
.vscode

# Cocoapods
Pods/

Expand Down
19 changes: 15 additions & 4 deletions server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,21 @@ app.set('trust proxy', true);

// MongoDB configuration
const mongoose = require('mongoose');
mongoose.connect(config.mongoUri, {
useNewUrlParser: true,
useCreateIndex: true,
});
const connectRetry = function() {
mongoose.connect(config.mongoUri, {
useNewUrlParser: true,
useCreateIndex: true,
reconnectTries: 30,
reconnectInterval: 1000,
poolSize: 50,
}, (err) => {
if (err) {
console.log('Mongoose connection error:', err);
setTimeout(5000, connectRetry);
}
});
}
connectRetry();

// Set up the view engine
app.set('view engine', 'pug');
Expand Down
10 changes: 6 additions & 4 deletions server/routes/pilots/stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ router.get('/authorize', pilotRequired, (req, res) => {
req.session.state = Math.random()
.toString(36)
.slice(2);
// Prepare the mandatory Stripe parameters: make sure to include our platform's client ID
// Define the mandatory Stripe parameters: make sure to include our platform's client ID
let parameters = {
client_id: config.stripe.clientId,
state: req.session.state,
};
// Optionally, the Express onboarding flow accepts `first_name`, `last_name`, `email`,
// and `phone` in the query parameters so the form fields will be prefilled
// and `phone` in the query parameters: those form fields will be prefilled
parameters = Object.assign(parameters, {
redirect_uri: config.publicDomain + '/pilots/stripe/token',
'stripe_user[business_type]': req.user.type || 'individual',
Expand Down Expand Up @@ -69,7 +69,7 @@ router.get('/token', pilotRequired, async (req, res, next) => {
// Post the authorization code to Stripe to complete the Express onboarding flow
const expressAuthorized = await request.post({
uri: config.stripe.tokenUri,
form: {
form: {
grant_type: 'authorization_code',
client_id: config.stripe.clientId,
client_secret: config.stripe.secretKey,
Expand Down Expand Up @@ -110,7 +110,9 @@ router.get('/dashboard', pilotRequired, async (req, res) => {
try {
// Generate a unique login link for the associated Stripe account to access their Express dashboard
const loginLink = await stripe.accounts.createLoginLink(
pilot.stripeAccountId
pilot.stripeAccountId, {
redirect_url: config.publicDomain + '/pilots/dashboard'
}
);
// Directly link to the account tab
if (req.query.account) {
Expand Down
1 change: 1 addition & 0 deletions server/views/signup.pug
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ block content
.row.select(label='Country')
select(name='country')
option(value='US') United States
option(value='US') Canada
aside * Indicates required fields
h4 Rocket information
fieldset
Expand Down

0 comments on commit 7ef7c92

Please sign in to comment.