#Monkey D. Luffy
1 messages · Page 1 of 1 (latest)
Hi there, are you using the Server driven integration?
No JS SDK
https://stripe.com/docs/terminal/payments/setup-integration?terminal-sdk-platform=js#connection-token This is how you set up a connection token endpoint. I'd suggest you to read through this doc first, let me know if you have any other questions.
Thanks, How can I know whether payment completed or not do I have to set up webhooks?
https://stripe.com/docs/terminal/payments/collect-payment?terminal-sdk-platform=js#process-payment the result from terminal.processPayment() tells you whether the payment is succeeded or not. And I'd strongly suggest you to build a webhook integration so that your system can still get the payment result even if the terminal reader suddenly go offline.
Sure Thanks
It should be StripeTerminal.create, capital S.
I have Using same but still getting same error
Did you include the js library?
Yes I have Installed It
Did you install it in your client side or server side?
client side
Can you share the code you're using that is throwing the error?
Sure
const StripeTerminal = loadStripeTerminal();
console.log("StripeTerminal", StripeTerminal);
const terminal = StripeTerminal.create({
onFetchConnectionToken: async () => {
fetchConnectionToken;
},
});
import { loadStripeTerminal } from "@stripe/terminal-js";
You probably need to await loadStripeTerminal()
Okay sure
I guess it hasn't initialised before you call it
While using await I am getting error that I have to use async() before using await
Yes you can't call await at the top-level yet. Something like this should work:
(async function() {
const StripeTerminal = await loadStripeTerminal()
}())
I will try
I am getting Invalid argument when I am passing connection token
Can you share the ID (req_xxx) of the failing API request? https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
req_1681203833876
app_error_code: "OK"
content: "ewp9"
error: ""
request_id: "1681203833876"
rpc_error_code: "RPC_OK"
What code are you calling?
const terminal = StripeTerminal.create()
From JS
I am passing connection token and getting that error
I am getting Invalid argument
There's no arguments passed here?
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!
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,
});
Could you please share the exact error message you're getting? With screenshots if possible.
What version of Stripe.js SDK are you using?
0.11.2
You mean @stripe/terminal-js?: https://www.npmjs.com/package/@stripe/terminal-js?activeTab=versions
Does your fetchConnectionToken function endpoint actually return the expected JSON?
yes
We are using GET API
{
"success": true,
"code": 200,
"data": {
"token": "pst_test_YWNjdF8xSUNSREtMbUNzc0paeFplLDYzbUZOVUJGa1p3SXFucllGQWxNZ3JLRkdkeVFqNHk_006I024buu"
}
}
This is the response
The key should be secret, not token
Okay
(well that's what you've used in your code):
.then(function(data) {
return data.secret;
});
I will change to secret
Hey, taking over here. Let me know if there's any follow-up Qs I can answer!