When this promise is run the browser just times out ( didn’t send any data. ERR_EMPTY_RESPONSE). There aren't any errors in the terminal. The first console.log is printed but nothing else.
var createStripeCustomer = function(customer, source) {
console.log('create stripe customer');
return new Promise(function(res, rej) {
stripe.customers.create({
email: customer.email,
source: source,
account_balance: 500,
metadata: {
first_name: customer.first_name,
last_name: customer.last_name,
phone: customer.phone,
address: `${customer.address} ${customer.appt}`,
city: customer.city,
state: customer.state,
zipcode: customer.zip,
referral: customer.referral
},
function(err, newCustomer) {
if (err) {
console.log(err);
rej(err);
}
else {
console.log('created customer');
res(newCustomer);
}
}
});
});
};
You have missed a
}
in thestripe.customers.create
method first parameter:and then it should work in this way: