Create direct Checkout URL from my own native app/backend to Wix Store

Hi Wix Community!

I am trying to achieve the fairly straight forward flow of sending a user from our native app to the checkout flow of a product in our Wix Store. I would like to send the user directly to checkout, and to achieve that I need a “checkoutId” and the “cartId” to put in the URL that I send.

PREFERABLY there is just a link to a resource explaining some parts of this flow, that I am just missing (I have tried to search for it for some hours now but without luck on these last parts).

There are four parts as I see it:

  1. Get or create the user’s cart (get a “cartId”)
  2. Add a product to that cart
  3. Get or create the checkout (get a “checkoutId”)

I have access and can write code in clients and API’s, so I am using wix-http-functions to make the Wix API and my API communicate (initiated by my API). That part feels smooth.

Dilemmas I am encountering:

Ad 1) Get or create the user’s cart (get a “cartId”)

I would like the “cartId” of the user, but I would like it without a Wix Store open in the browser when retrieving it – so I can create a direct link to the checkout, and open the browser at that point. So I am looking for something like getCurrentCart but with the option to pass in the user id for which I would like to collect the cart for (so I am not dependent on the active browser session).

Ad 2) Add a product to that cart

Not an issue.

Ad 3) Get or create the checkout (get a “checkoutId”)

Same as for “cartId”, but I am unsure where a “checkoutId” is even retrieved if I had an active session?

Any help would be highly appreciated.

Love,
Thoger