#bimal-pandey_unexpected
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1389100467740737708
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi, thanks for reaching out. Could you also share the code used for discover a reader?
useEffect(() => {
if (
!paymentIntegrations ||
!paymentIntegrations?.stripe ||
!paymentIntegrations?.stripe?.locationId
)
return;
initialize().then((vsl) => {
addLog(vsl);
handleDiscoverReaders();
});
}, []);
const handleDiscoverReaders = async () => {
const { error } = await discoverReaders({
discoveryMethod: Platform.OS === 'ios' ? 'bluetoothScan' : 'usb',
simulated: isSimulatedTerminal, // this is false when trying to connect to a real m2 reader.
locationId: paymentIntegrations?.stripe?.locationId, // If this doesn't exist then this component won't run
});
if (error) {
Alert.alert('Discover readers error: ', JSON.stringify(error, null, ' '));
}
};
const handleConnectBluetoothReader = async (selectedReader: Reader.Type) => {
addLog('connecting to ' + selectedReader.id);
const { reader, error } = await connectReader(
{
reader: selectedReader,
// @ts-ignore
locationId: paymentIntegrations?.stripe?.locationId,
},
Platform.OS === 'ios' ? 'bluetoothScan' : 'usb'
);
if (error) {
addLog(error);
showErrorMessage('Failed to connect to card reader');
return;
}
addLog(reader);
showSuccessMessage('Card reader connected successfully');
};
const {
initialize,
discoverReaders,
retrievePaymentIntent,
collectPaymentMethod,
discoveredReaders,
connectReader,
isInitialized,
confirmPaymentIntent,
connectedReader,
disconnectReader,
} = useStripeTerminal({
onUpdateDiscoveredReaders: (readers) => {
// After the SDK discovers a reader, your app can connect to it.
},
// Handle reader input requests (e.g., "Insert card", "Tap card")
onDidRequestReaderInput: (inputOptions) => {
addLog(`Reader input requested: ${inputOptions.join(', ')}`);
// Convert input options to user-friendly messages
const inputMessages = inputOptions.map((option) => {
switch (option) {
case 'insertCard':
return 'Insert your card';
case 'swipeCard':
return 'Swipe your card';
case 'tapCard':
return 'Tap your card';
default:
return `Present your ${option}`;
}
});
setUserMessage(inputMessages.join(' or '));
setShowUserMessage(true);
setPaymentStatus('processing');
},
// Handle reader display messages (e.g., "Retry card", "Remove card")
onDidRequestReaderDisplayMessage: (message) => {
addLog(`Reader display message: ${message}`);
// Convert technical messages to user-friendly ones
let userFriendlyMessage = '';
/// Here is code to convert the message to a userFriendly message but discord won't let me send all the messages
setUserMessage(userFriendlyMessage);
setShowUserMessage(true);
setPaymentStatus('processing');
},
// Handle when reader input is no longer needed
onDidReportReaderEvent: (event) => {
addLog(`Reader event: ${event}`);
if (event === 'cardInserted' || event === 'cardRemoved') {
setUserMessage('Processing payment...');
}
},
});
Thank you, looks normal to me. Which log did you get from handleConnectBluetoothReader ?
{
"reader": {
"id": "tmr_GFhv2QEdHCF5tG",
"label": null,
"batteryLevel": 1,
"serialNumber": "STRM26146006451",
"batteryStatus": "nominal",
"ipAddress": null,
"deviceSoftwareVersion": "2.01.00.31-SZZZ_Prod_US_v12-481001",
"deviceType": "stripeM2",
"isCharging": false,
"locationId": "tml_GD4NJQOJ5GwdRl",
"location": {
"livemode": false,
"id": "tml_GD4NJQOJ5GwdRl",
"displayName": "Raaz Test",
"address": {
"state": "CA",
"country": "US",
"line2": "",
"city": "San Francisco",
"line1": "300 W Washington Street",
"postalCode": "94111"
}
},
"availableUpdate": null,
"simulated": false,
"status": "offline",
"locationStatus": "set"
}
}
This is the log I believe
I have 2 terminals, and below is the log for another:
{
"reader": {
"id": "tmr_GFjJCQC1EqWGuK",
"label": null,
"batteryLevel": 0.8399999737739563,
"serialNumber": "STRM26214039968",
"batteryStatus": "nominal",
"ipAddress": null,
"deviceSoftwareVersion": "2.01.00.31-SZZZ_Prod_US_v1-480001",
"deviceType": "stripeM2",
"isCharging": true,
"locationId": "tml_GD4NJQOJ5GwdRl",
"location": {
"livemode": false,
"id": "tml_GD4NJQOJ5GwdRl",
"displayName": "Raaz Test",
"address": {
"state": "CA",
"country": "US",
"line2": "",
"city": "San Francisco",
"line1": "300 W Washington Street",
"postalCode": "94111"
}
},
"availableUpdate": {
"requiredAt": "1750777187089",
"deviceSoftwareVersion": "2.01.00.31-SZZZ_Prod_US_v12-481001",
"estimatedUpdateTime": "estimate2To5Minutes"
},
"simulated": false,
"status": "offline",
"locationStatus": "set"
}
Both of them don't work. I have 2 iPads too and I have tried all permutations.
Could you elaborate why are you doing this?
Platform.OS === 'ios' ? 'bluetoothScan' : 'usb'
I want android tablets to use usb which I found to be more reliable and on iOS I believe usb doesn't work so I used bluetoothScan as per the docs.
Ah I see, but let's say if you use bluetooth scan with Android, do you see the same issue?
I haven't tested that, give me 10 minutes.
Sure no rush. Just to share that not much we can tell from our internal log, the readere behaves like the collectPaymentMethod purely wasn't called
Thank you for your patience.
Yes I can confirm that when I discover readers via bluetoothScan even on android it hangs.
This is the reader that was discovered:
{
"reader": {
"settingsVersion": "AB91315AB4D9E0ABA497398AE2219CD2",
"macKeyProfileId": "1546",
"hardwareVersion": "STRM2-01 (0803)",
"availableUpdate": null,
"firmwareVersion": "2.01.00.31",
"emvKeyProfileId": "1546",
"configVersion": "SZZZ_Prod_US_v12",
"trackKeyProfileId": "1546",
"deviceSoftwareVersion": "2.01.00.31-SZZZ_Prod_US_v12-481001",
"ipAddress": null,
"serialNumber": "STRM26146006451",
"location": {
"livemode": false,
"address": {
"state": "CA",
"line2": "",
"line1": "300 W Washington Street",
"postalCode": "94111",
"city": "San Francisco",
"country": "US"
},
"displayName": "Raaz Test",
"id": "tml_GD4NJQOJ5GwdRl"
},
"locationStatus": "set",
"batteryLevel": 1,
"status": "unknown",
"deviceType": "stripeM2",
"bootloaderVersion": null,
"baseUrl": null,
"locationId": "tml_GD4NJQOJ5GwdRl",
"pinKeysetId": "481001",
"pinKeyProfileId": "1546",
"simulated": false,
"id": "tmr_GFhv2QEdHCF5tG",
"label": null
}
}
And below is the retrieved payment intent:
{
"paymentMethodOptions": {
"cardPresent": {
"surcharge": {
"maximumAmount": null,
"status": null
},
"requestIncrementalAuthorizationSupport": false,
"requestExtendedAuthorization": false
}
},
"paymentMethod": null,
"sdkUuid": "5d287319-b925-4d60-85fe-58e452b60a07",
"statementDescriptorSuffix": null,
"amountTip": 0,
"paymentMethodId": null,
"captureMethod": "automatic",
"statementDescriptor": null,
"currency": "usd",
"id": "pi_3RfadMDFyENhwoz80KMzLE19",
"metadata": {
"restaurantId": "raazkitchen@orderq.us",
"mode": "test",
"documentId": "3C7o2FGZKntORAYNwBw4"
},
"charges": [],
"created": "1751262724000",
"amount": 106,
"offlineDetails": null,
"amountDetails": {
"tip": {
"amount": null
}
},
"status": "requiresPaymentMethod"
}
Just tested it again, and it worked on android, but it did hang the first time.
below are the logs:
{
"reader": {
"settingsVersion": "AB91315AB4D9E0ABA497398AE2219CD2",
"macKeyProfileId": "1546",
"hardwareVersion": "STRM2-01 (0803)",
"availableUpdate": null,
"firmwareVersion": "2.01.00.31",
"emvKeyProfileId": "1546",
"configVersion": "SZZZ_Prod_US_v12",
"trackKeyProfileId": "1546",
"deviceSoftwareVersion": "2.01.00.31-SZZZ_Prod_US_v12-481001",
"ipAddress": null,
"serialNumber": "STRM26146006451",
"location": {
"livemode": false,
"address": {
"state": "CA",
"line2": "",
"line1": "300 W Washington Street",
"postalCode": "94111",
"city": "San Francisco",
"country": "US"
},
"displayName": "Raaz Test",
"id": "tml_GD4NJQOJ5GwdRl"
},
"locationStatus": "set",
"batteryLevel": 1,
"status": "unknown",
"deviceType": "stripeM2",
"bootloaderVersion": null,
"baseUrl": null,
"locationId": "tml_GD4NJQOJ5GwdRl",
"pinKeysetId": "481001",
"pinKeyProfileId": "1546",
"simulated": false,
"id": "tmr_GFhv2QEdHCF5tG",
"label": null
}
}
Retrieved intent:
{
"paymentMethodOptions": {
"cardPresent": {
"surcharge": {
"maximumAmount": null,
"status": null
},
"requestIncrementalAuthorizationSupport": false,
"requestExtendedAuthorization": false
}
},
"paymentMethod": null,
"sdkUuid": "df472c9b-7e75-40fc-b981-895c3f505881",
"statementDescriptorSuffix": null,
"amountTip": 0,
"paymentMethodId": null,
"captureMethod": "automatic",
"statementDescriptor": null,
"currency": "usd",
"id": "pi_3RfanhDFyENhwoz81YsBHyIU",
"metadata": {
"restaurantId": "raazkitchen@orderq.us",
"mode": "test",
"documentId": "00ovIjGJSf7HX01gWH1B"
},
"charges": [],
"created": "1751263365000",
"amount": 106,
"offlineDetails": null,
"amountDetails": {
"tip": {
"amount": null
}
},
"status": "requiresPaymentMethod"
}
Hmm so it's the unstable Bluetooth connection
The terminal is very close to the tablet. So distance is not the issue.
When testing, I try my best to turn off other tablet's bluetooth, just to make sure only 1 device is connecting.
Anything else that might make the connection unstable.
There is a beeping noise as soon as the collectPaymentMethod is called,, like the one that plays after successful payment.
Sorry just rubber-duck-debugging but can you try in an iPhone?
your POS app
Was iPad never able to connect even after a few tries?
Initially, when building the app, it would connect and work flawlessly, only hanging like once or twice a week. But suddenly it started hanging on every payment. There have been no code changes, so I thought it was a terminal issue, so I bought another m2 reader, it didn't work. So I thought my iPad was damaged somehow so I bought another iPad and nope it didn't work.
I don't have an iPhone, sorry.
Interesting
If you restart readers and the iPads, would it still completely not working?
yes, I have restarted the terminal and tablets multiple times. I even reset the iPad.
Also I noticed many Bluetooth issue fixed in 2.01.00.21. Could you check which firmware version your M2 readers are in?
"deviceSoftwareVersion": "2.01.00.31-SZZZ_Prod_US_v12-481001",
Is this the firmware version?
Yep
hmm
Do you receive any onDidStartReaderReconnect event?
And do you turn on autoReconnectOnUnexpectedDisconnect ?
I though autoReconnectOnUnexpectedDisconnect was true by default?
No, I have not manually set that to true.
onDidStartReaderReconnect Just tried this and no this one doesn't trigger.
I also tried to get connected reader just before payment via const readerStat = await getConnectedReader();
It logs
{
"id": "tmr_GFjJCQC1EqWGuK",
"label": null,
"batteryLevel": 0.8399999737739563,
"serialNumber": "STRM26214039968",
"batteryStatus": "nominal",
"ipAddress": null,
"deviceSoftwareVersion": "2.01.00.31-SZZZ_Prod_US_v1-480001",
"deviceType": "stripeM2",
"isCharging": true,
"locationId": "tml_GD4NJQOJ5GwdRl",
"location": {
"livemode": false,
"id": "tml_GD4NJQOJ5GwdRl",
"displayName": "Raaz Test",
"address": {
"state": "CA",
"country": "US",
"line2": "",
"city": "San Francisco",
"line1": "300 W Washington Street",
"postalCode": "94111"
}
},
"availableUpdate": {
"deviceSoftwareVersion": "2.01.00.31-SZZZ_Prod_US_v12-481001",
"requiredAt": "1750777187089",
"estimatedUpdateTime": "estimate2To5Minutes"
},
"simulated": false,
"status": "offline",
"locationStatus": "set"
}
Should the status be offline?
On android, status is unknown.
Yes that's weird. I suppose that should be online
Sorry I am running out of idea
- Double check (or attempt revert anyway) there wasn't any code changes.
- Ask Stripe Support to replace the M2 reader you just bought.
Does that status indicate it's connection to the internet or its power status?
If it is internet then running getConnectedReader just before retrievePaymentIntent also says offline but retrievePaymentIntent does indeed return back a response.
more of connection between reader <> POS app
aka the Bluetooth connection
By any chance do you have 2 POS app (2 deployed versions of it on 2 different devices) trying to connect to a same M2 reader?
Yes, but I closed the app and turned bluetooth off on another one.
Will that affect?
Oh they are not trying to connect to the same reader.
Alright, just for troubleshooting but if you open iPad's Bluetooth Settings (not your app), can you connect the the reader?
Okie now when you can reproduce on your POS app, could you share the full log from your app, up untill you are supposing to call collectPaymentMethod? (Put a breakpoint there and capture the log when it stops at collectPaymentMethod)
I'll need some time. This thread won't close, right?
We may close when my colleage take over. But you can always open a new thread and it will link back to this thread