daily pastebin goal
15%
SHARE
TWEET

Untitled

a guest Jun 4th, 2018 468 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Promise.all(chargeArray.map(function(chargeData) {
  2.       return stripe.tokens.create({
  3.           customer: stripeCustomer,
  4.       }, {
  5.           stripe_account: chargeData["vendorStripeAccount"],
  6.       }).then(function(token) {
  7.           return stripe.charges.create({
  8.               amount: chargeData["amount"],
  9.               currency: "usd",
  10.               source: token.id,
  11.               application_fee: Math.round(chargeData["amount"] * 0.05)
  12.           }, {
  13.               stripe_account: chargeData["vendorStripeAccount"],
  14.           })
  15.       }).then(function(charge) {
  16.           console.log("Created charge " + charge.id + " with amount " + charge.amount + "/" + "$" + charge.amount / 100)
  17.           return order.save()
  18.               .catch(function(err) {
  19.                   console.log(err.message)
  20.                   return err.message
  21.               });
  22.       }).catch(function(error) {
  23.           console.log("Error creating charge" + " " + error);
  24.           return error;
  25.       })
  26.   })).then((charges) => {
  27.       res.status(200).send({ status: charges })
  28.   });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top