#weretaco-terminaljs
1 messages ยท Page 1 of 1 (latest)
thanks
sorry was not able to look but can a colleague is catching up and they can help
One more question - how specifically did you install the stripe terminal library?
npm install @stripe/terminal-js
so when i do
import { loadStripeTerminal, Reader } from '@stripe/terminal-js/pure';
that's fine.. but when i load it with the browser i get an error saying it needs a relative path
localhost/:1
Uncaught TypeError: Failed to resolve module specifier "@stripe/terminal-js/pure". Relative references must start with either "/", "./", or "../".
is the specific error
What happens if you remove the /pure - I'm trying to pinpoint if the /pure is part of the issue or not
localhost/:1
Uncaught TypeError: Failed to resolve module specifier "@stripe/terminal-js". Relative references must start with either "/", "./", or "../".
same deal
also interesting
in terminal.d.ts
my tsconfig
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "ES2018",
"lib": [ "es2018", "DOM" ],
"outDir": "wwwroot/js",
"module": "ESNext",
"moduleResolution": "node",
"typeRoots": [
"./@types",
"./node_modules/@types",
"./node_modules/@stripe"
]
},
"exclude": [
"node_modules",
"wwwroot"
],
"include": [
"scripts/**/*"
]
}```
Hm... I wonder if you also need to specify "types"? Try this out and see if it helps:
"paths": {
"@stripe/terminal-js": [
"node_modules/@stripe/terminal-js/dist/terminal
.js"
]
}
Hello ๐ stepping in and catching up here. Looking in to this...
tahnks
also just for test purposes
i added
declare let StripeTerminal: any
and when i get to
await terminal.connectReader(reader)
i'm getting an "invalid type"
the reader object is being returned from a controller call to my .net backend
do i need to pass the rawJObject
That is a good question. Looking in to that too. I'm not too familiar with TypeScript/Terminal and have reached out to my colleagues who will have a better idea on this
๐ I'm back - are things still not working?
well i worked around the typings problem for now
declare let StripeTerminal: any
gets aroun d that
and for the readers.. i just added the call for discover, then filtered on the one i know they chose
var readers = await terminal.discoverReaders();
var selected = readers.discoveredReaders.find(r => r.id == self.terminalSelectedTerminal());
Well glad you could get it working - and sorry we weren't that helpful ๐ฆ
i might re-visit later
have a feeling i need to bring in webpack to roll up the imports for the browser
@honest otter done!
thanks.. so the basics are.. when you import as the docs say it includes implementation as well
and if you're not using a bundler that import line gets included in the js output when typescript compiles
so if you just want the typings and stuff like that
you can do
import type * as StripeTypes from '@stripe/terminal-js'
then the terminal creation is done as
self.connectedTerminal = StripeTerminal.create({
onFetchConnectionToken: this.fetchConnectionToken,
onUnexpectedReaderDisconnect: this.unexpectedDisconnect,
onConnectionStatusChange: this.terminalConnectionStatusChange
});```
so it grabs the global StripeTerminal object and goes from there