airwallex / paymentacceptance-plugin-magento

Airwallex payment magento plugin
12 stars 3 forks source link

Feature/mb 21757 #25

Closed laurisdedumets closed 1 year ago

laurisdedumets commented 1 year ago

When installing the module through Composer, the Mobiledetectlib dependency gets installed with it, and also gets locked to a certain version (2.8.x), which has an alias class called Mobile_Detect installed with it. We try to detect this class to determine if payment methods are available, as some steps depend on specific mobile devices. If the class is not detected, payment methods won't show up, and a message will appear in the admin panel asking to install the library.

If a user installs the Airwallex module manually instead of through Composer, they will definitely have to install the dependency themselves, which we provide a command for in the admin panel message. The problem is that the message can potentially install a newer version of the library, such as 3.x.x, which doesn't have this alias anymore, therefore preventing the payment methods from ever appearing, because it can't find the class.

To fix this, we replaced the alias class to the fully PSR-namespace path to the main worker class, allowing the library to be detected successfully no matter the install version of it.