capacitor-stripe-terminal
capacitor-stripe-terminal copied to clipboard
Ionic v1 + AngularJS ES5 project usage
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?
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.
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.
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?
Can't create an instance ((
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