#.nikuuuu

1 messages · Page 1 of 1 (latest)

agile thornBOT
alpine chasm
#

Hello! How are you currently passing the intent to the hardware terminal?

agile thornBOT
long portal
#

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; }

alpine chasm
#

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

long portal
#

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)

alpine chasm
#

No, I don't think that's quite right - I don't htink cancelAction is something we have in our JS terminal SDK

long portal
#

Do you know where the documentation for that is? We can't find any info on the JS terminal SDK other than the cancelAction

alpine chasm
#

We mention things there like using cancelCollectPaymentMethod() to cancel collecting a payment method

long portal
#

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

alpine chasm
#

👍

long portal
#

Thanks @alpine chasm that fixed it. So appreciate your help!

alpine chasm
#

hurray! glad you got it working