Ecommerce Order from different IP

I have the following ecommerce process:

  1. User selects the item to purchase on my website. doTrackEcommerceCartUpdate is called
  2. The user is redirected to the third-party payment gateway where he/she pays via credit card.
  3. The payment gateway’s server calls a PHP script on my server to complete the order. This script calls doTrackEcommerceOrder.

The problem is that doTrackEcommerceCartUpdate is done using the client’s IP. However, doTrackEcommerceOrder will be done from a third-party server and will therefore have a different IP compared to the client IP that updated the cart.

So I end up with 2 carts on Piwik.1 abandoned cart (made from the client’s IP), and another completed cart (from the gateway’s IP).

Is there way to avoid this? Maybe somehow get a preliminary order ID from doTrackEcommerceCartUpdate and then use that ID in doTrackEcommerceOrder, respective of which IP made thew request.