title: Is it okay to do database operations and API call in a single transaction?
body: <p>Let's take an example scenario for a simple buy operation where a user can pay from his wallet or from credit card or in case the amount exceed from the amount he has in his wallet then the remaining amount will be billed to his credit card. SO in that scenario there are two distinct transactions one to debit the wallet and then also charge the credit card. And let's assume that wallet is a DB operation while Credit card is a call to third party, is it okay to do both these operations in a single DB transaction so that if an one fails the entire operations rollsback or should I do it in parallel as most modern apps now utilize parallel operations. If I do both operations in parallel then how would I ensure the atomicity of the entire operation?</p>
  
  <p>How do we implement such kind of functionality in a microservices architecture or distributed applications?</p>
  
  <p>Thanks in advance.</p>