title: How do I maintain consistency between third-party API and my own database?
body: <p>I am working with REST API and have the following scenario for processing request to make a payment:</p>
  
  <ol>
  <li>A client sends the request (payment information) to my own API.</li>
  <li>My API calls third-party REST API, passes it payment information, and receives a payment ID from it. If third-party API call fails for any reason, the error is returned to the client immediately.</li>
  <li>My API stores the resulting payment ID from step 2 and some extra info to its own database.</li>
  </ol>
  
  <p>I want the data to be consistent between third-party API and my own database. However, if for some reason the database is not accessible on step 3, I will end up with inconsistent data — the payment will exist in third-party API, but not in my own API's database.</p>
  
  <p>What's the best way of handling this consistency issue?</p>