#bwurtz999

1 messages ยท Page 1 of 1 (latest)

urban briarBOT
opal halo
#

Hello ๐Ÿ‘‹
What have you tried so far?

lyric saddle
#

I've tried setting the terminal.setReaderDisplay() to a variable and then logging the output

#

I can see that it's a promise

#

But when I disconnect the card reader to simulate a failed attempt it just says pending

#

I'm trying to follow some basic JS promise examples online but I can't get the syntax right

opal halo
#

Can you share the code you're using?

lyric saddle
#
var request = terminal.setReaderDisplay({

        type: 'cart',
        cart: {
            line_items: info,
            tax: Math.round(tax * 100),
            total: Math.round(total * 100),
            currency: 'usd',
        }

    });

    request.then(
        function(value) {console.log('success')};
        function(error) {console.log('error')};
    );
opal halo
#

if you just do
request.then((res) => {console.log(res)};
What are you seeing?

lyric saddle
#

Uncaught syntax error when the page loads

#

oh wait hang on

#

it didn't copy properly

#

still the same syntax error

#

Am I missing something? I don't see an example provided in the Stripe docs for how to access the result of an error

#

I was looking through the JS docs and found an example of using a Promise so I updated my code and now there's no syntax error

#
var request = terminal.setReaderDisplay({

        type: 'cart',
        cart: {
            line_items: info,
            tax: Math.round(tax * 100),
            total: Math.round(total * 100),
            currency: 'usd',
        }

    }).then(function(result) {
        console.log(result);
        if(result.success) {
            console.log('success');
        } else if(result.error) {
            console.log('error');
        }
    });
#

But I don't get anything in the then function when the request fails

#

only when it succeeds

opal halo
#

oh interesting.. This would actually need a little more time to debug/reproduce.
Do you mind writing in to our support team support@stripe.com and mention that you spoke with hanzo on discord.
I'll grab the ticket and respond as soon as I can.

lyric saddle
#

OK

#

I sent it in

opal halo
#

Thanks, I'll respond via email as soon as I can ๐Ÿ™‚ thanks