#.nikuuuu
1 messages · Page 1 of 1 (latest)
Hello! How are you currently passing the intent to the hardware terminal?
From the front end (angular) we are calling:
const result = await terminal.processPayment(paymentIntent);
const { terminal } = this.connectedTerminals[ this.searchInConnectedTerminals(reader, this.connectedTerminals) ]; const result = await terminal.processPayment(paymentIntent);
public searchInConnectedTerminals(value, array: Array<object>) { for (let i = 0; i < array.length; i++) { if (array[i]['reader']['id'] === value['id']) { return i; } } return -1; }
If you're making those calls from you're frontend (using our Stripe.js library) then you can't also be making requests from your backend to your reader. You can either make ALL your calls from your frontend, or all of them from your backend
Ok,
so on the front end would this be correct:
import { loadStripeTerminal } from '@stripe/terminal-js';
public async setTerminal() { const StripeTerminal = await loadStripeTerminal(); this.terminal = StripeTerminal.create({ onFetchConnectionToken: this.fetchConnectionToken, onUnexpectedReaderDisconnect: this.unexpectedDisconnect, }); }
public async connectReader(reader) { await this.setTerminal(); const terminal = this.getTerminal(); if ( this.connectedTerminals.length === 0 || this.searchInConnectedTerminals(reader, this.connectedTerminals) === -1 ) { this.connectedTerminals.push({ reader, terminal }); } else { this.connectedTerminals.splice( this.searchInConnectedTerminals(reader, this.connectedTerminals), 1 ); this.connectedTerminals.push({ reader, terminal }); } const connectResponse = await terminal.connectReader(reader); if (!connectResponse['error']) { localStorage.setItem('cardReader', JSON.stringify(reader)); } return connectResponse; }
const reader = await this.terminal.readers.cancelAction(id)
No, I don't think that's quite right - I don't htink cancelAction is something we have in our JS terminal SDK
Do you know where the documentation for that is? We can't find any info on the JS terminal SDK other than the cancelAction
We have a full API reference for our JS terminal library here: https://stripe.com/docs/terminal/references/api/js-sdk#api-methods
Have you also read through our docs on collect payments? https://stripe.com/docs/terminal/payments/collect-payment?terminal-sdk-platform=js
We mention things there like using cancelCollectPaymentMethod() to cancel collecting a payment method
Thanks, I think that last link is what we needed. It didn't come up when we were searching the api docs.
We will try that now
👍
Thanks @alpine chasm that fixed it. So appreciate your help!
hurray! glad you got it working