capacitor-stripe-terminal icon indicating copy to clipboard operation
capacitor-stripe-terminal copied to clipboard

Ionic v1 + AngularJS ES5 project usage

Open iborschca opened this issue 3 years ago • 3 comments

Hey guys! Thank you so much for such amazing and useful plugin. I am a bit disappointed because I am having ES5 Ionic + AngularJS project and I want to use this plugin but I can't. I am wondering is there any chance I can leverage your amazing plugin with my old project without modernizing it entirely?

iborschca avatar Feb 02 '22 00:02 iborschca

In theory, you should be able to use it with ES5. Try importing this way:

const {
  StripeTerminalPlugin,
  DiscoveryMethod
} = require('capacitor-stripe-terminal')

Then you'd have to use promises instead of async/await.

Like I said, this should work in theory. I've not actually tried it.

nprail avatar Feb 02 '22 00:02 nprail

Unfortunately AngularJS is using AMD (Asynchronous module definition) I can't just use RequireJS directly. But I found the place where the framework is importing it. image On the screenshot you can see create() and discoverReaders() functions. Can you please help me to initialize an object instance of the class with help of these functions?

iborschca avatar Feb 02 '22 05:02 iborschca

Can't create an instance (( Screen Shot 2022-02-02 at 4 00 44 PM

iborschca avatar Feb 02 '22 23:02 iborschca

Yeah, unfortunately that does not work because the StripeTerminal class that is exposed by Capacitor is not the same as the StripeTerminalPlugin class that this plugin exports. Capacitor.Plugins.StripeTerminal is the native bridge directly generated by Capacitor. StripeTerminalPlugin contains a considerable amount of wrapper code that you are loosing by using StripeTerminal directly and it is not how this plugin is intended to be used.

AMD is not supported and isn't something I want to add support for.

You could use StripeTerminal exported by Capacitor but you would effectively have to re-create this entire file in your code to use it correctly: https://github.com/eventOneHQ/capacitor-stripe-terminal/blob/master/src/plugin.ts

nprail avatar Feb 28 '23 18:02 nprail