Skip to content

How to create a link to the Magento 2 checkout page for a cart created programmatically through REST API calls

I’m able to create a cart in Magento 2 programmatically calling rest APIs, being an administrator. I used this feature to allow users of another application to place orders on Magento, using a totally different user experience.

I would like, at the end of the process, to redirect people to the “normal” checkout page, to complete the payment and generate the order. The problem is that I’m not able to “inject” the user session ID (being him/her already registered or as a guest) in the checkout page, so that he/she would find the cart already filled.

Ideally I thought it would have been possible to generate a sort of a “payment link”, like Stripe does, in a form like:

https://example.com/checkout/cart/?session_id=something

I’m not experienced at all in Magento 2 development, but I wasn’t able to find any reference to a possibility like that. The same question has been asked here 4 months ago (Create a Magento store Checkout url via Magento REST API) but nobody answered.

I guess I can create a Magento extension to handle a new url and then handling in it the session “injection” and then the real redirection to the checkout page, but I’m wondering if there’s already a better way built in Magento to handle it.