Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TransactionHelper.findTransaction(transactionId).then((transaction)=>{
- if(internalState === Models.Transaction.ISTATE_COMPLETE)
- {
- // TransactionHelper.endSuccessfulTransaction will also credit a user if it's a deposit
- return TransactionHelper.endSuccessfulTransaction(transaction, updateData);
- }
- else if(internalState === Models.Transaction.ISTATE_PENDING)
- {
- // update stuff
- return transaction.save();
- }
- else if(internalState === Models.Transaction.ISTATE_FAILED)
- {
- // TransactionHelper.endFailedTransaction will also refund user if needed
- return TransactionHelper.endFailedTransaction(transaction, updateData);
- }
- }).then((savedTransaction)=>{
- collected.transaction = savedTransaction;
- return Models.User.findOne({openId: savedTransaction.openId});
- }).then((foundUser) => {
- // returns stuff back to the bot
- return res.json(data);
- }).catch((err)=>{
- // error handling
- }).finally(() => {
- // send REDIS to SOCKET notification
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement