Magento 2 Payment Method You Requested is Not Available

You may see payment method you requested is not available error when you are using custom payment method or you are working on developing a custom payment module.

The solution of this blog post is only work if you are facing this error message when you can see your custom payment method on the Magneot 2 checkout page but when you are clicking on the Place Order button it’s throwing payment method you requested is not available error message.

I have created many custom payment module and i faced this issue while i am working on creating Moneris hosted payment extension. Following is what mistaken i have done and how i solved this issue.

Just make sure you have added “method” in getData function the Component JS of your magento 2 custom payment module. You can find this JS at app/code/YourModule/view/frontend/web/js/view/payment/method-renderer/

NOTE: This error will only come if you are setting data without extending parent getData. You can either enter “method” in data array or you can extends from the parent getData. If you do not wanted to pass any extra values then you can simply remove the getData function and this issue will also be solved.

getData: function () {
    var data = {
        'method': "your_paymentt_method_code"
        'additional_data': {
            'token': paymenttoken
        }
    };

    return data;
},