magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.5k stars 9.31k forks source link

Payment methods for specific country is not working in Checkout #10234

Closed ghost closed 5 years ago

ghost commented 7 years ago

Preconditions

Magento version 2.1.7

Steps to reproduce

1) Login to admin panel 2) Go to Stores >> Configuration >> Sales >> Payment method 3) Edit "Check/Money Order" method. 4) Set "Payment from Applicable Countries" to Specific Countries and select couple of countries. 5) On Frontend - open checkout and select any allowed country and click NEXT. It will show desired payment methods in next step. 6) Go back to Step #1 and select any other country which doesn't allow Check and Money Order and click NEXT. 7) It will still show Check and Money Order though it is set to NO for selected country. 8) If you refresh the checkout page and process again with same country - it will hide it according to settings.

Expected result

It should work based on selected country while step #1.

step 1

step2

step3

Actual result

Check Money Order payment method is still shown even when there is chosen not an allowed country.

step4

step6

tutd9x commented 7 years ago

I also encounter the issue.

joni-jones commented 7 years ago

Hi, @ravibhalodia, did you clear the cache and refresh the checkout page? After applying changes in the configuration, the checkout page should be refreshed because it uses local storage and available payment methods are also cached.

ghost commented 7 years ago

@joni-jones Yes, I cleared cache from Magento back office. Also, I tried by deleting VAR folder content as well. But it didn't work for me.

joni-jones commented 7 years ago

Did you refresh the Checkout page after applying config changes and cleaning the cache?

ghost commented 7 years ago

@joni-jones Yeah - I refreshed the page after making changes in back-office. It will work for one time only. But again if you come back to step#1, it will not work as expected.

joni-jones commented 7 years ago

Please, clarify, you refreshed the Checkout page after each changes applying and cleaning cache?

ghost commented 7 years ago

@joni-jones Yes, that's how it is. We did refresh checkout page after making changes in back office and clearing cache.

joni-jones commented 7 years ago

Please, attach a screenshot with expanded Check / Money order section, it should contain selected billing address. I suppose, when you are selecting shipping address with another country, the billing address country still the same.

ghost commented 7 years ago

Please find my screenshot from below. Fyi, I have selected Togo as the country in step#1.

step2 2

joni-jones commented 7 years ago

I've created internal ticket MAGETWO-70700. Thanks for reporting.

ghost commented 7 years ago

Thanks, I will wait for further updates.

ghost commented 7 years ago

Is this issue resolved already in ver2.1.9?

joni-jones commented 7 years ago

Hi, @ravibhalodia, this issue is not fixed yet.

magento-engcom-team commented 7 years ago

@ravibhalodia, thank you for your report. We've created internal ticket(s) MAGETWO-70700 to track progress on the issue.

IvanDotsenko commented 6 years ago

I am working on it at #mm17es

ghost commented 6 years ago

Is there any update on this issue? We are still facing in newer version of Magento as well.

trushangsuthartri commented 6 years ago

Hello @ravibhalodia

I am facing same issue #10234. have you got any fix for solve this issue?

vasanth833 commented 6 years ago

+1 Same issue in 2.2.2

bpoiss commented 6 years ago

Is there any workaround for this problem, or has someone any idea where the problem is located in the code?

jigar48 commented 6 years ago

Does this issue has been fixed on 2.2.6 ?

SignPainterThe commented 5 years ago

Seems that issue also take place in sample-module-payment-gateway. So, any updates?

thangasujitha commented 5 years ago

Hai, I also facing the same issue for braintree plugin in magento 2.2.4.. It shows only when I upgrade and deploy. after that It didnot show.. Can anyone give the solution for this

aishwaryasunarc commented 5 years ago

Hai,

I also same facing payment methods for specific country issue in Magento 2.2.6

staywithabhi commented 5 years ago

hi, Is there any update on this issue,facing the same issue in magento 2.3.0. Using onestepcheckout and facing the same issue

PascalBrouwers commented 5 years ago

Facing this issue too.

aishwaryasunarc commented 5 years ago

Any update ?

paragpadsumbiya commented 5 years ago

Hello @magento-engcom-team @orlangur Yes same issue with Magento 2.2.6 and Magento 2.3.0 . It is also not working this way for specific country . If you enabled any payment method for specific country and go to frontend then payment method will not show as per the selection of country . it will only show if you set payment method for all countries. I have checked with Default Magento checkout and onestepcheckout and mollie payment method and default magento payment method as well. But not working in any option .

This is very serious issue, need to resolve as soon as possible.

thangasujitha commented 5 years ago

Check the payment method configuration for each store view if you use multiple stores.

aishwaryasunarc commented 5 years ago

I am not using multiple stores in my system. I checked this issue with a single store.

paragpadsumbiya commented 5 years ago

@magento-engcom-team

Please resolve this issue as this one is from begging.

m2-assistant[bot] commented 5 years ago

Hi @AlexWorking. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

m2-assistant[bot] commented 5 years ago

Hi @engcom-backlog-nazar. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

ghost commented 5 years ago

Hello @ravibhalodia. At now we are not able to reproduce Your issue. Please watch here attached videos and point out to us the things we've missed or done wrong. Video1 Video2 Video3

aishwaryasunarc commented 5 years ago

The issue is coming when we have multiple addresses and switch addresses on the checkout page.

For example, I added multiple addresses from the address book of a customer. At checkout, I switch address from default shipping address to another address and another address to default shipping. In this scenario, the restricted payment method is not working properly.

Kindly check this scenario

ghost commented 5 years ago

@aishwaryasunarc , here is the next video with the case You described above. Unfortunately there is the same result as You can see. Issue is not reproduced. CMO

hitendra-wagento commented 5 years ago

I am working on this at #dmcdindia19

magento-engcom-team commented 5 years ago

@hitendra-wagento thank you for joining. Please accept team invitation here and self-assign the issue.

hitendra-wagento commented 5 years ago

@magento-engcom-team give me 2.2.3 instance

magento-engcom-team commented 5 years ago

Hi @hitendra-wagento. Thank you for your request. I'm working on Magento 2.2.3 instance for you

magento-engcom-team commented 5 years ago

Hi @hitendra-wagento, here is your Magento instance. Admin access: https://i-10234-2-2-3.instances.magento-community.engineering/admin Login: admin Password: 123123q Instance will be terminated in up to 3 hours.

hitendra-wagento commented 5 years ago

The issue is reproduce able coming when we have multiple addresses and switch addresses on the checkout page. Backend:-

1:-I have configured payment method for only United States Country.

Front End:- 1:-Created the New Customer and add the product in cart. 2:-I have created two address one for United State and second for India. 3:-At checkout, I switch address from default shipping address to another address it's show the previous shipping address in next step and required hard refresh.

please review the attached video for your reference:-

Backend Specific Country.zip](https://github.com/magento/magento2/files/3144111/Backend.Specific.Country.zip)

AlexWorking commented 5 years ago

The issue is not reproduced nether on 2.2-develop version nor on 2.3-develop version. Therefore we are closing it. If You manage to reproduce it on ether of the two aforementioned versions please reopen it. Thank You.

nkajic commented 5 years ago

@magento-engcom-team give me 2.3.2 instance

magento-engcom-team commented 5 years ago

Hi @nkajic. Thank you for your request. I'm working on Magento 2.3.2 instance for you

magento-engcom-team commented 5 years ago

Hi @nkajic, here is your Magento instance. Admin access: https://i-10234-2-3-2.instances.magento-community.engineering/admin Login: admin Password: 123123q Instance will be terminated in up to 3 hours.

nkajic commented 5 years ago

Still does not work on v2.3.2. In order to reproduce bug customer needs to be logged in (works fine for first time/non registered customers).

Create product in backend and customer on frontend Add multiple addresses to customer (for eg. one CRO and one SLO) Setup payment methods (one is enabled for all, enable other one for SLO only) Add product to cart and go to checkout. While switching addresses using "Ship Here" payment methods are not updated after clicking "Next".

niku0911 commented 4 years ago

is there any solution for this, because it's not working on 2.3.3?

neddy236 commented 3 years ago

@AlexWorking @magento-engcom-team this issue is still valid, please reponen it. Not working in magento 2.3.3(php7.3) nor magento 2.3.2 (php7.2).

I have managed to troubleshoot it a bit and found that the issue is in the following file on the getCountry() method vendor/magento/module-payment/Model/Checks/CanUseForCountry/CountryProvider.php

Original: public function getCountry(Quote $quote) { $address = $quote->getBillingAddress() ? : $quote->getShippingAddress(); return (!empty($address) && !empty($address->getCountry())) ? $address->getCountry() : $this->directoryHelper->getDefaultCountry(); }

Possible Solution:

public function getCountry(Quote $quote) { $address = $quote->getShippingAddress() ? : $quote->getBillingAddress(); return (!empty($address) && !empty($address->getCountry())) ? $address->getCountry() : $this->directoryHelper->getDefaultCountry(); }

EDIT: The following JS error happens because we had a mixin on step navigator. Above fix works.

If you set $address to shippingAddress it works just fine. But then if you select an address that has the payment method allowed for that country, click next, select the payment method, go back and select the other address which has the payment method disallowed and click next, you get the following JS error

Uncaught TypeError: Cannot read property 'hasOwnProperty' of null at ko.subscription.callback (step-navigator.js:52) at Function.notifySubscribers (knockout.js:1330) at Function.valueHasMutated (knockout.js:1548) at Object.observable [as paymentMethod] (knockout.js:1514) at select-payment-method.js:15 at Object.setPaymentMethods (payment-service.js:62) at Object. (default.js:61) at fire (jquery.js:3232) at Object.fireWith [as resolveWith] (jquery.js:3362) at done (jquery.js:9840) at XMLHttpRequest.callback (jquery.js:10311)