Magento - onePage checkout and SSL (HTTPS)

Magento - onePage checkout and SSL (HTTPS)

July 9, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - onePage checkout and SSL (HTTPS)

Magento OnePage Checkout and SSL (HTTPS): Solving the Mixed Content Issue

Hello developers! Today we’re going to dive into an issue that many Magento store owners face when implementing one-page checkout: ensuring all communication is conducted over HTTPS to maintain security and prevent errors.

Understanding the Problem with Mixed Content

The core of the problem lies in Magento’s default configuration. Even if you’ve properly set up your SSL certificate and configured your domain to use HTTPS, Magento still generates internal links using HTTP protocol. This creates a mixed content situation - secure (HTTPS) pages loading unsecure (HTTP) scripts or styles.

In our friend’s case, when the one-page checkout was accessed via HTTPS, it attempted to load scripts and perform AJAX requests over HTTP internally, leading to a failure since you can’t mix protocols in modern browsers. The error message “X-JSON call to unsafe URL” is exactly what we’d expect under these circumstances.

Why Magento Behaves This Way

This issue stems from Magento’s core configuration files which are set up for default HTTP URLs. Even when you specify HTTPS URLs, the one-page checkout module doesn’t automatically update its internal configuration references.

Solving the Problem: A Step-by-Step Guide

1. Update Config XML Files

The first step is to update the core config.xml files where Magento defines the payment methods and default URLs. You can find these in app/code/core/Mage/Payment/etc/config.xml and app/code/core/Mage/Onepagecheckout/etc/config.xml.

You’ll see sections like this:

<config>
    <global>
        <payment>
            <method>
                <checkmo>
                    <info>
                        <title>Cash On Delivery</title>
                    </info>
                    <specific>
                        <form_field_visibility>
                            <cpo_number>never</cpo_number>
                            <card_number>never</card_number>
                            <card_type>never</card_type>
                            <cvv_number>never</cvv_number>
                            <month_expires>never</month_expires>
                            <year_expires>never</year_expires>
                        </form_field_visibility>
                    </specific>
                </checkmo>
            </method>
        </payment>
    </global>
</config>

In each <method> section, look for the <url> child element. Replace any instances of “http://yourdomain.com” with “https://yourdomain.com”. Be sure to update both files.

2. Update Rewrite Rules

Next, you need to ensure that your .htaccess file is properly configured for SSL redirection and rewrite rules for one-page checkout URLs. The default Magento configuration should already have the necessary rules, but double-check them:

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

RewriteEngine On
RewriteBase /

# Rewrite for onepage checkout
RewriteRule ^checkout/cart/add/uenc/([^/.]+)/(/)?$ checkout/cart/add/uenc/$1$2

3. Clear Cache and Reindex

After updating the files, remember to clear your Magento cache and reindex all data:

  1. Log in to your Magento admin panel.
  2. Go to System > Cache Management.
  3. Select all cache types and click “Flush Magento Cache”.
  4. Navigate to System > Index Management.
  5. Click “Reindex All” under the ‘Actions’ column.

Conclusion

While our friend’s approach of manually replacing HTTP with HTTPS using jQuery was a clever workaround, it’s not a sustainable solution in the long run due to potential conflicts and compatibility issues.

By updating the core configuration files and ensuring your .htaccess is correctly set up for SSL redirection, you can eliminate mixed content issues and maintain a secure one-page checkout process.

Remember, when dealing with sensitive data like customer information and payment details, security should always be your top priority. If you’re not comfortable making these changes yourself, don’t hesitate to contact a certified Magento developer or reach out to our team at Laravel Company for expert assistance.

Happy coding!

Checkout Security Extensions Configuration

Our network