Working for Trek I seem to remember a training module that clearly stated that the primary cause of e-bike fires by a hefty margin is the use of non compatible or aftermarket charging systems. The training was likely with Trek or Bosch.
so basically, don’t do it! Don’t even think about it. These battery systems vary greatly in quality ( read as China home/off brand = crap ) and some of the cheap off brands are sensitive to polarity ( lacking protection to reversed polarity ) voltage ( little or no internal voltage control ) amperage ( you can damage the batteries by using too high or too low a current ) and my favourite… no overcharging protection. While your motor may be a respected make who knows who made the controller or battery pack. Different manufacturers place the charging controls in different places. Some place them in the charger, some the battery pack itself and some the bike’s control module. ( where batteries are not removable )
And… matching connectors doesn’t automatically mean they are compatible. Connectors and copies of common types of connectors are made by a lot of companies and sold widely in the electronics industry and how each end user arranges the pin out within the connector is up to them. At a previous job we had a customer set a fire in his house by using a “similar” battery charger with a matching connector. Luckily it was caught in time. ( the accepted term for this in the automotive industry is a “thermal event”, it seems to make the lawyers happy. I got crap for calling it a fire in my report)