Here is my situation. I make different personalized stores for sports teams.
I make different stores for each of them on subdomains such as sportteam1.maindomain.com, sportteam2.maindomain.com, etc. The maindomain.com is the only domain with an SSL so the checkout has to go through there
In magento 1.9.3 and older version I just made different websites for each subdomain put the subdomain as the BASE_URL, and put https://maindomain.com as the SECURE_BASE_DOMAIN. I did everything myself and did not use any custom code.
It worked perfectly letting my customers shop on their team specific websites/stores, and then redirecting them to the SSL encrypted maindomain.com site when they entered the one page checkout.
Now that I have switched servers and gone to Magento 2.1.5 everything works as expected. I can shop at the subdomain site, but when I click checkout and get redirected to the SSL domain the items are no longer in the cart.
I tried all the common answers to this issue such as adding a Cookie Domain and lengthening the cookie lifetime with no luck.