Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. TransactionHelper.findTransaction(transactionId).then((transaction)=>{
  2.  
  3.             if(internalState === Models.Transaction.ISTATE_COMPLETE)
  4.             {
  5.                 // TransactionHelper.endSuccessfulTransaction will also credit a user if it's a deposit
  6.                 return TransactionHelper.endSuccessfulTransaction(transaction, updateData);
  7.             }
  8.             else if(internalState === Models.Transaction.ISTATE_PENDING)
  9.             {
  10.                 // update stuff
  11.  
  12.                 return transaction.save();
  13.             }
  14.             else if(internalState === Models.Transaction.ISTATE_FAILED)
  15.             {
  16.                 // TransactionHelper.endFailedTransaction will also refund user if needed
  17.                 return TransactionHelper.endFailedTransaction(transaction, updateData);
  18.             }
  19.  
  20.         }).then((savedTransaction)=>{
  21.             collected.transaction = savedTransaction;
  22.            
  23.             return Models.User.findOne({openId: savedTransaction.openId});
  24.  
  25.         }).then((foundUser) => {
  26.             // returns stuff back to the bot                        
  27.             return res.json(data);
  28.         }).catch((err)=>{
  29.             // error handling
  30.         }).finally(() => {         
  31.             // send REDIS to SOCKET notification               
  32.         });
  33.  
  34.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement