#Monkey D. Luffy

1 messages · Page 1 of 1 (latest)

prisma scarabBOT
bright oasis
#

Hi there, are you using the Server driven integration?

turbid pendant
#

No JS SDK

bright oasis
turbid pendant
#

Thanks, How can I know whether payment completed or not do I have to set up webhooks?

bright oasis
turbid pendant
#

Sure Thanks

turbid pendant
#

I am getting this issue

#

stripeTerminal.create is not a function

bright oasis
#

It should be StripeTerminal.create, capital S.

turbid pendant
#

I have Using same but still getting same error

bright oasis
#

Did you include the js library?

prisma scarabBOT
turbid pendant
#

Yes I have Installed It

bright oasis
#

Did you install it in your client side or server side?

turbid pendant
#

client side

shy yarrow
#

Can you share the code you're using that is throwing the error?

turbid pendant
#

Sure

#

const StripeTerminal = loadStripeTerminal();
  console.log("StripeTerminal", StripeTerminal);
  const terminal = StripeTerminal.create({
    onFetchConnectionToken: async () => {
      fetchConnectionToken;
    },
  });

#

import { loadStripeTerminal } from "@stripe/terminal-js";

shy yarrow
#

You probably need to await loadStripeTerminal()

turbid pendant
#

Okay sure

shy yarrow
#

I guess it hasn't initialised before you call it

turbid pendant
#

While using await I am getting error that I have to use async() before using await

shy yarrow
#

Yes you can't call await at the top-level yet. Something like this should work:

(async function() {
  const StripeTerminal = await loadStripeTerminal()
}())
turbid pendant
#

I will try

turbid pendant
#

I am getting Invalid argument when I am passing connection token

shy yarrow
turbid pendant
#

req_1681203833876

#

app_error_code: "OK"
content: "ewp9"
error: ""
request_id: "1681203833876"
rpc_error_code: "RPC_OK"

shy yarrow
#

What code are you calling?

turbid pendant
#

const terminal = StripeTerminal.create()

#

From JS

#

I am passing connection token and getting that error

#

I am getting Invalid argument

shy yarrow
prisma scarabBOT
turbid pendant
#

I have passed arguments

#

I have passed connection Token

round frost
#

Hi! I'm taking over my colleague. Please, give me a moment to catch up.

#

Could you please share the complete code where you pass the connection token argument etc.? Thanks!

turbid pendant
#

Sure

#

function unexpectedDisconnect() {
// In this function, your app should notify the user that the reader disconnected.
// You can also include a way to attempt to reconnect to a reader.
console.log("Disconnected from reader")
}

function fetchConnectionToken() {
// Do not cache or hardcode the ConnectionToken. The SDK manages the ConnectionToken's lifecycle.
return fetch('/connection_token', { method: "POST" })
.then(function(response) {
return response.json();
})
.then(function(data) {
return data.secret;
});
}

var terminal = StripeTerminal.create({
onFetchConnectionToken: fetchConnectionToken,
onUnexpectedReaderDisconnect: unexpectedDisconnect,
});

round frost
turbid pendant
#

Sure

round frost
#

What version of Stripe.js SDK are you using?

turbid pendant
#

0.11.2

round frost
shy yarrow
#

Does your fetchConnectionToken function endpoint actually return the expected JSON?

turbid pendant
#

yes

#

We are using GET API

#

{
"success": true,
"code": 200,
"data": {
"token": "pst_test_YWNjdF8xSUNSREtMbUNzc0paeFplLDYzbUZOVUJGa1p3SXFucllGQWxNZ3JLRkdkeVFqNHk_006I024buu"
}
}

#

This is the response

shy yarrow
#

The key should be secret, not token

turbid pendant
#

Okay

shy yarrow
#

(well that's what you've used in your code):

.then(function(data) {
      return data.secret;
    });
turbid pendant
#

I will change to secret

prisma scarabBOT
lean cosmos
#

Hey, taking over here. Let me know if there's any follow-up Qs I can answer!