---
title: "How to Pre-select Default Payment Method at the Checkout Page in Magento 2?"
url: "https://magecomp.com/blog/pre-select-default-payment-method-at-the-checkout-page-magento-2/"
date: "2023-05-12T18:00:21+00:00"
modified: "2025-05-27T12:01:26+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 375
reading_time: "2 min read"
summary: "Hello Magento Friends,"
description: "To set the default payment method as selected by default in the Magento 2 checkout page, check out the guide"
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "How to Disable Empty Category Programmatically using Root Script in Magento 2?"
    url: "https://magecomp.com/blog/disable-empty-category-programmatically-using-root-script-magento-2/"
  - title: "How to Add Shipping Address Details in Order Grid in Magento 2?"
    url: "https://magecomp.com/blog/add-shipping-address-details-in-order-grid-in-magento-2/"
  - title: "How to Programmatically Create Invoice using Root Script in Magento 2"
    url: "https://magecomp.com/blog/programmatically-create-invoice-using-root-script-magento-2/"
---

# How to Pre-select Default Payment Method at the Checkout Page in Magento 2?

_Published: May 12, 2023_  
_Author: Dhiren Vasoya_  

![How to Pre-select Default Payment Method at the Checkout Page in Magento 2](https://magecomp.com/blog/wp-content/uploads/2023/05/How-to-Pre-select-Default-Payment-Method-at-the-Checkout-Page-in-Magento-2-1024x512.webp)

**Hello Magento Friends,**

In today’s blog, we will learn about How to Pre-select the Default Payment Method at the Checkout Page in Magento 2.
[![hyva theme development](https://magecomp.com/blog/wp-content/uploads/2025/02/hyva-theme-development-CTA-6.webp)](https://magecomp.com/services/hyva-theme-development/)

Checkout is the most crucial step in a customer’s shopping journey. Having a lengthy checkout process will fail to convert visitors into customers for your Magento 2 store. The quick checkout process is what every store owner must focus on to improve store efficiency.
If you have a payment method that most of your customers opt for, you can preselect the default payment method to reduce user actions.
Here are the steps to Pre-select Default Payment Method at the Checkout Page in Magento 2.
## Steps to Pre-select Default Payment Method at the Checkout Page in Magento 2:
**Step 1:** First, we must create the **“requirejs-config.js”** file inside the extension at the following path.
**app\code\Vendor\Extension\view\frontend**

Then write the code below
```
var config = {
    config: {
        mixins: {
            'Magento_Checkout/js/model/checkout-data-resolver': {
                'Vendor_Extension/js/model/checkout-data-resolver': true
            }
        }
    }
};
```

**Step 2:** After that, we must create a **“checkout-data-resolver.js”** file inside the extension at the following path.
**app\code\Vendor\Extension\view\frontend\web\js\model**

Now add the code as given below
```
define([
    'Magento_Checkout/js/model/payment-service',
    'Magento_Checkout/js/checkout-data',
    'Magento_Checkout/js/action/select-payment-method'
], function(
    paymentService,
    checkoutData,
    selectPaymentMethodAction
) {
    'use strict';

    return function(checkoutDataResolver) {
        checkoutDataResolver.resolvePaymentMethod = function() {
            var availablePaymentMethods = paymentService.getAvailablePaymentMethods(),
                selectedPaymentMethod = checkoutData.getSelectedPaymentMethod(),
                paymentMethod = selectedPaymentMethod ? selectedPaymentMethod : 'cashondelivery';
                //set payment method as per your requirement(i.e cashondelivery replace with your payment method)

            if (availablePaymentMethods.length > 0) {
                availablePaymentMethods.some(function (payment) {
                    if (payment.method == paymentMethod) {
                        selectPaymentMethodAction(payment);
                    }
                });
            }
        };
        return checkoutDataResolver;
    };
});
```

Once both files are created in your extension, run Magento upgrade and deploy commands in your server.
[![Hire Magento Programmer](https://magecomp.com/blog/wp-content/uploads/2025/02/Hire-Magento-Programmer-CTA-1.webp)](https://magecomp.com/services/hire-magento-programmer/)

Check in the storefront, you will see that the default payment method is pre-selected at the checkout page in Magento 2.
[![preselect default payment method](https://magecomp.com/blog/wp-content/uploads/2023/05/preselect-default-payment-method.png)](https://magecomp.com/blog/wp-content/uploads/2023/05/preselect-default-payment-method.png)

## Conclusion:
Hence, using the above steps, you can easily Pre-select the Default Payment Method at the Checkout Page in Magento 2 and reduce customer work in selecting the payment method.
Integrate your desired payment method into your Magento 2 store with the [**Payment Gateway Integration service**](https://magecomp.com/magento-2-payment-gateway-integration-service.html) and set it as the default payment method with pre-selection at the checkout page using the above method.
[![Magento version upgrade](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-2-Version-Upgrade-CTA-2-2.webp)](https://magecomp.com/services/magento-upgrade-services/)

Share the article with your friends and stay updated with us.
**Happy Coding!**


---

_View the original post at: [https://magecomp.com/blog/pre-select-default-payment-method-at-the-checkout-page-magento-2/](https://magecomp.com/blog/pre-select-default-payment-method-at-the-checkout-page-magento-2/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-09-10 16:15:11 UTC_  
