Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Promise.all(chargeArray.map(function(chargeData) {
- return stripe.tokens.create({
- customer: stripeCustomer,
- }, {
- stripe_account: chargeData["vendorStripeAccount"],
- }).then(function(token) {
- return stripe.charges.create({
- amount: chargeData["amount"],
- currency: "usd",
- source: token.id,
- application_fee: Math.round(chargeData["amount"] * 0.05)
- }, {
- stripe_account: chargeData["vendorStripeAccount"],
- })
- }).then(function(charge) {
- console.log("Created charge " + charge.id + " with amount " + charge.amount + "/" + "$" + charge.amount / 100)
- return order.save()
- .catch(function(err) {
- console.log(err.message)
- return err.message
- });
- }).catch(function(error) {
- console.log("Error creating charge" + " " + error);
- return error;
- })
- })).then((charges) => {
- res.status(200).send({ status: charges })
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement