#UnrealPlayer
1 messages · Page 1 of 1 (latest)
what was the exact code you used and that resulted in that error message?
Here is the code
console.log("cancel reader");
let body = JSON.parse(req.body);
console.log(`body: ${body}`);
console.log(`serial: ${body["serial_number"]}`);
console.log(`Cancel Reader Action with serial: ${body.serial_number}`);
if (!body?.serial_number) {
res.status(400).json({ message: "serial_number is required" });
return;
}
try {
const response = await fetch2.default(
"https://api.stripe.com/v1/terminal/readers?limit=3",
{
headers: {
Authorization:
"Basic " +
Buffer.from(
`${process.env.STRIPE_SECRET_KEY}:`
).toString("base64"),
},
}
);
if (response.status == 200) {
var readerObj;
let b : any = await response.json();
for (var i = 0; i < b.data?.length ?? 0; i++) {
let e = b.data[i];
if (e.serial_number == body.serial_number) {
readerObj = e;
break;
}
}
if (readerObj) {
try {
let reader = stripe.terminal.readers.cancelAction(readerObj.id);
res.send({ reader });
} catch (e: any) {
console.log(e);
res.send({ error: { message: e.message } });
}
} else {
res.status(404).json({
message: `Couldn't find any reader with serial number: ${body.serial_number}`,
});
return;
}
} else {
res.sendStatus(response.status);
return;
}
} catch (ex) {
console.log(ex);
res.sendStatus(500);
}
thanks. I'll have a look, but probably the M2 just doesn't support this so there isn't really a workaround, it's just not a supported flow
can you share a request ID req_xxx for the error too? https://support.stripe.com/questions/finding-the-id-for-an-api-request
here it is req_yFzkMjzwSBPaye
hmm, well was the reader actually doing something when you called this?
waiting for the card
in the code you are list listing all your readers and calling cancel on them , but as far as I can tell we would return this error message if there is "nothing to cancel"
I am not calling on all readers
I am finding my reader and only calling cancel on that reader
ah ok
are you sure it's processing a payment? Like I'm looking at your API logs and I don't see any calls to v1/terminal/readers/tmr_xxx/process_payment_intent ,but will look again
it is not processing payment, it is waiting for the customer card swipe
I can only cancel before customer swipe his/her card
process payment is the next step, aint it?
is the confusion that you're using our mobile SDKs with M2 for collecting payment info and processing payment, but the server-driven APIs for cancelling?
because in server driven, as far as I know, no, there is distinct "collect a payment method" step, you just call processPaymentIntent https://stripe.com/docs/terminal/payments/collect-payment?terminal-sdk-platform=server-driven#process-payment
if you're using iOS to connect to the reader and process the payment, you have to use the iOS SDK to cancel it(by calling .cancel() on the SCPCancelable returned from https://stripe.dev/stripe-terminal-ios/docs/Classes/SCPTerminal.html#/c:objc(cs)SCPTerminal(im)collectPaymentMethod:completion: )
yeah that's the issue, sorry for the confusion from my colleague, you were shown the wrong docs
Yeah, great!
Thanks
Also, Please add these things somewhere
I searched a lot for how to cancel the payment and wasted a lot of time.
Thanks for the quick support 🙂